API Integration Guide
Prepare your key, Base URL, and model ID, then connect with OpenAI or Anthropic formats using cURL, Python, or JavaScript.
Prepare Your Connection Details
Sign in, open API keys in the console sidebar, and select the pencil icon beside your default key. Copy the key and the request address for your chosen route. New accounts receive a default key when they sign up.
| Setting | What to use |
|---|---|
| API key | The complete key copied from the key panel. |
| Base URL | The example uses https://nusi.si/v1. For another route, use its address from the panel, including /v1. |
| Model ID | Choose a text model that supports your endpoint in the model catalog and copy its model ID. |
Set these two environment variables in the terminal where you will run the request. Replace YOUR_API_KEY with your key. The OpenAI examples use these variables; the Anthropic section explains its separate address setting.
Choose an example below for an endpoint supported by your model:
| Format | SDK Base URL | Headers and Endpoint |
|---|---|---|
| OpenAI · Chat Completions | https://nusi.si/v1 | Authorization: Bearer YOUR_API_KEYPOST /v1/chat/completions |
| OpenAI · Responses | https://nusi.si/v1 | Authorization: Bearer YOUR_API_KEYPOST /v1/responses |
| Anthropic · Messages | https://nusi.si | x-api-key: YOUR_API_KEYanthropic-version: 2023-06-01POST /v1/messages |
macOS / Linux
export NUSI_API_KEY="YOUR_API_KEY"
export NUSI_BASE_URL="https://nusi.si/v1"Windows PowerShell
$env:NUSI_API_KEY = "YOUR_API_KEY"
$env:NUSI_BASE_URL = "https://nusi.si/v1"How to Fetch Model IDs with the API
Alternatively, run this command in a macOS / Linux terminal to fetch models available to your key with GET /v1/models, then copy the model’s id.
curl "$NUSI_BASE_URL/models" \
-H "Authorization: Bearer $NUSI_API_KEY"Keep your key in local or server environment variables and out of public web pages and source repositories.
Make Your First API Call
Find the endpoint your model supports, then choose one example. Replace YOUR_MODEL_ID with the real model ID and run it in the terminal where you set the environment variables.
OpenAI Chat Completions
POST /v1/chat/completions
cURL · Run Directly in Your Terminal
Paste this into a macOS / Linux terminal and run it:
curl "$NUSI_BASE_URL/chat/completions" \
-H "Authorization: Bearer $NUSI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [{"role": "user", "content": "Reply with: connection successful"}]
}'The full address is your Base URL followed by /chat/completions. For Windows PowerShell, use the Python or JavaScript example below.
Python · OpenAI SDK
With Python 3.9 or later installed, install the SDK in your terminal:
python -m pip install openaiSave this code as first_call.py:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["NUSI_API_KEY"],
base_url=os.environ["NUSI_BASE_URL"],
)
reply = client.chat.completions.create(
model="YOUR_MODEL_ID",
messages=[{"role": "user", "content": "Reply with: connection successful"}],
)
print(reply.choices[0].message.content)Run this in the folder where you saved the file:
python first_call.pyIf your system uses python3 or py, use it for both installation and execution. The SDK appends /chat/completions automatically; keep the Base URL ending at /v1.
JavaScript · OpenAI SDK
With Node.js 20 LTS or a newer supported version installed, install the SDK in your project folder:
npm install openaiSave this code as first_call.mjs:
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.NUSI_API_KEY,
baseURL: process.env.NUSI_BASE_URL,
});
const reply = await client.chat.completions.create({
model: "YOUR_MODEL_ID",
messages: [{ role: "user", content: "Reply with: connection successful" }],
});
console.log(reply.choices[0].message.content);Run this in the same folder:
node first_call.mjsRun this in local Node.js or on your server. The SDK appends the endpoint path automatically; keep the Base URL ending at /v1.
Choosing Model Parameters
Responses uses input; Chat Completions uses messages. Depending on the model and endpoint, output limits use max_output_tokens, max_completion_tokens, or max_tokens. Follow the actual example in the model’s integration panel.
Support for temperature, top_p, reasoning effort, output formats, and tool choice depends on the model. Omit unsupported parameters. Structured output requires its schema, and a tool choice requires matching tool definitions.
Streaming and Tool Calls
Set stream: true on a Chat Completions request to receive SSE chunks. Responses uses its own stream events. Read the stream to completion with the matching SDK and handle errors and interruptions.
For models that support tool calling, declare functions in tools. Your application validates arguments, executes each function, and sends the result back. Chat Completions and Responses use different tool and result formats; use the matching SDK types.
OpenAI Responses
POST /v1/responses
Codex uses the Responses format. For your own app, choose a model that supports Responses and reuse the key and OpenAI Base URL above. Requests use input; SDKs expose the reply as output_text.
cURL
curl "$NUSI_BASE_URL/responses" \
-H "Authorization: Bearer $NUSI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_MODEL_ID","input":"Reply with: connection successful"}'Python · OpenAI SDK
Run python -m pip install openai, save this as first_call.py and run python first_call.py in the same terminal.
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["NUSI_API_KEY"], base_url=os.environ["NUSI_BASE_URL"])
reply = client.responses.create(model="YOUR_MODEL_ID", input="Reply with: connection successful")
print(reply.output_text)JavaScript · OpenAI SDK
Run npm install openai, save this as first_call.mjs and run node first_call.mjs in the same folder.
import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.NUSI_API_KEY, baseURL: process.env.NUSI_BASE_URL });
const reply = await client.responses.create({
model: "YOUR_MODEL_ID",
input: "Reply with: connection successful",
});
console.log(reply.output_text);With stream: true, read Responses stream events. The non-streaming output_text helper and streaming event handling use different access patterns.
Anthropic Messages
POST /v1/messages
Prefer the Anthropic format for Claude models and Claude Code CLI. Choose a Claude model that supports Messages and replace YOUR_MODEL_ID with its model ID.
Reuse NUSI_API_KEY above. The Anthropic SDK uses the site root as its Base URL and appends /v1/messages. Add this variable in the same terminal; for another route, use its Anthropic address from the key panel.
macOS / Linux
export NUSI_ANTHROPIC_BASE_URL="https://nusi.si"Windows PowerShell
$env:NUSI_ANTHROPIC_BASE_URL = "https://nusi.si"cURL
curl "$NUSI_ANTHROPIC_BASE_URL/v1/messages" \
-H "x-api-key: $NUSI_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"max_tokens": 1024,
"messages": [{"role":"user","content":"Reply with: connection successful"}]
}'Python · Anthropic SDK
python -m pip install anthropicSave this as first_call.py and run python first_call.py. If your system uses python3 or py, use it for both installation and execution.
import os
from anthropic import Anthropic
client = Anthropic(
api_key=os.environ["NUSI_API_KEY"],
base_url=os.environ["NUSI_ANTHROPIC_BASE_URL"],
default_headers={"anthropic-version": "2023-06-01"},
)
reply = client.messages.create(
model="YOUR_MODEL_ID",
max_tokens=1024,
messages=[{"role": "user", "content": "Reply with: connection successful"}],
)
for block in reply.content:
if block.type == "text":
print(block.text)JavaScript · Anthropic SDK
npm install @anthropic-ai/sdkSave this as first_call.mjs and run node first_call.mjs.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.NUSI_API_KEY,
baseURL: process.env.NUSI_ANTHROPIC_BASE_URL,
defaultHeaders: { "anthropic-version": "2023-06-01" },
});
const reply = await client.messages.create({
model: "YOUR_MODEL_ID",
max_tokens: 1024,
messages: [{ role: "user", content: "Reply with: connection successful" }],
});
for (const block of reply.content) {
if (block.type === "text") console.log(block.text);
}Messages Parameters and Output Budget
The example’s max_tokens: 1024 is an explicit output budget for this request, not a model default or maximum capacity. Set max_tokens explicitly on Messages requests and keep it within the model’s output limit and thinking-budget requirements.
Thinking mode and output_config.effort depend on your model. Adaptive thinking and explicit budgets use different structures. Omit temperature or top_p when unsupported, and provide the required schema for structured output.
Streaming and Tool Calls
Set stream: true on a Messages request to receive SSE message and content-block events. Use the Anthropic SDK to process them and handle errors or incomplete streams.
Define tool names and input_schema in tools. After receiving a tool_use block, your app validates and executes the call, then returns a tool_result.
Prompt Caching
For Claude models that support caching, set cache_control on compatible system or messages content blocks:
{
"type": "text",
"text": "Long, reusable context",
"cache_control": {"type": "ephemeral"}
}Caching generally requires a model-specific minimum length and an identical reusable prefix. Support depends on the model and upstream response. Check writes and reads in usage.cache_creation_input_tokens and usage.cache_read_input_tokens.
Image Generation
Image models use POST /v1/images/generations. Replace YOUR_IMAGE_MODEL_ID with the full ID of a model supporting image generation and run this in a macOS / Linux terminal:
curl "$NUSI_BASE_URL/images/generations" \
-H "Authorization: Bearer $NUSI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_IMAGE_MODEL_ID","prompt":"A cat in sunlight"}'Use size, quality, count, and output format values supported by the current model. Example selections do not establish model defaults. Confirm that the response contains readable image data and check the call in usage records; image responses are not always URLs. For image editing, confirm the endpoint is supported by both the model and the platform.
For detailed parameters and a complete example, see the GPT Image 2 integration guide. For other image models, open their integration panel in the model catalog.
Check That the Call Succeeded
Python and JavaScript print the reply below in your terminal. For cURL, find it in the JSON response. Capitalization or punctuation may vary slightly.
connection successfulOnce you see the model reply, replace the example message with your own task and integrate it into your app or workflow. If the request fails, read the error message first and use the checks below.
| Problem | What to do next |
|---|---|
| 401 | Check that the key is complete and NUSI_API_KEY is set in this terminal. |
| 403 | Follow the error message to check account access, key permissions, or spending limits. If it reports insufficient balance, add funds to the billed team. |
| 400 / 404 | Check the Base URL, model ID, and endpoint support. Confirm the model supports the selected endpoint. |
| 429 | Read the error reason. For a rate limit, wait for Retry-After when provided. If concurrency is full, wait for running tasks to finish before retrying. |
| Timeout or 5xx | Check the request status in usage records before deciding whether to retry, to avoid duplicate submissions. |