For the complete documentation index, see llms.txt. This page is also available as Markdown.

Python SDK

Setup

Install the SDK and set your credentials:

pip install openai

All examples read the API key from a .env file:

API_KEY=YOUR_NEXOS_API_KEY

OpenAI SDK clients use the base URL https://api.nexos.ai/v1; the Anthropic SDK appends /v1/messages itself, so it takes the bare https://api.nexos.ai.

Model IDs on nexos.ai are the model names shown in the console (e.g. GPT 5.6 Sol, Claude Sonnet 5, Whisper). List them with GET /v1/models.

Chat Completion

Send a conversation and get the model's next reply — the standard OpenAI-compatible endpoint, supported by most chat models on the platform.

import os

from dotenv import load_dotenv
from openai import OpenAI
from openai.types.chat import ChatCompletionUserMessageParam, ChatCompletion

load_dotenv()
api_key = os.environ["API_KEY"]

openai = OpenAI(
    api_key=api_key,
    base_url="https://api.nexos.ai/v1",
)
message: ChatCompletionUserMessageParam = {
    "role": "user",
    "content": "how many letters 'r' in the word 'strawberry'",
}
response: ChatCompletion = openai.chat.completions.create(model="GPT 5.6 Sol", messages=[message])
print(response.choices[0].message.content)

Messages

The /v1/messages endpoint implements the Anthropic Messages API and works with the official Anthropic SDK (pip install anthropic). It is available for models that list the messages endpoint in GET /v1/models (e.g. Claude models).

Messages with prompt caching

Reuse a large, stable prompt prefix across calls to cut cost (cached tokens are ~10× cheaper) and latency. /v1/messages forwards cache_control byte-for-byte, so Anthropic prompt caching works natively. The cached prefix must exceed the model's minimum cacheable length (~1024 tokens):

Messages streaming

Receive the reply incrementally as server-sent events instead of waiting for the whole message — useful for chat UIs and long outputs.

Messages with thinking

Let the model reason internally before answering — the response starts with a thinking block followed by the final text.

Messages with tool calls

Let the model call functions you define: it responds with a tool_use block, your code runs the tool and sends the result back, and the model produces the final answer.

Responses

OpenAI's newer generation API: send text or structured input items and get the model output back. Responses created with store can be retrieved and managed later.

Responses - compact conversation

Compress a long stored conversation into a smaller context so it can keep going without hitting the model's context limit. Pass the last response's ID via previous_response_id — the API returns a new, compacted response whose ID you use to continue the conversation.

Responses lifecycle

Stored responses (store=true) live on the platform after creation, so you can work with them later: retrieve a response by ID, list the input items it was created from, and delete it when it's no longer needed.

Embedding

Convert text into a numeric vector for semantic search, clustering, and RAG. One vector is returned per input.

Audio Generation

Convert text to spoken audio (text-to-speech).

Audio Transcription

Transcribe an audio file to text in its original language. The example reads sound.mp3 — you can create one with the Audio Generation example above.

Audio Translation

Transcribe an audio file and translate the text into English. The example reads sound.mp3 — you can create one with the Audio Generation example above.

Image Generation

Generate an image from a text prompt.

Last updated