SimpleLLMDocs
HTTP API
Markdown ↗

Create a chat completion

POST /v1/chat/completions

Model-specific vision and tool support. stream=true returns SSE; usage-only events may have empty choices. Client cancellation closes the upstream connection. Cancelled streams with zero recorded output tokens are not charged; partial usage after output may be estimated and billed. No automatic retry after response starts.

Base URL: https://api.simplellm.eu. Authenticate using Authorization: Bearer $SIMPLELLM_API_KEY.

Request body

Content-Type: application/json

FieldTypeRequiredMeaning
modelstringYesExact chat model ID from GET /v1/models.
messagesarray<Message>YesMinimum items: 1.
messages[].rolestringYesValues: system, developer, user, assistant, tool.
messages[].contentstring / null / array<ContentPart>No
messages[].content[].typestringYes
messages[].content[].textstringNo
messages[].content[].image_urlobjectNo
messages[].content[].image_url.urlstringYes
messages[].content[].image_url.detailstringNoValues: auto, low, high.
messages[].namestringNo
messages[].tool_call_idstringNo
messages[].tool_callsarray<ToolCall>No
messages[].tool_calls[].idstringYes
messages[].tool_calls[].type"function"Yes
messages[].tool_calls[].functionobjectYes
messages[].tool_calls[].function.namestringYes
messages[].tool_calls[].function.argumentsstringYesJSON-encoded arguments; parse and validate before executing.
messages[].reasoning_contentstring / nullNoOptional provider-specific reasoning; not guaranteed.
messages[].reasoningstring / nullNoAlternative provider-specific reasoning field; not guaranteed.
streambooleanNoDefault: false.
max_tokensintegerNoOutput budget; reasoning can consume this budget. Minimum: 1.
temperaturenumberNo
top_pnumberNo
stream_optionsobjectNo
stream_options.include_usagebooleanNo
stoparray<string>NoV1 accepts an array of strings, not a plain string.
nintegerNoForwarded; multiple choices are model-dependent.
presence_penaltynumberNoModel-dependent sampling parameter.
frequency_penaltynumberNoModel-dependent sampling parameter.
toolsarray<Tool>No
tools[].type"function"Yes
tools[].functionobjectYes
tools[].function.namestringYes
tools[].function.descriptionstringNo
tools[].function.parametersobjectNo
tools[].function.strictbooleanNoOnly where the selected model/backend supports strict schemas.
tool_choicestring / objectNo
response_formatobjectNoForwarded, model-dependent output-format request; no universal JSON schema guarantee.

Nested required fields are required only when their containing object is supplied. Extra chat parameters may be provider-specific; acceptance does not guarantee model support.

Example request

bash
curl --fail-with-body https://api.simplellm.eu/v1/chat/completions \
  -H "Authorization: Bearer $SIMPLELLM_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "qwen3.8-flash-next",
  "messages": [
    {
      "role": "user",
      "content": "Explain what an API is in one sentence."
    }
  ],
  "max_tokens": 1024
}'

Responses

HTTP 200

JSON response or incremental SSE stream ending with data: [DONE].

Content-Type: application/json

FieldTypeRequiredMeaning
idstringNo
objectstringNo
createdintegerNo
modelstringNo
choicesarray<object>No
choices[].indexintegerNo
choices[].messageMessageNo
choices[].message.rolestringYesValues: system, developer, user, assistant, tool.
choices[].message.contentstring / null / array<ContentPart>No
choices[].message.content[].typestringYes
choices[].message.content[].textstringNo
choices[].message.content[].image_urlobjectNo
choices[].message.content[].image_url.urlstringYes
choices[].message.content[].image_url.detailstringNoValues: auto, low, high.
choices[].message.namestringNo
choices[].message.tool_call_idstringNo
choices[].message.tool_callsarray<ToolCall>No
choices[].message.tool_calls[].idstringYes
choices[].message.tool_calls[].type"function"Yes
choices[].message.tool_calls[].functionobjectYes
choices[].message.tool_calls[].function.namestringYes
choices[].message.tool_calls[].function.argumentsstringYesJSON-encoded arguments; parse and validate before executing.
choices[].message.reasoning_contentstring / nullNoOptional provider-specific reasoning; not guaranteed.
choices[].message.reasoningstring / nullNoAlternative provider-specific reasoning field; not guaranteed.
choices[].finish_reasonstring / nullNo
usageUsageNo
usage.prompt_tokensintegerNo
usage.completion_tokensintegerNo
usage.total_tokensintegerNo
usage.prompt_tokens_detailsobjectNo
usage.prompt_tokens_details.cached_tokensintegerNoSubset of prompt_tokens, not additional input.

Illustrative response shape only; IDs, timestamps and counters below are synthetic, not live limits or customer data.

json
{
  "id": "chatcmpl-example",
  "object": "chat.completion",
  "created": 1789380000,
  "model": "qwen3.8-flash-next",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "An API lets software communicate."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 10,
    "total_tokens": 30,
    "prompt_tokens_details": {
      "cached_tokens": 0
    }
  }
}

Content-Type: text/event-stream

Response type: string.

text
data: {"choices":[{"delta":{"content":"Hello"}}]}

data: [DONE]

Error handling

Errors can occur in authentication, billing, routing or the upstream service; not every status applies to every route.

StatusMeaning
400Invalid request
401Invalid credentials
402Insufficient credits
403Access denied
404Model or resource not found
429Rate or capacity limit
500Internal error
502Routing or upstream error
503Temporarily unavailable
504Deployment timeout

See Troubleshooting for response examples and Rate limits & retries for retry rules.

Machine-readable schema

Download OpenAPI JSON. Operation ID: createChatCompletion.

Search the complete documentation.