beatra

Create chat completion (OpenAI-compatible)

Creates a chat completion using an OpenAI-compatible request and response shape. Set `stream=true` to receive Server-Sent Events with `chat.completion.chunk` payloads. Use `model="auto"` to let beatra choose a capable model, or pass a specific model id returned by `/v1/models`.

POST
/v1/chat/completions

Request Body

application/jsonRequired
model
Required
Model

Model name (e.g. 'gpt-4o-mini', 'qwen-max', 'auto')

messages
Required
Messages
temperatureTemperature
top_pTop P
max_tokensMax Tokens

Legacy; reasoning models reject this. beatra maps to max_completion_tokens.

max_completion_tokensMax Completion Tokens
nN
seedSeed
stopStop
streamStream
Default: false
stream_optionsAny properties in StreamOptions
frequency_penaltyFrequency Penalty
presence_penaltyPresence Penalty
logit_biasLogit Bias
logprobsLogprobs
top_logprobsTop Logprobs
toolsTools
tool_choiceTool Choice
parallel_tool_callsParallel Tool Calls
response_formatResponse Format
reasoning_effortReasoning Effort
audioAny properties in AudioOutputConfig
modalitiesModalities
metadataMetadata
storeStore
service_tierService Tier
safety_identifierSafety Identifier
prompt_cache_keyPrompt Cache Key
userUser

Deprecated; use safety_identifier

model_optionsModel Options

beatra extension; per-model passthrough

[key: string]any

Header Parameters

X-Request-Idstring

Optional client request id echoed in the response.

Authorization
Required
string

Bearer API key.

Idempotency-Keystring

Optional idempotency key for safe retries of mutating requests.

curl -X POST "https://example.com/v1/chat/completions" \
  -H "X-Request-Id: string" \
  -H "Authorization: string" \
  -H "Idempotency-Key: string" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "string",
    "messages": [
      {
        "role": "system",
        "content": "string",
        "name": "string"
      }
    ],
    "temperature": 2,
    "top_p": 1,
    "max_tokens": 0,
    "max_completion_tokens": 0,
    "n": 1,
    "seed": 0,
    "stop": "string",
    "stream": false,
    "stream_options": {
      "include_usage": false
    },
    "frequency_penalty": -2,
    "presence_penalty": -2,
    "logit_bias": {
      "property1": 0,
      "property2": 0
    },
    "logprobs": true,
    "top_logprobs": 20,
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "string",
          "description": "string",
          "parameters": {},
          "strict": true
        }
      }
    ],
    "tool_choice": "string",
    "parallel_tool_calls": true,
    "response_format": {
      "type": "text"
    },
    "reasoning_effort": "minimal",
    "audio": {
      "voice": "string",
      "format": "wav"
    },
    "modalities": [
      "text"
    ],
    "metadata": {
      "property1": "string",
      "property2": "string"
    },
    "store": true,
    "service_tier": "string",
    "safety_identifier": "string",
    "prompt_cache_key": "string",
    "user": "string",
    "model_options": {}
  }'

Sync completion or streaming chat completion chunks

{
  "id": "string",
  "object": "chat.completion",
  "created": 0,
  "model": "string",
  "system_fingerprint": "string",
  "service_tier": "string",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "string",
        "refusal": "string",
        "reasoning_content": "string",
        "tool_calls": [
          {
            "id": "string",
            "type": "function",
            "function": {
              "name": "string",
              "arguments": "string"
            }
          }
        ],
        "audio": {
          "id": "string",
          "data": "string",
          "expires_at": 0,
          "transcript": "string"
        },
        "name": "string"
      },
      "finish_reason": "stop",
      "logprobs": {
        "content": [
          {
            "token": "string",
            "logprob": 0,
            "bytes": [
              0
            ],
            "top_logprobs": [
              {}
            ]
          }
        ],
        "refusal": [
          {
            "token": "string",
            "logprob": 0,
            "bytes": [
              0
            ],
            "top_logprobs": [
              {}
            ]
          }
        ]
      }
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "audio_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0,
      "audio_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    },
    "credits": "string",
    "credits_usd_reference": "string"
  }
}