Create a chat completion
Create a chat completion
chat.completions.create(CompletionCreateParams**kwargs) -> ChatCompletion
POST/api/v1/chat/completions
OpenAI-compatible Chat Completions. Supports streaming, function tools, structured output, and image and file input.
Parameters
max_completion_tokens: Optional[int]
Output token limit, reasoning included. Do not send together with max_tokens.
minimum1
maximum2147483647
metadata: Optional[Dict[str, str]]
Up to 16 string pairs (keys up to 64 characters). Kept with a stored completion; never sent to the model provider.
safety_identifier: Optional[str]
Accepted for OpenAI compatibility; not sent to the model provider.
maxLength64
Create a chat completion
import os
from adaption import Adaption
client = Adaption(
api_key=os.environ.get("ADAPTION_API_KEY"), # This is the default and can be omitted
)
for completion in client.chat.completions.create(
model="glm-5.2",
messages=[{
"role": "system",
"content": "string",
}],
):
print(completion){
"id": "id",
"object": "chat.completion",
"created": 0,
"model": "model",
"system_fingerprint": "system_fingerprint",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "content",
"refusal": "refusal",
"reasoning_content": "reasoning_content",
"tool_calls": [
{
"id": "id",
"type": "function",
"function": {
"name": "name",
"arguments": "arguments"
}
}
]
}
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
}
}Returns Examples
{
"id": "id",
"object": "chat.completion",
"created": 0,
"model": "model",
"system_fingerprint": "system_fingerprint",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "content",
"refusal": "refusal",
"reasoning_content": "reasoning_content",
"tool_calls": [
{
"id": "id",
"type": "function",
"function": {
"name": "name",
"arguments": "arguments"
}
}
]
}
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
}
}