Create chat completion

POST /v1/chat/completions

Creates a model response for the given chat conversation. OpenAI Chat Completions compatible.

When stream is false (the default), the response is a single JSON chat.completion object (application/json).

When stream is true, the response is a text/event-stream of server-sent events. Each event’s data: field carries one chat.completion.chunk JSON object. The stream is terminated by a final data: [DONE] sentinel, which is a literal marker and not valid JSON.

Unsupported or unknown request fields are passed through to the upstream inference endpoint unchanged (they are not rejected by the gateway).

The gateway is a drop-in replacement for OpenAI’s Chat Completions API: point any OpenAI SDK at the gateway’s base URL and use your Springboards API key.

Request body

Content type: application/json

FieldTypeRequiredDescription
modelstringYesID of the model to use (alias or dated version).
messagesarray of objectYesThe conversation so far, as a list of messages.
chat_template_kwargsobjectNoSpringboards extension: key/value pairs forwarded to the upstream model’s chat template. See x-springboards-chat-template-kwargs.
frequency_penaltynumberNoPenalty between -2 and 2 for tokens based on their frequency so far.
max_completion_tokensintegerNoUpper bound on the number of tokens generated for the completion.
max_tokensintegerNoDeprecated. Maximum number of tokens to generate. Superseded by max_completion_tokens.
nintegerNoNumber of completions to generate for each prompt.
presence_penaltynumberNoPenalty between -2 and 2 for tokens based on whether they appear so far.
seedintegerNoBest-effort deterministic sampling seed.
stoparray of stringNoUp to 4 sequences where the API stops generating further tokens.
streambooleanNoIf true, partial deltas are streamed as server-sent events terminated by a [DONE] sentinel.
temperaturenumberNoSampling temperature between 0 and 2.
top_pnumberNoNucleus sampling probability mass.
userstringNoStable identifier for the end user, for abuse monitoring.

messages[]

FieldTypeRequiredDescription
rolestring (system, user, assistant, tool)YesThe role of the message author.
contentstringYesThe contents of the message.
namestringNoOptional name to disambiguate participants with the same role.

Fields not listed above are accepted and passed through to the upstream model unchanged.

Responses

200

A chat completion. Returned as a single JSON object, or as an SSE stream when stream=true.

Content type: application/json

FieldTypeRequiredDescription
idstringYesUnique identifier for the completion.
objectstringYesThe object type, always “chat.completion”.
createdintegerYesUnix timestamp (seconds) of when the completion was created.
modelstringYesThe model used for the completion.
choicesarray of objectYesThe list of completion choices.
usageobjectNoToken usage statistics for the request.

choices[]

FieldTypeRequiredDescription
indexintegerYesThe index of this choice in the list.
messageobjectYesThe generated message.
finish_reasonstring (stop, length, content_filter, tool_calls)YesWhy generation stopped.

choices[].message

FieldTypeRequiredDescription
rolestringYesThe role of the author, always “assistant”.
contentstringYesThe contents of the message.

usage

FieldTypeRequiredDescription
prompt_tokensintegerYesTokens in the prompt.
completion_tokensintegerYesTokens in the generated completion.
total_tokensintegerYesTotal tokens used (prompt + completion).

Streaming (text/event-stream)

Each server-sent event is a bare data: line carrying one JSON payload. The stream is terminated by a final data: [DONE] sentinel — a literal marker, not JSON:

data: {"id":"chatcmpl-123","object":"chat.completion.chunk",...}

data: {"id":"chatcmpl-123","object":"chat.completion.chunk",...}

data: [DONE]

Event payload:

FieldTypeRequiredDescription
idstringYesUnique identifier for the completion; shared across all chunks.
objectstringYesThe object type, always “chat.completion.chunk”.
createdintegerYesUnix timestamp (seconds) of when the completion was created.
modelstringYesThe model used for the completion.
choicesarray of objectYesThe list of streamed choice deltas.

choices[]

FieldTypeRequiredDescription
indexintegerYesThe index of this choice in the list.
deltaobjectYesThe incremental message content for this chunk.
finish_reasonstring (stop, length, content_filter, tool_calls)YesWhy generation stopped, or null while streaming.

choices[].delta

FieldTypeRequiredDescription
contentstringNoThe token(s) appended by this chunk.
rolestringNoPresent on the first chunk of a choice.

400

The request body was malformed or missing the required model field.

404

The requested model does not exist.

502

The upstream inference endpoint could not be reached.

Examples

Basic request

curl https://api.example.com/v1/chat/completions \
  -H "Authorization: Bearer $SPRINGBOARDS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "flint-alpha",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Streaming

curl -N https://api.example.com/v1/chat/completions \
  -H "Authorization: Bearer $SPRINGBOARDS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "flint-alpha",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": true
  }'

OpenAI Python SDK

from openai import OpenAI

client = OpenAI(
    base_url="https://api.example.com/v1",
    api_key=os.environ["SPRINGBOARDS_API_KEY"],
)
completion = client.chat.completions.create(
    model="flint-alpha",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(completion.choices[0].message.content)

Notes

chat_template_kwargs is a Springboards (non-OpenAI) extension. Its key/value pairs are forwarded verbatim to the upstream model’s chat template, allowing per-request template variables that OpenAI’s schema has no field for.