Chat

Create chat completion

Creates a model response from a Chat Completions request. Supported request formats are listed in each model’s details. Unknown fields are accepted on a best-effort basis; model-specific support is not guaranteed.

post/v1/chat/completions

Request

  • Base URL: https://api.tokenlab.sh
  • URL: https://api.tokenlab.sh/v1/chat/completions
  • Auth: HTTP bearer

Headers

X-TokenLab-Delivery-Policy'auto' | 'verified' | 'official'

Per-request Delivery policy. Overrides the API key and Workspace defaults. Auto tries TokenLab Verified first and may switch once to Official only before output, request acceptance, or persistent resource creation.

Request body

modelstring required

ID of the model to use (e.g., gpt-5.4, claude-sonnet-4-6)

temperaturenumber

Sampling temperature (0-2)

top_pnumber

Nucleus sampling probability

ninteger

Number of completions to generate

streamboolean

If true, returns a stream of events

max_tokensinteger

Maximum number of tokens to generate

max_completion_tokensinteger

Maximum completion tokens for newer reasoning-enabled model families

presence_penaltynumber

Presence penalty (-2 to 2)

frequency_penaltynumber

Frequency penalty (-2 to 2)

functionsobject[]

Deprecated function definitions retained by the official Chat Completions contract.

seedinteger

Seed for deterministic generation

userstring

End-user identifier for abuse detection

stream_optionsobject

Streaming options such as usage chunk inclusion.

parallel_tool_callsboolean

Whether the model may issue parallel tool calls.

reasoning_effortstring

Reasoning effort hint for compatible model families.

logprobsboolean

Whether to return log probabilities for output tokens.

top_logprobsinteger

Number of most likely tokens to return at each position when logprobs is enabled.

logit_biasobject

Per-token logit bias map.

modalitiesstring[]

Requested output modalities such as text or audio.

audioobject

Audio output configuration when requesting audio modality.

predictionobject

Prediction hints for models that support draft or speculative decoding.

service_tierstring nullable

TokenLab serves this request at the standard service tier. auto and default are forwarded. Other values, such as flex, priority, fast and ultrafast, are ignored and billed at the standard price.

Example request

{
  "model": "gpt-4o"
}

Response

Successful response

idstring required

Unique identifier for the completion

object'chat.completion' required

Object type

createdinteger required

Unix timestamp of creation

modelstring required

Model used for completion

system_fingerprintstring

System fingerprint

Example response

{
  "id": "chatcmpl-abc123"
}

Changes

No recorded changes to this operation across all 1 revision of this API.