-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat:Add Anthropic POST endpoints and supporting schemas to openapi.yaml #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdded two Anthropic-related POST endpoints to the OpenAPI spec and introduced several supporting schemas (messages input, token count request, system content, thinking config, tool). Request bodies reference the new schemas, with standard 200/422 responses. All changes are confined to src/libs/DeepInfra/openapi.yaml. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant API as DeepInfra API
participant Router as Endpoint Router
participant Handler as Anthropic Controller
rect rgb(230,245,255)
note over Client,Handler: Create Message
Client->>API: POST /anthropic/v1/messages (AnthropicMessagesIn)
API->>Router: Route request
Router->>Handler: Validate headers/body
Handler-->>Client: 200 OK (message response)
Handler-->>Client: 422 Unprocessable Entity (on validation error)
end
sequenceDiagram
autonumber
actor Client
participant API as DeepInfra API
participant Router as Endpoint Router
participant Handler as Token Count Controller
rect rgb(240,255,240)
note over Client,Handler: Count Tokens
Client->>API: POST /anthropic/v1/messages/count_tokens (AnthropicTokenCountRequest)
API->>Router: Route request
Router->>Handler: Validate headers/body
Handler-->>Client: 200 OK (token count)
Handler-->>Client: 422 Unprocessable Entity (on validation error)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (35)
src/libs/DeepInfra/Generated/DeepInfra..JsonSerializerContext.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.DeepInfraClient.AnthropicMessages.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.DeepInfraClient.AnthropicMessagesCountTokens.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.IDeepInfraClient.AnthropicMessages.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.IDeepInfraClient.AnthropicMessagesCountTokens.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.JsonConverters.AnthropicSystemContentType.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.JsonConverters.AnthropicSystemContentTypeNullable.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.JsonSerializerContextTypes.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesAnthropicV1MessagesPostResponse.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesAnthropicV1MessagesPostResponse.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesCountTokensAnthropicV1MessagesCountTokensPostResponse.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesCountTokensAnthropicV1MessagesCountTokensPostResponse.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesIn.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesIn.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesInMessage.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesInMessage.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesInMetadata.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesInMetadata.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesInToolChoice.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesInToolChoice.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicSystemContent.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicSystemContent.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicSystemContentType.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicThinkingConfig.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicThinkingConfig.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTokenCountRequest.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTokenCountRequest.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTokenCountRequestMessage.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTokenCountRequestMessage.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTokenCountRequestToolChoice.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTokenCountRequestToolChoice.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTool.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTool.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicToolInputSchema.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicToolInputSchema.g.csis excluded by!**/generated/**
📒 Files selected for processing (1)
src/libs/DeepInfra/openapi.yaml(2 hunks)
| title: AnthropicMessagesIn | ||
| required: | ||
| - model | ||
| - messages | ||
| type: object | ||
| properties: | ||
| model: | ||
| title: Model | ||
| type: string | ||
| max_tokens: | ||
| title: Max Tokens | ||
| type: integer | ||
| nullable: true | ||
| messages: | ||
| title: Messages | ||
| type: array | ||
| items: | ||
| type: object | ||
| system: | ||
| title: System | ||
| anyOf: | ||
| - type: string | ||
| - type: array | ||
| items: | ||
| $ref: '#/components/schemas/AnthropicSystemContent' | ||
| nullable: true | ||
| stop_sequences: | ||
| title: Stop Sequences | ||
| type: array | ||
| items: | ||
| type: string | ||
| nullable: true | ||
| stream: | ||
| title: Stream | ||
| type: boolean | ||
| default: false | ||
| nullable: true | ||
| temperature: | ||
| title: Temperature | ||
| type: number | ||
| default: 1 | ||
| nullable: true | ||
| top_p: | ||
| title: Top P | ||
| type: number | ||
| nullable: true | ||
| top_k: | ||
| title: Top K | ||
| type: integer | ||
| nullable: true | ||
| metadata: | ||
| title: Metadata | ||
| type: object | ||
| nullable: true | ||
| tools: | ||
| title: Tools | ||
| type: array | ||
| items: | ||
| $ref: '#/components/schemas/AnthropicTool' | ||
| nullable: true | ||
| tool_choice: | ||
| title: Tool Choice | ||
| type: object | ||
| nullable: true | ||
| thinking: | ||
| $ref: '#/components/schemas/AnthropicThinkingConfig' | ||
| AnthropicSystemContent: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark max_tokens as required for Anthropic requests.
POST /anthropic/v1/messages rejects requests that omit max_tokens (same as Anthropic’s upstream contract). Because the schema doesn’t list it as required, auto-generated clients will happily drop the field and hit runtime 400s. Please add it to the required array so the spec matches the actual behavior.
required:
- model
- messages
+ - max_tokens📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| title: AnthropicMessagesIn | |
| required: | |
| - model | |
| - messages | |
| type: object | |
| properties: | |
| model: | |
| title: Model | |
| type: string | |
| max_tokens: | |
| title: Max Tokens | |
| type: integer | |
| nullable: true | |
| messages: | |
| title: Messages | |
| type: array | |
| items: | |
| type: object | |
| system: | |
| title: System | |
| anyOf: | |
| - type: string | |
| - type: array | |
| items: | |
| $ref: '#/components/schemas/AnthropicSystemContent' | |
| nullable: true | |
| stop_sequences: | |
| title: Stop Sequences | |
| type: array | |
| items: | |
| type: string | |
| nullable: true | |
| stream: | |
| title: Stream | |
| type: boolean | |
| default: false | |
| nullable: true | |
| temperature: | |
| title: Temperature | |
| type: number | |
| default: 1 | |
| nullable: true | |
| top_p: | |
| title: Top P | |
| type: number | |
| nullable: true | |
| top_k: | |
| title: Top K | |
| type: integer | |
| nullable: true | |
| metadata: | |
| title: Metadata | |
| type: object | |
| nullable: true | |
| tools: | |
| title: Tools | |
| type: array | |
| items: | |
| $ref: '#/components/schemas/AnthropicTool' | |
| nullable: true | |
| tool_choice: | |
| title: Tool Choice | |
| type: object | |
| nullable: true | |
| thinking: | |
| $ref: '#/components/schemas/AnthropicThinkingConfig' | |
| AnthropicSystemContent: | |
| title: AnthropicMessagesIn | |
| required: | |
| - model | |
| - messages | |
| - max_tokens | |
| type: object | |
| properties: | |
| model: | |
| title: Model | |
| type: string | |
| max_tokens: | |
| title: Max Tokens | |
| type: integer | |
| nullable: true | |
| messages: | |
| title: Messages | |
| type: array | |
| items: | |
| type: object | |
| system: | |
| title: System | |
| anyOf: | |
| - type: string | |
| - type: array | |
| items: | |
| $ref: '#/components/schemas/AnthropicSystemContent' | |
| nullable: true | |
| stop_sequences: | |
| title: Stop Sequences | |
| type: array | |
| items: | |
| type: string | |
| nullable: true | |
| stream: | |
| title: Stream | |
| type: boolean | |
| default: false | |
| nullable: true | |
| temperature: | |
| title: Temperature | |
| type: number | |
| default: 1 | |
| nullable: true | |
| top_p: | |
| title: Top P | |
| type: number | |
| nullable: true | |
| top_k: | |
| title: Top K | |
| type: integer | |
| nullable: true | |
| metadata: | |
| title: Metadata | |
| type: object | |
| nullable: true | |
| tools: | |
| title: Tools | |
| type: array | |
| items: | |
| $ref: '#/components/schemas/AnthropicTool' | |
| nullable: true | |
| tool_choice: | |
| title: Tool Choice | |
| type: object | |
| nullable: true | |
| thinking: | |
| $ref: '#/components/schemas/AnthropicThinkingConfig' | |
| AnthropicSystemContent: |
🤖 Prompt for AI Agents
In src/libs/DeepInfra/openapi.yaml around lines 4867 to 4933, the
AnthropicMessagesIn schema omits max_tokens from the required array which causes
generated clients to omit it and receive 400s; update the schema by adding
max_tokens to the required list for AnthropicMessagesIn so the OpenAPI spec
mandates the field and aligns with the upstream Anthropic behavior.
Summary by CodeRabbit