OpenAI Compatible API

Accepts the OpenAI Chat Completions request format and preserves the matching response, SSE, and error structures. Recommended for projects using the OpenAI SDK and for most new projects — existing OpenAI SDK code migrates by changing only the base URL and API key.

POST/api/v1/chat/completions

OpenAI Chat Completions

OpenAI Chat Completions 兼容入口,额外字段按模型能力透传。

Bearer API KeyUse the Authorization: Bearer sk_live_... header; x-api-key is also supported.
Confirm the model call name firstFirst filter models that support this endpoint format on the Models page, then open a model detail page to copy its call name. Your account's final availability also depends on organization permissions.

Request structure

The section below confirms the method, URL and authentication scheme. It is an HTTP structure snippet, not a standalone runnable example.

HTTP
POST https://www.silvamux.com/api/v1/chat/completions
Authorization: Bearer $SILVAMUX_API_KEY
Content-Type: application/json

Request body

application/json · OpenAIChatRequest · Required

FieldTypeRequiredDescription
max_tokensintegerNo
messagesarray<Message>Yes
messages.contentstring | array<FreeFormObject>Yes
messages.rolestring (system | user | assistant | tool)Yes
modelstringYesSilvaMux 模型 id 或 alias。
streambooleanNoDefault: false
temperaturenumberNo
toolsarray<FreeFormObject>No

Response

200OpenAI Chat JSON 或 SSE 响应。

application/json · OpenAIChatResponse

FieldTypeRequiredDescription
choicesarray<FreeFormObject>Yes
idstringYes
modelstringNo
objectstringNo
usageFreeFormObjectNo

defaultOpenAI 兼容错误。

application/json · OpenAIError

FieldTypeRequiredDescription
errorobjectYes
error.codestring | integerNo
error.messagestringYes
error.typestringNo

Examples

curl https://www.silvamux.com/api/v1/chat/completions \
  -H "Authorization: Bearer $SILVAMUX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "minimax-m2.5",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant"},
      {"role": "user", "content": "Hello"}
    ],
    "stream": false
  }'

Response (OpenAI format):

{
  "id": "chatcmpl-xxxx",
  "choices": [
    {
      "message": {"role": "assistant", "content": "Hello! How can I help you today?"},
      "finish_reason": "stop"
    }
  ],
  "usage": {"prompt_tokens": 20, "completion_tokens": 15, "total_tokens": 35}
}

The compatible entry passes through extra fields of the corresponding protocol. See Overview for streaming and multimodal input.