Skip to content

Conversation

@HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Sep 24, 2025

Summary by CodeRabbit

  • New Features
    • Added API endpoints to interact with Anthropic models:
      • POST /anthropic/v1/messages for sending messages (supports system prompts, tools, streaming, and configurable parameters).
      • POST /anthropic/v1/messages/count_tokens for estimating token usage.
  • Documentation
    • Updated API specification to include the new endpoints with request/response definitions and supported options.

@coderabbitai
Copy link

coderabbitai bot commented Sep 24, 2025

Walkthrough

Added 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

Cohort / File(s) Summary
OpenAPI: Anthropic endpoints and schemas
src/libs/DeepInfra/openapi.yaml
Added POST /anthropic/v1/messages and /anthropic/v1/messages/count_tokens with header params and request bodies. Introduced schemas: AnthropicMessagesIn, AnthropicTokenCountRequest, AnthropicSystemContent, AnthropicThinkingConfig, AnthropicTool. Wired schemas into endpoints and components with cross-references.

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
Loading
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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump my paw: new paths appear,
Two posts to call, both crisp and clear.
Schemas bloom like clover bright,
Tools and thoughts in tidy light.
Tokens counted, messages sent—
A hop, a skip, well-documented! 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title “feat:@coderabbitai” is vague and doesn’t describe the primary changeset details, so it doesn’t convey the added API endpoints or schemas. It uses a generic feature prefix and a team mention without summarizing the contents. Consider renaming the pull request to clearly describe the main changes, for example “Add Anthropic messaging and token counting endpoints to OpenAPI spec.”
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bot/update-openapi_202509241825

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@HavenDV HavenDV enabled auto-merge (squash) September 24, 2025 18:25
@HavenDV HavenDV merged commit fb29150 into main Sep 24, 2025
3 of 4 checks passed
@HavenDV HavenDV deleted the bot/update-openapi_202509241825 branch September 24, 2025 18:27
@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:Add Anthropic POST endpoints and supporting schemas to openapi.yaml Sep 24, 2025
Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between d038f4f and 4375fe4.

⛔ Files ignored due to path filters (35)
  • src/libs/DeepInfra/Generated/DeepInfra..JsonSerializerContext.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.DeepInfraClient.AnthropicMessages.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.DeepInfraClient.AnthropicMessagesCountTokens.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.IDeepInfraClient.AnthropicMessages.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.IDeepInfraClient.AnthropicMessagesCountTokens.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.JsonConverters.AnthropicSystemContentType.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.JsonConverters.AnthropicSystemContentTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesAnthropicV1MessagesPostResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesAnthropicV1MessagesPostResponse.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesCountTokensAnthropicV1MessagesCountTokensPostResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesCountTokensAnthropicV1MessagesCountTokensPostResponse.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesIn.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesIn.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesInMessage.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesInMessage.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesInMetadata.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesInMetadata.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesInToolChoice.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicMessagesInToolChoice.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicSystemContent.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicSystemContent.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicSystemContentType.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicThinkingConfig.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicThinkingConfig.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTokenCountRequest.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTokenCountRequest.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTokenCountRequestMessage.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTokenCountRequestMessage.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTokenCountRequestToolChoice.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTokenCountRequestToolChoice.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTool.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicTool.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicToolInputSchema.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.AnthropicToolInputSchema.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/DeepInfra/openapi.yaml (2 hunks)

Comment on lines +4867 to +4933
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:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants