OpenAI SDK (Python / Node)
Call models through /v1/chat/completions with the official OpenAI SDK. Only api_key and base_url change.
AI Nexus is compatible with the OpenAI Chat Completions API (POST /v1/chat/completions), the general OpenAI-compatible endpoint. Existing OpenAI code needs only two changes: api_key and base_url.
Install
pip install openaiBasic call
Replace your-model-id in the samples with a model ID from the model square (or call GET /v1/models).
Put your API key in an environment variable first:
export MYAIEXP_API_KEY="sk-..."import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["MYAIEXP_API_KEY"],
base_url="https://ai.myaiexp.com/v1",
)
resp = client.chat.completions.create(
model="your-model-id", # replace with a model ID from the model square
messages=[{"role": "user", "content": "Introduce yourself in one sentence."}],
)
print(resp.choices[0].message.content)
print("usage:", resp.usage.prompt_tokens, "in /", resp.usage.completion_tokens, "out")Key points:
base_url/baseURLmust include/v1:https://ai.myaiexp.com/v1.- Authentication is
Authorization: Bearer sk-...; the SDK adds it fromapi_key. modelis the model ID and is case-sensitive. Pick a model on the model square that supports/v1/chat/completionsand use its model ID.- Read the key from an environment variable; never hardcode it or commit it to a repository.
List available models
curl -sS https://ai.myaiexp.com/v1/models \
-H "Authorization: Bearer $MYAIEXP_API_KEY"The same with the SDK:
for m in client.models.list():
print(m.id)GET /v1/models returns every model the current key can call. If you set a model restriction when creating the key, only the allowed models are listed.
Endpoint support
Endpoint support varies by model: /v1/chat/completions is the general OpenAI-compatible endpoint; /v1/messages works with models that support the Claude-native format; /v1/responses works with models that support the Responses API. The available models and the endpoints each one supports are listed on the model square. See also Anthropic Messages and the Responses API.
If your code switches between models, Chat Completions is the simplest choice: one code path, only model changes.
See the full model list and prices on the model square. Prices are synced daily from each vendor's official public list price, in USD per 1M tokens. Which models your key can use is determined by GET /v1/models.
Thinking models
Thinking and reasoning models think before they answer. Thinking counts toward output tokens; if max_tokens is too small the response can be cut off mid-thought, leaving content empty. Increase max_tokens or switch to streaming.
Profile and security
View your account details, set balance alerts and the interface language, and manage password, email binding, sign-in sessions and other security options.
Streaming
Add stream=true to receive output as it is generated. Ideal for chat UIs and avoiding timeouts on long answers.
This service is provided for learning and research purposes only. Please follow each model provider's usage policies.