Core Concepts
The Chat API is the primary interface for conversations, reasoning, and code generation with Cortiqa models like openai/gpt-oss-120b. It supports multi-turn dialogues, system instructions, real-time streaming, and tool calls.
1import cortiqa23client = cortiqa.Client()45response = client.chat.create(6 model="openai/gpt-oss-120b",7 messages=[8 {"role": "user", "content": "What is machine learning?"}9 ],10 temperature=0.711)1213print(response.content)| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID, e.g. openai/gpt-oss-120b or cortiqa/falin-1 |
messages | array | Yes | Array of role/content objects (system, user, assistant) |
max_tokens | integer | No | Maximum tokens to generate (up to 131K context) |
temperature | float | No | Sampling temperature (0.0 to 2.0). Default: 0.7 |
top_p | float | No | Nucleus sampling probability threshold |
stream | boolean | No | Enable SSE token streaming. Default: false |
tools | array | No | List of tool definitions for function calling |
stop | array | No | Custom stop sequences |
{
"id": "chatcmpl-01JHE7N9",
"object": "chat.completion",
"created": 1726982400,
"model": "openai/gpt-oss-120b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Machine learning is a subset of artificial intelligence where algorithms learn patterns from data..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 84,
"total_tokens": 96
}
}Include the historical conversation turns to maintain context:
1response = client.chat.create(2 model="openai/gpt-oss-120b",3 messages=[4 {"role": "user", "content": "What is Python?"},5 {"role": "assistant", "content": "Python is a high-level, readable programming language..."},6 {"role": "user", "content": "What are its 3 biggest advantages for AI development?"}7 ]8)9print(response.content)Provide a system message at index 0 to steer model persona and formatting rules:
response = client.chat.create(
model="openai/gpt-oss-120b",
messages=[
{"role": "system", "content": "You are a senior systems engineer at Cortiqa. Respond strictly in valid JSON."},
{"role": "user", "content": "List 3 Linux diagnostic commands."}
]
)