Chat Completions
POST /v1/chat/completions
This operation can change data. Use resources you control.
This operation can spend credits. Save the request or run identifier before retrying.
For streaming, see the completions stream guide.
Request fields
| Field | Location | Type | Required |
|---|---|---|---|
authorization | header | string | null | Optional |
allowed_tools | body | List of string | null | Optional |
api_key_id | body | string | null | Optional |
api_key_name | body | string | null | Optional |
attached_document_ids | body | List of string | null | Optional |
context_tool_profile | body | string | null | Optional |
max_tokens | body | integer | null | Optional |
max_tool_rounds | body | integer | null | Optional |
messages | body | List of ChatCompletionMessage | Required |
model | body | string | Required |
queue_request_id | body | string | null | Optional |
session_id | body | string | null | Optional |
stream | body | boolean | Optional |
temperature | body | number | null | Optional |
Examples
Use the environment settings from Quickstart. Replace sample resource IDs with your own. The examples show the required request shape.
import { MaxClient } from "@elmax/api";
const max = new MaxClient({
baseURL: process.env.MAX_API_URL,
apiKey: process.env.MAX_API_KEY,
});
const result = await max.api.postV1ChatCompletions({
"body": {
"model": "agt_example",
"messages": [
{
"role": "user",
"content": "How do I reset my password?"
}
]
}
});
console.log(result);import os
from elmax_ai import MaxClient
with MaxClient(base_url=os.environ["MAX_API_URL"], api_key=os.environ["MAX_API_KEY"]) as max:
result = max.api.post_v1_chat_completions(**{'body': {'model': 'agt_example',
'messages': [{'role': 'user',
'content': 'How do I reset my password?'}]}})
print(result)Response type JSON value