Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Create chat completion

Generate a chat completion for the given messages, following the OpenAI Chat Completions API wire format.

Set stream: true to receive a Server-Sent Events stream. Each event carries a chat.completion.chunk object. When stream_options.include_usage is true, the final chunk before [DONE] includes a usage field with token counts.

post
Authorizations
AuthorizationstringRequired

Please provide header value as 'Bearer ' and don't forget to add 'Bearer' HTTP Authorization Scheme before the token.

Body

Request body for POST /v1/chat/completions (OpenAI Chat Completions API).

modelstringRequired

ID of the model to use.

Example: openai/gpt-oss-120b
response_formatone ofOptional

The format the model must output. Which formats a model supports is model-specific.

or
or
temperaturenumber · max: 2Optional

Sampling temperature between 0 and 2.

top_pnumber · max: 1Optional

Nucleus sampling probability mass, greater than 0 and at most 1. A value outside that range, including exactly 0, is rejected with a 400.

ninteger · min: 1Optional

Number of chat completion choices to generate. When omitted, the model chooses.

streambooleanOptional

If true, stream partial results as Server-Sent Events.

Default: false
stopone ofOptional

Up to 4 sequences at which generation stops.

stringOptional
or
string[] · max: 4Optional
max_tokensinteger · min: 1Optional

Maximum number of tokens to generate. For a reasoning model, the reasoning counts toward this limit and comes before the answer. If the limit is reached while the model is still reasoning, the response has finish_reason length, an empty content, and the reasoning so far in reasoning. A lower reasoning_effort leaves more of the limit for the answer.

max_completion_tokensintegerOptional

Maximum number of tokens to generate, including any reasoning, as for max_tokens. OpenAI's replacement for the deprecated max_tokens. Avoid setting both in one request: which of the two applies is model-specific. The accepted range is model-specific.

presence_penaltynumber · min: -2 · max: 2Optional

Penalize tokens that have appeared so far in the text.

frequency_penaltynumber · min: -2 · max: 2Optional

Penalize tokens based on their frequency in the text.

logprobsbooleanOptional

Whether to return log probabilities of the output tokens.

top_logprobsinteger · max: 20Optional

Number of most-likely tokens to return at each position, when logprobs is true.

userstringOptional

Opaque identifier for your end user.

reasoning_effortstringOptional

How much reasoning to do before answering, for reasoning-capable models. Accepted values are model-specific. A value the model does not accept is rejected with a 400.

Example: high
tool_choiceone ofOptional

Controls which tool, if any, the model calls. none means no tool call, auto lets the model decide, and required forces a tool call. A named tool object forces a specific function.

Which values a model honors is model-specific. A model may answer with a normal message instead of the tool call that required or a named function asks for. The value is not checked, so how any other value is answered is also model-specific.

string · enumOptionalPossible values:
or
seedintegerOptional

Seed for deterministic sampling. Repeated requests with the same seed and parameters return the same completion on a best-effort basis. Support is model-specific.

parallel_tool_callsbooleanOptional

Whether the model may emit more than one tool call in a single turn. Whether it is honored is model-specific.

Responses
200

Successful operation. Returns ChatCompletionResponse for non-streaming requests, or a text/event-stream of chat.completion.chunk objects when stream: true.

post/v1/chat/completions
POST /v1/chat/completions HTTP/1.1
Host: openai.inference.de-txl.ionos.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 127

{
  "model": "openai/gpt-oss-120b",
  "messages": [
    {
      "role": "user",
      "content": "Hello, how are you?"
    }
  ],
  "max_tokens": 256,
  "temperature": 0.7
}
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "openai/gpt-oss-120b",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I'm doing well, thank you!"
      },
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "usage": {
    "prompt_tokens": 13,
    "completion_tokens": 9,
    "total_tokens": 22
  }
}

Last updated

Was this helpful?