max developers SDK 0.4.0
API reference

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

FieldLocationTypeRequired
authorizationheaderstring | nullOptional
allowed_toolsbodyList of string | nullOptional
api_key_idbodystring | nullOptional
api_key_namebodystring | nullOptional
attached_document_idsbodyList of string | nullOptional
context_tool_profilebodystring | nullOptional
max_tokensbodyinteger | nullOptional
max_tool_roundsbodyinteger | nullOptional
messagesbodyList of ChatCompletionMessageRequired
modelbodystringRequired
queue_request_idbodystring | nullOptional
session_idbodystring | nullOptional
streambodybooleanOptional
temperaturebodynumber | nullOptional

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

Errors and recovery