Skip to main content
This is the reference for integrating the OpenAI and Anthropic SDKs with SERV. For a five-minute setup, start with the Quickstart. SERV exposes three HTTP endpoints under one base URL: https://inference-api.openserv.ai
EndpointShapeUse it for
POST /v1/chat/completionsOpenAIUniversal. Works with every model in the catalog.
POST /v1/responsesOpenAIOpenAI models, with streamed reasoning summaries.
POST /v1/messagesAnthropicClaude and most other providers. See endpoint compatibility.

OpenAI SDK

Chat completions

Responses

Use the Responses API to receive the reasoning trace alongside the answer. OpenAI models only.

Anthropic SDK

Messages

Important details

Base URL differs by SDK

SDKBase URLWhy
OpenAI SDKhttps://inference-api.openserv.ai/v1The OpenAI SDK expects /v1 in the base URL.
Anthropic SDKhttps://inference-api.openserv.aiThe Anthropic SDK appends /v1/messages itself. Including /v1 yourself would call /v1/v1/messages, which fails.

Auth field differs by SDK

SDKFieldNotes
OpenAI SDKapiKeyStandard.
Anthropic SDKauthTokenapiKey also works, but authToken keeps ANTHROPIC_API_KEY free if you ever fall back to direct Anthropic.

A system prompt is required

Every request needs a system, developer, or instructions message. Requests without one are rejected:
Where the system prompt goes depends on the endpoint:
EndpointWhere the system prompt goes
/v1/chat/completionsa { role: "system", content: "..." } message
/v1/responsestop-level instructions
/v1/messagestop-level system

Parameter map

Moving an integration across SDKs comes down to this mapping.
ConceptOpenAI ChatOpenAI ResponsesAnthropic Messages
HTTP path/v1/chat/completions/v1/responses/v1/messages
Auth field (SDK constructor)apiKeyapiKeyauthToken
baseURL suffix to use with SERV/v1/v1(none)
Token cap fieldmax_completion_tokensmax_output_tokensmax_tokens (required)
System promptmessage with role:"system"top-level instructionstop-level system
User message shape{role, content} in messages[]top-level input (string or array){role, content} in messages[]
Reasoning-effort controlreasoning_effortreasoning: { effort, summary }thinking: { type:"enabled", budget_tokens }
Streamingstream: truestream: truestream: true
Stop sequencesstopn/astop_sequences
Tool schematools: [{type:"function", function:{name, parameters}}]tools: [{type:"function", ...}]tools: [{name, input_schema}] (no nested function:)
Tool choicetool_choice: "auto" | {type:"function", function:{name}}tool_choice: ...tool_choice: "auto" | "any" | {type:"tool", name}
Response textchoices[0].message.contentoutput_text or output[] blockscontent[] array, find the type === "text" block
Token usageusage.prompt_tokens / completion_tokens / total_tokensusage.input_tokens / output_tokens / total_tokensusage.input_tokens / output_tokens
Cache metricsusage.prompt_tokens_details.cached_tokensusage.input_tokens_details.cached_tokensusage.cache_read_input_tokens, usage.cache_creation_input_tokens

See also