> For the complete documentation index, see [llms.txt](https://docs.ionos.com/cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ionos.com/cloud/api-reference/ai/ai-model-hub/open-ai-compatible-endpoints/create-chat-completions.md).

# Create Chat Completions

Create Chat Completions by calling an available model in a format that is compatible with the OpenAI API. Supports both text-only and multimodal (text + images) inputs for compatible models. Rate limits apply per contract. Default limits apply unless a custom rate limit is configured for your contract. Exceeding the limit returns HTTP 429 with a Retry-After header.

```json
{"openapi":"3.0.3","info":{"title":"IONOS CLOUD - OpenAI compatible AI Model Hub API","version":"1.0.0"},"tags":[{"name":"OpenAI Compatible Endpoints","description":"Endpoints compatible with OpenAI's API specification"}],"servers":[{"url":"https://openai.inference.de-txl.ionos.com","description":"Berlin"}],"security":[{"tokenAuth":[]}],"components":{"securitySchemes":{"tokenAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Please provide header value as 'Bearer <token>' and don't forget to add 'Bearer' HTTP Authorization Scheme before the token."}},"schemas":{"ChatCompletionRequest":{"type":"object","properties":{"model":{"type":"string","description":"ID of the model to use"},"messages":{"type":"array","items":{"$ref":"#/components/schemas/ChatCompletionMessage"}},"response_format":{"description":"An object specifying the format that the model must output. Use json_object for JSON mode or json_schema to enforce a specific schema (Structured Outputs). If omitted, default text output is used.\n","oneOf":[{"$ref":"#/components/schemas/ResponseFormatJSONSchema"},{"$ref":"#/components/schemas/ResponseFormatJSONObject"},{"$ref":"#/components/schemas/ResponseFormatText"}]},"temperature":{"type":"number","description":"The sampling temperature to be used","default":1},"top_p":{"type":"number","description":"An alternative to sampling with temperature","default":-1},"n":{"type":"integer","description":"The number of chat completion choices to generate for each input message","default":1},"stream":{"default":false,"type":"boolean","description":"If set to true, it sends partial message deltas"},"stop":{"type":"array","items":{"type":"string"},"description":"Up to 4 sequences where the API will stop generating further tokens"},"max_tokens":{"type":"integer","description":"The maximum number of tokens to generate in the chat. This value is now deprecated in favor of max_completion_tokens completion","default":16,"deprecated":true},"max_completion_tokens":{"type":"integer","description":"An upper bound for the number of tokens that can be generated for a completion, including visible output tokens","default":16},"presence_penalty":{"type":"number","description":"It is used to penalize new tokens based on their existence in the text so far","default":0},"frequency_penalty":{"type":"number","description":"It is used to penalize new tokens based on their frequency in the text so far","default":0},"logit_bias":{"type":"object","description":"Used to modify the probability of specific tokens appearing in the completion"},"logprobs":{"type":"boolean","description":"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.","default":false},"top_logprobs":{"type":"integer","description":"An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.","minimum":0,"maximum":20},"user":{"type":"string","description":"A unique identifier representing your end-user"},"reasoning_effort":{"type":"string","enum":["low","medium","high"],"default":"medium","description":"OpenAI-compatible field that controls the model's reasoning token\nbudget. Supported values are `low`, `medium`, and `high`.\n"},"tools":{"type":"array","description":"A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.\n","items":{"$ref":"#/components/schemas/chatCompletionTool"}},"tool_choice":{"$ref":"#/components/schemas/chatCompletionToolChoiceOption"},"stream_options":{"type":"object","description":"Options for streaming responses","properties":{"include_usage":{"type":"boolean","description":"Whether to include usage information in streamed responses","default":true}}}},"required":["model","messages"]},"ChatCompletionMessage":{"type":"object","description":"A message in a chat completion request, supporting both text-only and multimodal content","properties":{"role":{"type":"string","description":"The role of the message's author","enum":["system","user","assistant","tool"]},"content":{"oneOf":[{"type":"string","description":"Text content of the message (legacy format)"},{"type":"array","description":"Array of content parts for multimodal messages","items":{"$ref":"#/components/schemas/ChatCompletionContentPart"}}]},"name":{"type":"string","description":"The name of the author of the message"},"tool_calls":{"type":"array","description":"Tool calls generated by the model","items":{"$ref":"#/components/schemas/chatCompletionMessageToolCall"}},"tool_call_id":{"type":"string","description":"Tool call that this message is responding to"}},"required":["role","content"]},"ChatCompletionContentPart":{"oneOf":[{"$ref":"#/components/schemas/ChatCompletionContentPartText"},{"$ref":"#/components/schemas/ChatCompletionContentPartImage"}],"discriminator":{"propertyName":"type","mapping":{"text":"#/components/schemas/ChatCompletionContentPartText","image_url":"#/components/schemas/ChatCompletionContentPartImage"}}},"ChatCompletionContentPartText":{"type":"object","description":"Text content part","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part"},"text":{"type":"string","description":"The text content"}},"required":["type","text"]},"ChatCompletionContentPartImage":{"type":"object","description":"Image content part","properties":{"type":{"type":"string","enum":["image_url"],"description":"The type of the content part"},"image_url":{"$ref":"#/components/schemas/ChatCompletionContentPartImageImageUrl"}},"required":["type","image_url"]},"ChatCompletionContentPartImageImageUrl":{"type":"object","description":"Image URL or data","properties":{"url":{"type":"string","description":"Either a URL of the image or the base64 encoded image data.\nSupported formats:\n- URLs: https://example.com/image.jpg\n- Base64 data URLs: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...\n"},"detail":{"type":"string","description":"Specifies the detail level of the image. \n- \"low\" uses fewer tokens and is faster\n- \"high\" is more detailed but uses more tokens\n- \"auto\" lets the model choose\n","enum":["low","high","auto"],"default":"auto"}},"required":["url"]},"chatCompletionMessageToolCall":{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"$ref":"#/components/schemas/toolCallType"},"function":{"type":"object","description":"The function that the model called.","properties":{"name":{"type":"string","description":"The name of the function to call."},"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."}},"required":["name","arguments"]}},"required":["id","type","function"]},"toolCallType":{"type":"string","enum":["function"],"description":"The type of the tool call, in this case `function`."},"ResponseFormatJSONSchema":{"type":"object","description":"Enable Structured Outputs; model must produce JSON adhering to supplied schema.","properties":{"type":{"type":"string","enum":["json_schema"]},"json_schema":{"type":"object","properties":{"name":{"type":"string","description":"Identifier for the schema definition."},"schema":{"type":"object","description":"Root JSON Schema object (must be object with additionalProperties=false)."},"strict":{"type":"boolean","description":"If true, instruct model to strictly follow schema.","default":true}},"required":["name","schema"],"additionalProperties":false}},"required":["type","json_schema"],"additionalProperties":false},"ResponseFormatJSONObject":{"type":"object","description":"Enable JSON mode; model outputs a single valid JSON object (no schema enforcement).","properties":{"type":{"type":"string","enum":["json_object"]}},"required":["type"],"additionalProperties":false},"ResponseFormatText":{"type":"object","description":"Request normal free-form text output (default behavior).","properties":{"type":{"type":"string","enum":["text"]}},"required":["type"],"additionalProperties":false},"chatCompletionTool":{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only `function` is supported."},"function":{"$ref":"#/components/schemas/FunctionObject"}},"required":["type","function"]},"FunctionObject":{"type":"object","properties":{"description":{"type":"string","description":"A description of what the function does, used by the model to choose when and how to call the function."},"name":{"type":"string","description":"The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"parameters":{"$ref":"#/components/schemas/FunctionParameters"}},"required":["name"]},"FunctionParameters":{"type":"object","description":"The parameters the functions accepts, described as a JSON Schema object.","additionalProperties":true},"chatCompletionToolChoiceOption":{"description":"Controls which (if any) tool is called by the model.\n`none` means the model will not call any tool and instead generates a message.\n`auto` means the model can pick between generating a message or calling one or more tools.\n`required` means the model must call one or more tools.\nSpecifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool.\n`none` is the default when no tools are present. `auto` is the default if tools are present.\n","oneOf":[{"type":"string","description":"`none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools.\n","enum":["none","auto","required"]},{"$ref":"#/components/schemas/chatCompletionNamedToolChoice"}]},"chatCompletionNamedToolChoice":{"type":"object","description":"Specifies a tool the model should use. Use to force the model to call a specific function.","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only `function` is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."}},"required":["name"]}},"required":["type","function"]},"SuccessfulChatCompletionResponse":{"type":"object","properties":{"id":{"type":"string"},"choices":{"type":"array","items":{"type":"object","properties":{"finish_reason":{"type":"string"},"index":{"type":"integer"},"message":{"type":"object","properties":{"role":{"type":"string"},"content":{"type":"string"},"tool_calls":{"type":"array","items":{"$ref":"#/components/schemas/chatCompletionMessageToolCall"},"readOnly":true},"refusal":{"type":"string","description":"Present when the model refuses to answer for safety/policy reasons."}}},"logprobs":{"type":"object","nullable":true,"description":"Log probability information for the choice.","properties":{"content":{"type":"array","nullable":true,"description":"A list of message content tokens with log probability information.","items":{"type":"object","properties":{"token":{"type":"string","description":"The token."},"logprob":{"type":"number","description":"The log probability of this token."},"bytes":{"type":"array","nullable":true,"description":"A list of integers representing the UTF-8 bytes representation of the token.","items":{"type":"integer"}},"top_logprobs":{"type":"array","description":"List of the most likely tokens and their log probability, at this token position.","items":{"type":"object","properties":{"token":{"type":"string"},"logprob":{"type":"number"},"bytes":{"type":"array","nullable":true,"items":{"type":"integer"}}}}}}}}}}}}},"created":{"type":"integer"},"object":{"type":"string"},"model":{"type":"string"},"system_fingerprint":{"type":"string"},"usage":{"type":"object","properties":{"prompt_tokens":{"type":"integer"},"completion_tokens":{"type":"integer"},"total_tokens":{"type":"integer"},"completion_tokens_details":{"type":"object","properties":{"reasoning_tokens":{"type":"integer"}}}}}}},"ErrorResponse":{"type":"object","description":"OpenAI-compatible error response. Returned for error responses that define this schema (for example, 429 Too Many Requests). Note: the backend currently returns an IONOS-native error body format; alignment to this schema is tracked in GPHML-2078.\n","properties":{"error":{"type":"object","properties":{"message":{"type":"string","description":"Human-readable error description."},"type":{"type":"string","description":"Error category (e.g. \"requests\", \"invalid_request_error\")."},"code":{"type":"string","nullable":true,"description":"Machine-readable error code (e.g. \"rate_limit_exceeded\"). May be null or omitted."},"param":{"type":"string","nullable":true,"description":"Parameter related to the error, if applicable. May be null or omitted."}},"required":["message","type"]}},"required":["error"]}},"headers":{"X-RateLimit-Limit":{"description":"Sustained request rate limit expressed as requests per minute. Enforcement is per second — see X-RateLimit-Burst for the short-window limit. The actual value depends on your contract; the default is 300 req/min (5 req/s).\n","schema":{"type":"integer"}},"X-RateLimit-Burst":{"description":"Maximum number of requests allowed within a 2-second burst window. Exceeding this triggers a 429 response. The actual value depends on your contract; the default is 10 requests per burst window.\n","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Requests remaining in the current 2-second burst window. Resets when the burst window expires. Does not reflect the per-minute X-RateLimit-Limit.\n","schema":{"type":"integer"}}},"responses":{"TooManyRequests":{"description":"Rate limit exceeded. Retry after the number of seconds indicated by the Retry-After header. Limits are contract-specific; check X-RateLimit-Limit and X-RateLimit-Burst in the response headers for the values that apply to your contract.\n","headers":{"Retry-After":{"description":"Number of seconds to wait before retrying.","schema":{"type":"integer"}},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Burst":{"$ref":"#/components/headers/X-RateLimit-Burst"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Overloaded":{"description":"The platform is temporarily overloaded and is shedding load to stay stable. Retry after the number of seconds indicated by the Retry-After header. This is unrelated to your contract's rate limits.\n","headers":{"Retry-After":{"description":"Number of seconds to wait before retrying.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/v1/chat/completions":{"post":{"operationId":"openaiCompatChatCompletionsPost","summary":"Create Chat Completions","description":"Create Chat Completions by calling an available model in a format that is compatible with the OpenAI API.\nSupports both text-only and multimodal (text + images) inputs for compatible models.\nRate limits apply per contract. Default limits apply unless a custom rate limit is configured for your contract.\nExceeding the limit returns HTTP 429 with a Retry-After header.\n","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionRequest"}}}},"responses":{"200":{"description":"Successful operation","headers":{"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Burst":{"$ref":"#/components/headers/X-RateLimit-Burst"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessfulChatCompletionResponse"}}}},"400":{"description":"Bad request"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"description":"Server error"},"529":{"$ref":"#/components/responses/Overloaded"}},"tags":["OpenAI Compatible Endpoints"]}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.ionos.com/cloud/api-reference/ai/ai-model-hub/open-ai-compatible-endpoints/create-chat-completions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
