Getting Started
What you need
- A computer with Windows, macOS or Linux and an internet connection.
- Node.js 18 or later. If you do not have it, step 3 installs it.
- A Nulu AI account with balance: the same account as on this platform.
Step-by-step installation
Copy each command, paste it into the terminal and press Enter.
1. Open the terminal
The terminal is the window where commands are typed. Windows: press the Windows key, type PowerShell and press Enter. macOS: press Cmd + Space, type Terminal and press Enter. Linux: press Ctrl + Alt + T.
2. Check whether you already have Node.js
Paste this command and press Enter:
node --versionIf it answers v18 or a higher number (for example v22.11.0), jump to step 4. If it answers with an error or a lower number, continue with step 3.
3. Install Node.js
Node.js comes with npm, the program that installs Nulu Code. Use the command for your system; when it finishes, close the terminal and open it again. If you prefer an installer with windows, download the LTS version from nodejs.org.
Windows (PowerShell)winget install OpenJS.NodeJS.LTSmacOS and Linux (terminal)curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash # close the terminal, open it again and paste: nvm install --ltsCheck: both must answer with a numbernode --version npm --version4. Install Nulu Code
Paste the first line; it takes about a minute. The second one checks that it is installed: it must answer with a version number.
npm install -g nulu-code nulu --versionLines that start with “npm warn” or “npm notice” are notices, not errors. If the second line answers with a version number, the installation worked and you can continue.
5. Have your Nulu AI account ready
It is the same account as on this platform. If you do not have one, sign up, confirm your email and add balance: Nulu Code works with that balance.
6. Open Nulu Code in your project folder
Nulu Code works inside the folder where you open it. To start a new project, paste these three commands, one at a time:
mkdir my-project cd my-project nuluAlready have a project? Type cd followed by the path of its folder, then nulu.
7. Sign in
The first time, Nulu Code shows a link. Open it in your browser, sign in to this platform and press Authorize. The page shows a one-time code that works for 10 minutes: copy it, paste it into the terminal and press Enter. You do not need to create or copy an API key. Do not share that code with anyone; Nulu AI will never ask you for it.
8. Ask for your first task
Type what you want in your own words and press Enter. For example:
Create a simple website for my business with a contact formBefore changing files or running commands, Nulu Code asks for your permission. Read each action and accept it if you agree.
All the commands
nulu # opens Nulu Code in the current folder
nulu --continue # continues your last conversation
nulu run "..." # sends a single instruction and prints the answer
nulu login # signs in or switches account
nulu logout # signs out on this computer
nulu models # models available in your account
nulu usage # usage and estimated cost
nulu doctor # checks everything and says what to fix
nulu update # installs the latest version
nulu --version # installed version
nulu --help # help with every option
npm uninstall -g nulu-code # uninstalls Nulu Code/help # lists every command and key
/models # switches model
/new # starts a new conversation
/resume # goes back to an earlier conversation
/undo # undoes your last message
/copy # copies the last answer or the whole conversation
/usage # balance, money spent and tokens used
/permissions # approve each action, or let the agent work on its own
/language # switches between Spanish and English
/update # installs the latest version without leavingIf something fails
Find the message you got and follow the fix.
“node” or “npm” is not recognized as a command
Node.js is not installed, or the terminal was opened before installing it. Close the terminal, open it again and try this command. If it still fails, repeat step 3.
node --versionWindows: “winget” is not recognized as a command
Your Windows does not include winget. Download the Node.js installer (LTS version) from nodejs.org, install it with the default options and open PowerShell again.
Windows: “running scripts is disabled on this system”
PowerShell is blocking npm. Paste this command, answer Y (yes) and repeat the command that failed.
Set-ExecutionPolicy -Scope CurrentUser RemoteSignedmacOS or Linux: permission error (EACCES) while installing
It happens when Node.js was installed for the whole system. The best fix is to install Node.js as step 3 says and repeat step 4. The quick alternative is this command.
sudo npm install -g nulu-code“nulu” is not recognized as a command after installing
Close the terminal and open it again. If nothing changes, install again and check that it does not end with an error.
npm install -g nulu-codeWhile installing you see “npm warn install-scripts … not yet covered by allowScripts”
It is a notice, not an error: recent npm versions do not run the last step of the installation and report it this way. Nulu Code finishes that step by itself the first time you open it. Paste the first line: if it answers with a version number, everything is fine and you can continue with step 5. Only if it answers “install script did not run” (it happens on Windows), install again with the second line.
nulu --version
npm install -g --allow-scripts=nulu-code nulu-codeWhile installing you see other “npm warn” or “npm notice” lines
They are notices from npm (for example, that a new npm version exists) and they do not stop the installation. A real error starts with “npm error”. Check that Nulu Code is installed with this command: it must answer with a version number.
nulu --versionnulu answers “install script did not run”
Your npm version blocked one step of the installation (npm 12 and later do so by default). Install with this command.
npm install -g --allow-scripts=nulu-code nulu-codeThe Node.js version is lower than 18
Install the current version: on macOS and Linux with the first line, on Windows with the second.
nvm install --lts
winget install OpenJS.NodeJS.LTSThe sign-in code is refused or expired
The code works for 10 minutes and only once. Ask for a new one and paste it into the same terminal that showed the link.
nulu loginThe sign-in link does not open by itself
Select the whole link in the terminal, copy it and paste it into your browser's address bar.
It says you have no balance
Add balance in this platform's dashboard and try again. Inside Nulu Code, /usage shows your balance.
Something else does not work
The first line checks everything and tells you what to fix. To start from scratch, uninstall with the second one and repeat step 4. If you write to support, include your operating system and what nulu --version answers; never send your sign-in code or your API key.
nulu doctor
npm uninstall -g nulu-codeAuthorization: Bearer sk_wat_your_key- The same key works on every endpoint: models, tools, files and usage.
- The /v1/messages endpoint also accepts the key in the x-api-key header.
- Keep it in a server environment variable (for example NULU_API_KEY). Do not put it in browser or mobile application code.
- Without a valid key the API answers 401 (invalid_api_key); with a balance below $0.50, 402 (insufficient_credit).
- Create a key in the dashboard, API Key section, and add balance (minimum $0.50).
- Send the request. With an OpenAI-compatible SDK you only change
base_urland the key. - Read the text in
choices[0].message.contentand the consumption inusage.
curl https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"messages": [
{"role": "system", "content": "Answer in one short sentence."},
{"role": "user", "content": "What is a managed AI API?"}
],
"max_tokens": 100
}'from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
response = client.chat.completions.create(
model="nulu-5-ultra",
messages=[
{"role": "system", "content": "Answer in one short sentence."},
{"role": "user", "content": "What is a managed AI API?"},
],
max_tokens=100,
)
print(response.choices[0].message.content)
print(response.usage.prompt_tokens, response.usage.completion_tokens)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const response = await client.chat.completions.create({
model: "nulu-5-ultra",
messages: [
{ role: "system", content: "Answer in one short sentence." },
{ role: "user", content: "What is a managed AI API?" },
],
max_tokens: 100,
});
console.log(response.choices[0].message.content);
console.log(response.usage.prompt_tokens, response.usage.completion_tokens);{
"id": "6bf293db-ee07-41d7-98e1-2c5889e05750",
"object": "chat.completion",
"created": 1796335244,
"model": "nulu-5-ultra",
"choices": [{
"index": 0,
"message": {"role": "assistant", "content": "A managed AI API is a hosted service that ..."},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 243,
"completion_tokens": 34,
"total_tokens": 277,
"prompt_tokens_details": {"cached_tokens": 128}
}
}model field must be a Nulu model id, lowercase and exact. Do not keep the key in your code: read it from an environment variable (for example NULU_API_KEY).curl https://api.nuluai.com/v1/models \
-H "Authorization: Bearer sk_wat_your_key"| Public ID | Name | Capabilities | Thinking |
|---|---|---|---|
nulu-5-pro | Nulu 5 Pro | Chat, Reasoning, Function calling | Optional |
nulu-5-ultra | Nulu 5 Ultra | Chat, Vision, Reasoning, Function calling, Web search, Deep thinking search, URL reading, File input, Content safety, Conversation titles | Optional |
nulu-image-1.5 | Nulu Image 1.5 (Legacy) | Image generation and editing | Unavailable |
nulu-image-3 | Nulu Image 3 | Image generation and editing | Unavailable |
Nulu API speaks three protocols. Pick the one your code or SDK already uses: all three support streaming, functions, files, vision, web tools, content safety and titles, and are billed the same way.
| Protocol | Endpoint | Models | Notes |
|---|---|---|---|
| Chat Completions | POST /v1/chat/completions | All chat models | OpenAI Chat Completions compatible format. |
| Responses | POST /v1/responses | nulu-5-ultra, nulu-5-pro | OpenAI Responses compatible format. Stateless: previous_response_id, conversation and background return 400. |
| Messages | POST /v1/messages | nulu-5-ultra, nulu-5-pro | Messages format. max_tokens is required. Accepts x-api-key as well as Authorization. |
Base URLs and SDK setup
| Protocol | SDK base URL | Detail |
|---|---|---|
| Chat Completions, Responses | https://api.nuluai.com/v1 | Includes /v1. |
| Messages | https://api.nuluai.com | Without /v1: the Messages SDK appends /v1/messages by itself. |
| Plain HTTP | https://api.nuluai.com/v1 | For cURL, requests or fetch. |
# Python
pip install openai anthropic requests
# JavaScript / TypeScript (Node.js 18+)
npm install openai @anthropic-ai/sdkcurl https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"messages": [
{"role": "system", "content": "Answer in one short sentence."},
{"role": "user", "content": "What is a managed AI API?"}
],
"max_tokens": 100
}'from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
response = client.chat.completions.create(
model="nulu-5-ultra",
messages=[
{"role": "system", "content": "Answer in one short sentence."},
{"role": "user", "content": "What is a managed AI API?"},
],
max_tokens=100,
)
print(response.choices[0].message.content)
print(response.usage.prompt_tokens, response.usage.completion_tokens)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const response = await client.chat.completions.create({
model: "nulu-5-ultra",
messages: [
{ role: "system", content: "Answer in one short sentence." },
{ role: "user", content: "What is a managed AI API?" },
],
max_tokens: 100,
});
console.log(response.choices[0].message.content);
console.log(response.usage.prompt_tokens, response.usage.completion_tokens);curl https://api.nuluai.com/v1/responses \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"input": "Say hello in five words.",
"max_output_tokens": 100
}'from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
response = client.responses.create(
model="nulu-5-ultra",
input="Say hello in five words.",
max_output_tokens=100,
)
print(response.output_text)
print(response.usage.input_tokens, response.usage.output_tokens)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const response = await client.responses.create({
model: "nulu-5-ultra",
input: "Say hello in five words.",
max_output_tokens: 100,
});
console.log(response.output_text);
console.log(response.usage.input_tokens, response.usage.output_tokens);curl https://api.nuluai.com/v1/messages \
-H "x-api-key: sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"max_tokens": 100,
"messages": [{"role": "user", "content": "Say hello in five words."}]
}'from anthropic import Anthropic
client = Anthropic(api_key="sk_wat_your_key", base_url="https://api.nuluai.com")
message = client.messages.create(
model="nulu-5-ultra",
max_tokens=100,
messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(message.content[0].text)
print(message.usage.input_tokens, message.usage.output_tokens)import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com" });
const message = await client.messages.create({
model: "nulu-5-ultra",
max_tokens: 100,
messages: [{ role: "user", content: "Say hello in five words." }],
});
console.log(message.content[0].text);
console.log(message.usage.input_tokens, message.usage.output_tokens);nulu-5-pro, nulu-5-ultra, nulu-image-1.5, nulu-image-3 in any SDK, in opencode and in external applications.Compatibility matrix
| Capability | Chat Completions | Responses | Messages |
|---|---|---|---|
| Text, streaming, function calling, JSON output, vision | Yes | Yes | Yes |
| Thinking | thinking / reasoning_effort | reasoning.effort | thinking |
| Web search, deep thinking search, image search | Yes | Yes | Yes |
| URL reading | Yes | Yes | Yes |
| File references | file part | input_file | document block |
| Citations | message.annotations | output_text.annotations | citations on text blocks |
| Tool activity while streaming | server_tool_event | response.web_search_call.* | content blocks |
| Content safety, conversation title | Yes | Yes | Yes |
| User context marker | Yes | No | Yes |
Stored conversations (previous_response_id) | n/a | No | n/a |
- Web tools:
nulu-5-ultraonly. Files:nulu-5-ultraandnulu-5-pro(the latter, text only). - The standalone APIs (search, fetch, OCR, speech, files) are REST and do not depend on the protocol.
- Other endpoints:
GET /v1/models,POST /v1/images/generations,POST /v1/images/edits. The full list is in API Reference.
Model Capabilities
Thinking is off by default on all three protocols, so you decide when to pay for it. Turn it on for the questions that need it: maths, planning, debugging, analysis.
| Protocol | How to enable | Where the reasoning arrives |
|---|---|---|
| Chat Completions | reasoning_effort: low, medium, high or max (turns it on by itself), or thinking: {"type": "enabled"} | message.reasoning_content |
| Responses | reasoning: {"effort": "low" | "high" | "max"} | reasoning item in output |
| Messages | thinking: {"type": "enabled"} | thinking blocks in content |
curl https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"messages": [{"role": "user", "content": "What is 17 * 23? Answer with the number."}],
"reasoning_effort": "high",
"max_tokens": 600
}'from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
response = client.chat.completions.create(
model="nulu-5-ultra",
messages=[{"role": "user", "content": "What is 17 * 23? Answer with the number."}],
reasoning_effort="high", # "low" | "medium" | "high" | "max"; sending it turns thinking on
max_tokens=600,
)
message = response.choices[0].message
print("reasoning:", message.reasoning_content[:80])
print("answer:", message.content)
print("reasoning tokens:", response.usage.completion_tokens_details.reasoning_tokens)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const response = await client.chat.completions.create({
model: "nulu-5-ultra",
messages: [{ role: "user", content: "What is 17 * 23? Answer with the number." }],
reasoning_effort: "high", // "low" | "medium" | "high" | "max"; sending it turns thinking on
max_tokens: 600,
});
const message = response.choices[0].message;
console.log("reasoning:", message.reasoning_content.slice(0, 80));
console.log("answer:", message.content);
console.log("reasoning tokens:", response.usage.completion_tokens_details.reasoning_tokens);{
"choices": [{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "391",
"reasoning_content": "17 * 23 = 17 * 20 + 17 * 3 = 340 + 51 = 391."
}
}],
"usage": {
"prompt_tokens": 267,
"completion_tokens": 17,
"total_tokens": 284,
"prompt_tokens_details": {"cached_tokens": 128},
"completion_tokens_details": {"reasoning_tokens": 15}
}
}from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
response = client.responses.create(
model="nulu-5-ultra",
input="What is 17 * 23? Answer with the number.",
reasoning={"effort": "high"}, # "low" | "high" | "max"
max_output_tokens=600,
)
print(response.output_text)
print("reasoning tokens:", response.usage.output_tokens_details.reasoning_tokens)from anthropic import Anthropic
client = Anthropic(api_key="sk_wat_your_key", base_url="https://api.nuluai.com")
message = client.messages.create(
model="nulu-5-ultra",
max_tokens=600,
thinking={"type": "enabled"},
messages=[{"role": "user", "content": "What is 17 * 23? Answer with the number."}],
)
for block in message.content:
if block.type == "thinking":
print("reasoning:", block.thinking[:80])
elif block.type == "text":
print("answer:", block.text)from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
# Thinking is off unless you ask for it. To switch it on without choosing a level,
# or to state "off" explicitly, send the thinking object through extra_body.
response = client.chat.completions.create(
model="nulu-5-ultra",
messages=[{"role": "user", "content": "Answer directly: capital of Peru?"}],
extra_body={"thinking": {"type": "disabled"}}, # or {"type": "enabled"}
max_tokens=50,
)
print(response.choices[0].message.content)usage.completion_tokens_details.reasoning_tokens reports how many there were.max_tokensincludes the reasoning: if it is low, the answer can come back empty withfinish_reason: "length".- With functions: when a thinking-mode assistant turn carries
tool_calls, send it back with itsreasoning_contentintact on later turns. - With
web_searchdeclared, turning thinking on makes the search a deep thinking search. - In the Python SDK the Nulu AI specific fields (
thinking,title,safety_check) go inextra_body; in JavaScript they are sent next to the other parameters.
Add an image_url part to the content of the user message. The URL can be a public https:// address or a base64 image (data:image/jpeg;base64,…). You can send several images and combine them with text.
| At a glance | |
|---|---|
| Models | nulu-5-ultra |
| Protocols | Chat Completions (image_url), Responses (input_image), Messages (image block) |
| Authentication | Authorization: Bearer <key> (Messages also accepts x-api-key) |
| Formats | JPEG, PNG, GIF, WebP |
| Streaming | Yes |
| Rate limit | 120 model requests per minute per key; above it, 429 with a retry-after header |
| Billing unit | Model input tokens |
Examples
IMAGE=$(base64 < photo.jpg | tr -d '\n')
curl https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"max_tokens": 100,
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "Describe this image in one sentence."},
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,'"$IMAGE"'"}}
]
}]
}'import base64
from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
with open("photo.jpg", "rb") as f:
image = base64.b64encode(f.read()).decode()
response = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=100,
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "Describe this image in one sentence."},
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64," + image}},
],
}],
)
print(response.choices[0].message.content)import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const image = fs.readFileSync("photo.jpg").toString("base64");
const response = await client.chat.completions.create({
model: "nulu-5-ultra",
max_tokens: 100,
messages: [{
role: "user",
content: [
{ type: "text", text: "Describe this image in one sentence." },
{ type: "image_url", image_url: { url: "data:image/jpeg;base64," + image } },
],
}],
});
console.log(response.choices[0].message.content);The response is a normal chat response: the text is in choices[0].message.content and the image tokens are in usage.prompt_tokens.
Pricing
- No per-image fee: each image counts as input tokens ($0.45 per 1M on Nulu 5 Ultra; double during peak hours). Larger images use more tokens.
- Example: a small photo (640×420) with a short question used about 430 input tokens and 20 output tokens: 430 × $0.45 / 1M + 20 × $1.80 / 1M = $0.0002295.
- A rejected request (4xx) is not charged.
- Public price list: www.nuluai.com/pricing
Tracking usage
- The cost is in the tokens:
usage.prompt_tokens(input) andusage.completion_tokens(output) of the same response. GET /v1/account/usagereturns every request with its tokens andcharge_usd; the dashboard Usage page shows the same.
Known limitations
- Still images only: no video or audio.
- An
https://URL must be public and reachable without a sign-in; otherwise send the image as base64. - The API stores no conversations: the image is sent again (and billed as input) on every turn of the history. For many questions about the same file, upload it and reference it by id.
- To get the exact text of a document use OCR; vision describes and interprets, it does not guarantee a literal transcription.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
| The model says it sees no image | Check that you use nulu-5-ultra and that the part is {"type": "image_url", "image_url": {"url": "…"}}. |
| 400 with a base64 image | The prefix must match the real format (data:image/png;base64, for PNG) and the base64 must have no line breaks. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- Describing product photos or generating alt text.
- Reading charts, diagrams and screenshots.
- Reviewing a user interface or a photographed document.
Describe your functions in tools. When the model needs one it answers with tool_calls and finish_reason: "tool_calls" instead of text. Your application runs the function, appends a role: "tool" message with the tool_call_id and the result, and calls the model again.
curl https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"max_tokens": 200,
"messages": [{"role": "user", "content": "What is the weather in Caracas?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}]
}'import json
from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}]
def get_weather(city):
return {"city": city, "temperature_c": 27, "condition": "sunny"} # your own code
messages = [{"role": "user", "content": "What is the weather in Caracas?"}]
first = client.chat.completions.create(model="nulu-5-ultra", messages=messages, tools=tools, max_tokens=200)
assistant = first.choices[0].message
messages.append(assistant) # send the assistant turn back unchanged
for call in assistant.tool_calls or []:
args = json.loads(call.function.arguments)
messages.append({
"role": "tool",
"tool_call_id": call.id,
"content": json.dumps(get_weather(**args)),
})
final = client.chat.completions.create(model="nulu-5-ultra", messages=messages, tools=tools, max_tokens=200)
print(final.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const tools = [{
type: "function",
function: {
name: "get_weather",
description: "Get the current weather for a city",
parameters: {
type: "object",
properties: { city: { type: "string" } },
required: ["city"],
},
},
}];
const getWeather = ({ city }) => ({ city, temperature_c: 27, condition: "sunny" }); // your own code
const messages = [{ role: "user", content: "What is the weather in Caracas?" }];
const first = await client.chat.completions.create({ model: "nulu-5-ultra", messages, tools, max_tokens: 200 });
const assistant = first.choices[0].message;
messages.push(assistant); // send the assistant turn back unchanged
for (const call of assistant.tool_calls ?? []) {
messages.push({
role: "tool",
tool_call_id: call.id,
content: JSON.stringify(getWeather(JSON.parse(call.function.arguments))),
});
}
const final = await client.chat.completions.create({ model: "nulu-5-ultra", messages, tools, max_tokens: 200 });
console.log(final.choices[0].message.content);{
"choices": [{
"index": 0,
"finish_reason": "tool_calls",
"message": {
"role": "assistant",
"content": "",
"tool_calls": [{
"index": 0,
"id": "call_00_WwynB9N3OjlttSeFPXWU7026",
"type": "function",
"function": {"name": "get_weather", "arguments": "{\"city\": \"Caracas\"}"}
}]
}
}],
"usage": {"prompt_tokens": 497, "completion_tokens": 39, "total_tokens": 536}
}- Available on
nulu-5-ultraandnulu-5-pro, on all three protocols (each with its own tool format). - The model never runs your functions: it only returns the name and the arguments as JSON. Validate the arguments before using them.
- Send the assistant turn back unchanged (with its
tool_callsand, if thinking was on, itsreasoning_content). - Your functions can live next to the server tools (
web_search,read_url) in the same request. - Pricing: the function definitions and their results count as input tokens; there is no per-call charge.
Send response_format: {"type": "json_object"}, include the word JSON in the prompt and show the shape you expect. The answer is a JSON object in message.content.
curl https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"max_tokens": 200,
"response_format": {"type": "json_object"},
"messages": [
{"role": "system", "content": "Reply with JSON only, shaped like {\"city\": string, \"country\": string}."},
{"role": "user", "content": "Where is the Eiffel Tower?"}
]
}'import json
from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
response = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=200,
response_format={"type": "json_object"},
messages=[
{"role": "system", "content": 'Reply with JSON only, shaped like {"city": string, "country": string}.'},
{"role": "user", "content": "Where is the Eiffel Tower?"},
],
)
data = json.loads(response.choices[0].message.content)
print(data["city"], data["country"])import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const response = await client.chat.completions.create({
model: "nulu-5-ultra",
max_tokens: 200,
response_format: { type: "json_object" },
messages: [
{ role: "system", content: 'Reply with JSON only, shaped like {"city": string, "country": string}.' },
{ role: "user", content: "Where is the Eiffel Tower?" },
],
});
const data = JSON.parse(response.choices[0].message.content);
console.log(data.city, data.country);- JSON mode guarantees valid JSON, not a schema: validate the fields in your code.
- Set
max_tokenswith headroom: if the answer is cut (finish_reason: "length"), the JSON is incomplete. - To extract data from a document, combine it with File input.
Upload the file once to /v1/files and put its id in the user message. The model receives its content together with your question. The shape of the reference depends on the protocol.
| At a glance | |
|---|---|
| Models | nulu-5-ultra (text, figures and images) and nulu-5-pro (text only) |
| Chat Completions | {"type": "file", "file_id": "file-api-…"} |
| Responses | {"type": "input_file", "file_id": "file-api-…"} |
| Messages | {"type": "document", "source": {"type": "file", "file_id": "file-api-…"}} |
| Authentication | Authorization: Bearer <key> (Messages also accepts x-api-key) |
| Streaming | Yes |
| Rate limit | 120 model requests per minute per key; above it, 429 with a retry-after header |
| Billing unit | Model input tokens |
Examples
curl https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"max_tokens": 100,
"messages": [{
"role": "user",
"content": [
{"type": "file", "file_id": "file-api-1234"},
{"type": "text", "text": "What is the total due? Answer with the amount only."}
]
}]
}'from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
response = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=100,
messages=[{
"role": "user",
"content": [
{"type": "file", "file_id": "file-api-1234"},
{"type": "text", "text": "What is the total due? Answer with the amount only."},
],
}],
)
print(response.choices[0].message.content)
print("input tokens:", response.usage.prompt_tokens)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const response = await client.chat.completions.create({
model: "nulu-5-ultra",
max_tokens: 100,
messages: [{
role: "user",
content: [
{ type: "file", file_id: "file-api-1234" },
{ type: "text", text: "What is the total due? Answer with the amount only." },
],
}],
});
console.log(response.choices[0].message.content);
console.log("input tokens:", response.usage.prompt_tokens);from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
response = client.responses.create(
model="nulu-5-ultra",
max_output_tokens=100,
input=[{
"role": "user",
"content": [
{"type": "input_file", "file_id": "file-api-1234"},
{"type": "input_text", "text": "What is the total due? Answer with the amount only."},
],
}],
)
print(response.output_text)from anthropic import Anthropic
client = Anthropic(api_key="sk_wat_your_key", base_url="https://api.nuluai.com")
message = client.messages.create(
model="nulu-5-ultra",
max_tokens=100,
messages=[{
"role": "user",
"content": [
{"type": "document", "source": {"type": "file", "file_id": "file-api-1234"}},
{"type": "text", "text": "What is the total due? Answer with the amount only."},
],
}],
)
print(message.content[0].text)The response is a normal model response; usage.prompt_tokens includes the tokens of the file.
Pricing
- No per-reference fee: the content of the file counts as input tokens on every request ($0.45 per 1M on Nulu 5 Ultra, $0.009 when cached; double during peak hours).
- Example: three questions about a 20,000-token document, 200 output tokens each: 3 × (20,000 × $0.45 / 1M + 200 × $1.80 / 1M = $0.00936). With context caching the second and third usually cost less.
- Parsing the document is charged separately and once, at upload ($0.675 per 1,000 pages).
- A rejected request (for example, 404
file_not_found) is not charged. - Public price list: www.nuluai.com/pricing
Tracking usage
- The cost is in the tokens:
usage.prompt_tokens(input) andusage.completion_tokens(output) of the same response. GET /v1/account/usagereturns every request with its tokens andcharge_usd; the dashboard Usage page shows the same.
Known limitations
- Up to 20 documents per request.
- The API stores no conversations: send the file reference again in the history of every request.
- Put files at the start of the conversation and keep their order: that way the prefix is reused from the cache.
- An expired or deleted file stops working even if it is still in your history.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
404 file_not_found | The id does not exist, expired or belongs to another account. Upload the file again and update the history. |
| The model ignores the figures | Upload the file with rich_layout_recognition and use nulu-5-ultra. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- Questions and answers over contracts, manuals or reports.
- Extracting fields from a document into JSON (combine it with JSON output).
- Comparing several documents in a single request.
There is nothing to enable. When a request starts the same way as an earlier one (same system prompt, same documents, same history), that part is served from the cache and billed at the cached-input rate.
On Nulu 5 Ultra input costs $0.45 per 1M tokens and cached input $0.009. usage.prompt_tokens_details.cached_tokens reports how many tokens of the request came from the cache.
from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
manual = "Nulu AI support manual. " + "Refunds are processed within five business days. " * 400
for question in ["How long do refunds take?", "Who processes refunds?"]:
response = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=60,
messages=[
{"role": "system", "content": manual}, # stable prefix first
{"role": "user", "content": question}, # changing part last
],
)
usage = response.usage
print(usage.prompt_tokens, "input tokens,", usage.prompt_tokens_details.cached_tokens, "from cache")- Put what does not change first (instructions, documents) and what changes last (the question).
- The cache matches on the exact prefix: a change at the start of the prompt invalidates everything after it.
- Caching is a likely saving, not a guaranteed one: the first request, and requests that come much later, pay the normal rate.
- On Messages the usage arrives as
cache_read_input_tokens; on Responses, asinput_tokens_details.cached_tokens.
Web and Research Tools
Declare {"type": "web_search"} in tools and the model decides when to search. One search may run several queries at once. The response carries the text, the citations (annotations) and the detail of every search (server_tool_calls) with its sources.
The search runs on the server: your application executes nothing. It is multilingual and works next to your own functions (type: "function") in the same request.
| At a glance | |
|---|---|
| Models | nulu-5-ultra only |
| Protocols | Chat Completions, Responses, Messages. On Messages the tool is declared as {"type": "web_search", "name": "web_search"}. |
| Authentication | Authorization: Bearer <key> (Messages also accepts x-api-key) |
| Streaming | Yes, with tool activity events |
| Rate limit | 120 model requests per minute per key; above it, 429 with a retry-after header |
| Typical latency | 5–15 s, one search step |
| Billing unit | Model tokens (no separate charge) |
Examples
curl https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"max_tokens": 300,
"tools": [{"type": "web_search"}],
"messages": [{"role": "user", "content": "Search the web: what is the latest stable Node.js LTS version? One sentence."}]
}'from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
response = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=300,
tools=[{"type": "web_search"}],
messages=[{"role": "user", "content": "Search the web: what is the latest stable Node.js LTS version? One sentence."}],
)
message = response.choices[0].message
print(message.content)
for annotation in message.annotations or []:
print("source:", annotation.url_citation.title, annotation.url_citation.url)
for step in getattr(message, "server_tool_calls", None) or []:
for call in step["calls"]:
print(call["kind"], call["status"], call["action"].get("queries"))
print("server tools:", getattr(response.usage, "server_tool_use", None))
print("input tokens:", response.usage.prompt_tokens)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const response = await client.chat.completions.create({
model: "nulu-5-ultra",
max_tokens: 300,
tools: [{ type: "web_search" }],
messages: [{ role: "user", content: "Search the web: what is the latest stable Node.js LTS version? One sentence." }],
});
const message = response.choices[0].message;
console.log(message.content);
for (const annotation of message.annotations ?? []) {
console.log("source:", annotation.url_citation.title, annotation.url_citation.url);
}
for (const step of message.server_tool_calls ?? []) {
for (const call of step.calls) console.log(call.kind, call.status, call.action.queries);
}
console.log("server tools:", response.usage.server_tool_use);
console.log("input tokens:", response.usage.prompt_tokens);{
"id": "250147e1-ee9e-468d-becb-c9d678ef809a",
"object": "chat.completion",
"model": "nulu-5-ultra",
"choices": [{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "The latest stable Node.js LTS version is ...",
"annotations": [{
"type": "url_citation",
"url_citation": {
"url": "https://nodejs.org/en/about/previous-releases",
"title": "Node.js Releases",
"start_index": 0,
"end_index": 86
}
}],
"server_tool_calls": [{
"index": 0,
"calls": [{
"index": 0,
"id": "srvtoolu_s_00_1fe7c4d1...",
"type": "web_search",
"kind": "search",
"action": {"type": "search", "queries": ["Node.js latest LTS version", "site:nodejs.org releases"]},
"status": "completed",
"sources": [{
"type": "url",
"url": "https://nodejs.org/en/about/previous-releases",
"title": "Node.js Releases",
"snippet": "...",
"site_name": "Node.js",
"site_icon": null,
"published_at": null
}]
}]
}]
}
}],
"usage": {
"prompt_tokens": 8028,
"completion_tokens": 46,
"total_tokens": 8074,
"prompt_tokens_details": {"cached_tokens": 0},
"server_tool_use": {"tool_search": 3, "tool_fetch": 0, "tool_image_search": 0}
}
}curl -N https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"max_tokens": 300,
"stream": true,
"tools": [{"type": "web_search"}],
"messages": [{"role": "user", "content": "Search the web: what is the latest stable Python version? One sentence."}]
}'from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
stream = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=300,
stream=True,
stream_options={"include_usage": True},
tools=[{"type": "web_search"}],
messages=[{"role": "user", "content": "Search the web: what is the latest stable Python version? One sentence."}],
)
citations = []
for chunk in stream:
if chunk.usage:
print("\nserver tools:", getattr(chunk.usage, "server_tool_use", None))
if not chunk.choices:
continue
choice = chunk.choices[0]
event = getattr(choice, "server_tool_event", None)
if event and event["type"] == "call_started":
print("[searching]", event["call"]["action"])
elif event and event["type"] == "call_completed":
print("[done]", event["call"]["status"])
if choice.delta.content:
print(choice.delta.content, end="", flush=True)
citations = getattr(choice.delta, "annotations", None) or citations # arrives on the last chunk
for citation in citations:
print("source:", citation["url_citation"]["url"])import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const stream = await client.chat.completions.create({
model: "nulu-5-ultra",
max_tokens: 300,
stream: true,
stream_options: { include_usage: true },
tools: [{ type: "web_search" }],
messages: [{ role: "user", content: "Search the web: what is the latest stable Python version? One sentence." }],
});
let citations = [];
for await (const chunk of stream) {
if (chunk.usage) console.log("\nserver tools:", chunk.usage.server_tool_use);
const choice = chunk.choices[0];
if (!choice) continue;
const event = choice.server_tool_event;
if (event?.type === "call_started") console.log("[searching]", JSON.stringify(event.call.action));
if (event?.type === "call_completed") console.log("[done]", event.call.status);
if (choice.delta.content) process.stdout.write(choice.delta.content);
citations = choice.delta.annotations ?? citations; // arrives on the last chunk
}
for (const citation of citations) console.log("source:", citation.url_citation.url);data: {"choices":[{"index":0,"delta":{},"server_tool_event":{"type":"call_started","step":0,"call":{"index":0,"id":"srvtoolu_s_00_5272...","type":"web_search","kind":"search","action":{"type":"search","queries":["latest stable Python version"]}}},"finish_reason":null}],"usage":null}
data: {"choices":[{"index":0,"delta":{},"server_tool_event":{"type":"call_completed","step":0,"call":{"index":0,"id":"srvtoolu_s_00_5272...","status":"completed","sources":[{"type":"url","url":"https://www.python.org/downloads/","title":"..."}]}},"finish_reason":null}],"usage":null}
data: {"choices":[{"index":0,"delta":{"content":"The"},"finish_reason":null}],"usage":null}
data: {"choices":[{"index":0,"delta":{"content":"","annotations":[...],"server_tool_calls":[...]},"finish_reason":"stop"}],"usage":{"prompt_tokens":2249,"completion_tokens":35,"total_tokens":2284,"server_tool_use":{"tool_search":1,"tool_fetch":0,"tool_image_search":0}}}
data: [DONE]While the model searches, a chunk may carry choices[0].server_tool_event: call_started (what it is about to search), call_completed (result and sources) and step_reasoning_done. The last chunk carries the complete delta.annotations and delta.server_tool_calls, finish_reason and usage.
from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
response = client.responses.create(
model="nulu-5-ultra",
max_output_tokens=300,
tools=[{"type": "web_search"}],
input="Search the web: what is the latest stable Node.js LTS version? One sentence.",
)
print(response.output_text)
for item in response.output:
if item.type == "web_search_call":
print("search:", item.status)
elif item.type == "message":
for annotation in item.content[0].annotations:
print("source:", annotation.title, annotation.url)from anthropic import Anthropic
client = Anthropic(api_key="sk_wat_your_key", base_url="https://api.nuluai.com")
message = client.messages.create(
model="nulu-5-ultra",
max_tokens=300,
tools=[{"type": "web_search", "name": "web_search"}],
messages=[{"role": "user", "content": "Search the web: what is the latest stable Node.js LTS version? One sentence."}],
)
for block in message.content:
if block.type == "server_tool_use":
print("search:", block.input)
elif block.type == "text":
print(block.text)
for citation in block.citations or []:
print("source:", citation.title, citation.url)Responses returns web_search_call items and a message whose citations are in output_text.annotations (url_citation). Messages returns server_tool_use and web_search_tool_result blocks, and text blocks with citations.
Pricing
- No per-search fee: you pay only the model tokens. Nulu 5 Ultra rates per 1M tokens: input $0.45, cached input $0.009, output $1.80; they double during peak hours.
- What is billed: the search results count as input tokens (usually 4,000 to 12,000 per search step) and the answer as output tokens.
- Example: an answer with search that uses 8,000 input tokens and 60 output tokens costs 8,000 × $0.45 / 1M + 60 × $1.80 / 1M = $0.003708 off-peak.
- Failed requests: a rejected request (4xx) is not charged. If a search or page read fails inside a request that does complete, the call is reported with
status: "failed"and only the tokens the model processed are billed. - Public price list: www.nuluai.com/pricing
Tracking usage
usage.server_tool_usecounts the operations of the request (tool_search). It is informational: nothing is charged separately.- The cost is in the tokens:
usage.prompt_tokens(input) andusage.completion_tokens(output) of the same response. GET /v1/account/usagereturns every request with its tokens andcharge_usd; the dashboard Usage page shows the same.
Known limitations
- The model decides whether to search;
tool_choicecannot force it. If you need a search, ask for it in the message ("Search the web: …"). - The model does not know today's date by itself: for current-events searches send the user context marker with the date.
- Full page text is not returned: you get title, URL and a snippet per source.
- You cannot restrict domains with a parameter; say it in the message or use the Search API with the
site:operator.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
400 unsupported_tool | Web tools work on nulu-5-ultra only. Change the model. |
400 unsupported_tool_choice | tool_choice cannot force web_search or read_url: the model decides. Remove tool_choice or ask for the search in the message. |
The response has no annotations | The model answered without searching. Check server_tool_calls: if it is absent, no search ran. Ask for the search explicitly. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- Assistants that answer about news, prices, versions or recent documentation.
- Answers with verifiable sources for support or research.
- Combining public data with your own functions in a single request.
It is web search with thinking turned on: declare web_search and enable thinking (reasoning_effort or thinking on Chat Completions and Messages, reasoning.effort on Responses). The model plans, runs several searches, opens the most useful pages and can look for a text inside a page.
Calls carry kind: "deep_search" and three action types: search (queries), open_page (opens a URL) and find_in_page (looks for a pattern in a page).
| At a glance | |
|---|---|
| Models | nulu-5-ultra only |
| Protocols | Chat Completions, Responses, Messages |
| Authentication | Authorization: Bearer <key> (Messages also accepts x-api-key) |
| Streaming | Yes, and it is the recommended way: without streaming the request is cut at ~95 s |
| Rate limit | 120 model requests per minute per key; above it, 429 with a retry-after header |
| Billing unit | Model tokens (no separate charge) |
Examples
Differences from standard search
| Standard search | Deep thinking search | |
|---|---|---|
| How to enable | web_search, thinking off | web_search + thinking on |
| Steps | 1 search step | Several: search → open pages → find in page (up to ~20 calls) |
| Typical latency | 5–15 s | 30–120 s |
| Input tokens added | ~4,000–12,000 | Tens of thousands, plus reasoning tokens in the output |
| Example cost (off-peak) | 8,000 × $0.45 / 1M + 60 × $1.80 / 1M = $0.003708 | 25,000 × $0.45 / 1M + 1,100 × $1.80 / 1M = $0.0132 |
| Streaming | Optional | Always recommended (stream: true) |
| Use it for | Single, current facts | Comparisons, reports and questions that need several sources read |
curl -N --max-time 300 https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"max_tokens": 1500,
"stream": true,
"reasoning_effort": "low",
"tools": [{"type": "web_search"}],
"messages": [{"role": "user", "content": "Compare the release cadence of Node.js and Python in three bullet points, with sources."}]
}'from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
# Deep thinking search = web_search + thinking. Always stream: runs take 30-120 s.
stream = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=1500,
stream=True,
stream_options={"include_usage": True},
reasoning_effort="low",
tools=[{"type": "web_search"}],
messages=[{
"role": "user",
"content": "Compare the release cadence of Node.js and Python in three bullet points, with sources.",
}],
timeout=300,
)
for chunk in stream:
if chunk.usage:
print("\n", getattr(chunk.usage, "server_tool_use", None), chunk.usage.prompt_tokens, "input tokens")
if not chunk.choices:
continue
choice = chunk.choices[0]
event = getattr(choice, "server_tool_event", None)
if event and event["type"] == "call_started":
print("[" + event["call"]["kind"] + "]", event["call"]["action"])
if choice.delta.content:
print(choice.delta.content, end="", flush=True)
for annotation in getattr(choice.delta, "annotations", None) or []:
print("\nsource:", annotation["url_citation"]["url"])import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
// Deep thinking search = web_search + thinking. Always stream: runs take 30-120 s.
const stream = await client.chat.completions.create(
{
model: "nulu-5-ultra",
max_tokens: 1500,
stream: true,
stream_options: { include_usage: true },
reasoning_effort: "low",
tools: [{ type: "web_search" }],
messages: [{
role: "user",
content: "Compare the release cadence of Node.js and Python in three bullet points, with sources.",
}],
},
{ timeout: 300_000 },
);
for await (const chunk of stream) {
if (chunk.usage) console.log("\n", chunk.usage.server_tool_use, chunk.usage.prompt_tokens, "input tokens");
const choice = chunk.choices[0];
if (!choice) continue;
const event = choice.server_tool_event;
if (event?.type === "call_started") console.log("[" + event.call.kind + "]", JSON.stringify(event.call.action));
if (choice.delta.content) process.stdout.write(choice.delta.content);
for (const annotation of choice.delta.annotations ?? []) console.log("\nsource:", annotation.url_citation.url);
}The stream events are the same as for web search (server_tool_event), one call per search or opened page. Show them to the user as progress: tens of seconds pass before the first text of the answer.
Pricing
- No per-search fee: you pay only the model tokens. Nulu 5 Ultra rates per 1M tokens: input $0.45, cached input $0.009, output $1.80; they double during peak hours.
- What is billed: search results and opened pages as input tokens; reasoning and the answer as output tokens (
usage.completion_tokens_details.reasoning_tokensreports the reasoning part). - Example: a research run with 25,000 input tokens and 1,100 output tokens costs 25,000 × $0.45 / 1M + 1,100 × $1.80 / 1M = $0.0132 off-peak. A long run can go beyond 100,000 input tokens.
- To bound the cost: use
reasoning_effort: "low", setmax_tokens, and keep this mode for questions that need it. - Failed requests: a rejected request (4xx) is not charged. If a search or page read fails inside a request that does complete, the call is reported with
status: "failed"and only the tokens the model processed are billed. - Public price list: www.nuluai.com/pricing
Tracking usage
usage.server_tool_usecounts the operations of the request (tool_search). It is informational: nothing is charged separately.- The cost is in the tokens:
usage.prompt_tokens(input) andusage.completion_tokens(output) of the same response. GET /v1/account/usagereturns every request with its tokens andcharge_usd; the dashboard Usage page shows the same.
Known limitations
- Without streaming the request is limited to about 95 seconds and may fail before the answer. Use
stream: trueand a client timeout of at least 5 minutes. - The number of steps is decided by the model (up to ~20 calls); there is no parameter to set it.
- With thinking and
web_searchdeclared, links in the message are opened by this mode, not byread_url. - Cost varies a lot between questions: measure with
usagebefore offering it to all your users.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
| Timeout or closed connection without streaming | The research took longer than the ~95 s limit. Repeat with stream: true. |
| The client gives up at 60 s | Raise the timeout of your HTTP client or SDK (the samples use 300 s). |
finish_reason: "length" with no useful answer | max_tokens was spent on reasoning. Raise it: reasoning counts as output. |
400 unsupported_tool | Web tools work on nulu-5-ultra only. Change the model. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- Comparative reports with sources (products, vendors, regulations).
- Technical questions that need full documentation or changelogs read.
- A "research in depth" mode the user explicitly chooses in your chat.
It is not a separate tool: declare web_search and send an image in the user message. The model may run an image search (kind: "image_search") to recognise what it sees or to find similar images. The sources of those calls carry image_url besides url and title.
| At a glance | |
|---|---|
| Models | nulu-5-ultra only |
| Protocols | Chat Completions, Responses, Messages |
| Authentication | Authorization: Bearer <key> (Messages also accepts x-api-key) |
| Streaming | Yes |
| Rate limit | 120 model requests per minute per key; above it, 429 with a retry-after header |
| Billing unit | Model tokens (no separate charge) |
Examples
import base64
from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
with open("photo.jpg", "rb") as f:
image = base64.b64encode(f.read()).decode()
response = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=300,
tools=[{"type": "web_search"}],
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "Search the web for images similar to this one and say what they show."},
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64," + image}},
],
}],
)
message = response.choices[0].message
print(message.content)
for step in getattr(message, "server_tool_calls", None) or []:
for call in step["calls"]:
print(call["kind"], call["status"])
for source in call.get("sources", [])[:3]:
print(" ", source.get("image_url") or source["url"])
print(getattr(response.usage, "server_tool_use", None))Pricing
- No per-search fee: you pay only the model tokens. Nulu 5 Ultra rates per 1M tokens: input $0.45, cached input $0.009, output $1.80; they double during peak hours.
- What is billed: the image you send and the search results count as input tokens.
- Example: 6,000 input tokens and 250 output tokens cost 6,000 × $0.45 / 1M + 250 × $1.80 / 1M = $0.00315 off-peak.
- Failed requests: a rejected request (4xx) is not charged. If a search or page read fails inside a request that does complete, the call is reported with
status: "failed"and only the tokens the model processed are billed. - Public price list: www.nuluai.com/pricing
Tracking usage
usage.server_tool_usecounts the operations of the request (tool_image_search). It is informational: nothing is charged separately.- The cost is in the tokens:
usage.prompt_tokens(input) andusage.completion_tokens(output) of the same response. GET /v1/account/usagereturns every request with its tokens andcharge_usd; the dashboard Usage page shows the same.
Known limitations
- The model decides whether to run an image search; it cannot be forced.
- The
image_urlvalues of the sources point to third-party sites: they can expire or block hot-linking. Download them if you need to keep them, and respect their licences. - It does not generate images; use
nulu-image-3for that.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
There are no image_search calls | The model answered with vision alone. Ask explicitly for a web search of similar images. |
400 unsupported_tool | Web tools work on nulu-5-ultra only. Change the model. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- Identifying a product, place or artwork from a photo.
- Finding visually similar images and where they come from.
- Checking whether an image already circulates on the web.
Declare {"type": "read_url"} in tools. The links in the last user message are opened on the server (the first 10 distinct ones) and the model answers from what it read. Each read appears in server_tool_calls with kind: "read_link".
If a page cannot be opened, the call arrives with status: "failed" and an error.code; the model is told and does not claim to have read it.
| At a glance | |
|---|---|
| Models | nulu-5-ultra only |
| Protocols | Chat Completions, Responses, Messages |
| Authentication | Authorization: Bearer <key> (Messages also accepts x-api-key) |
| Streaming | Yes (server_tool_event with read_link) |
| Rate limit | 120 model requests per minute per key; above it, 429 with a retry-after header |
| Billing unit | Model tokens (no separate charge) |
Examples
curl https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"max_tokens": 200,
"tools": [{"type": "read_url"}],
"messages": [{"role": "user", "content": "Summarize https://nodejs.org/en/about/previous-releases in two sentences."}]
}'from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
response = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=200,
tools=[{"type": "read_url"}],
messages=[{
"role": "user",
"content": "Summarize https://nodejs.org/en/about/previous-releases in two sentences.",
}],
)
message = response.choices[0].message
for step in getattr(message, "server_tool_calls", None) or []:
for call in step["calls"]:
if call["status"] == "completed":
print("read:", call["page"]["title"], call["page"]["url"])
else:
print("could not read:", call["action"]["url"], call["error"]["code"])
print(message.content)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const response = await client.chat.completions.create({
model: "nulu-5-ultra",
max_tokens: 200,
tools: [{ type: "read_url" }],
messages: [{
role: "user",
content: "Summarize https://nodejs.org/en/about/previous-releases in two sentences.",
}],
});
const message = response.choices[0].message;
for (const step of message.server_tool_calls ?? []) {
for (const call of step.calls) {
if (call.status === "completed") console.log("read:", call.page.title, call.page.url);
else console.log("could not read:", call.action.url, call.error.code);
}
}
console.log(message.content);"server_tool_calls": [{
"index": 0,
"calls": [{
"index": 0,
"id": "srvtoolu_rl_00_1b23c606...",
"type": "read_url",
"kind": "read_link",
"action": {"type": "read_link", "url": "https://nodejs.org/en/about/previous-releases"},
"status": "completed",
"page": {"url": "https://nodejs.org/en/about/previous-releases", "title": "Node.js Releases", "published_at": null},
"signature": "lSMvOnQcTf+yVKPchzWf..."
}]
}]
// A page that could not be read:
{"status": "failed", "action": {"type": "read_link", "url": "..."}, "error": {"code": "url_not_accessible"}}Pricing
- No per-page fee: the content read counts as model input tokens (input $0.45 per 1M on Nulu 5 Ultra; double during peak hours).
- Example: summarising a 6,000-token page with 150 output tokens costs 6,000 × $0.45 / 1M + 150 × $1.80 / 1M = $0.00297 off-peak.
- A failed read adds no page content: you pay only the tokens of the rest of the conversation.
- Public price list: www.nuluai.com/pricing
Tracking usage
usage.server_tool_usecounts the operations of the request (tool_fetch). It is informational: nothing is charged separately.- The cost is in the tokens:
usage.prompt_tokens(input) andusage.completion_tokens(output) of the same response. GET /v1/account/usagereturns every request with its tokens andcharge_usd; the dashboard Usage page shows the same.
Known limitations
- Only links in the last user message are opened, and at most the first 10 distinct ones.
- The page text is not returned to the client. If you need the text, use the Fetch API (
/v1/tools/fetch). - Pages behind a sign-in or paywall, and private or internal addresses, cannot be read.
- On later turns send the assistant turn back unchanged: the page is restored from its
signature, without downloading it again. - With thinking and
web_searchdeclared together, links are handled by deep thinking search.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
error.code: url_not_accessible | The page does not respond, requires a sign-in or has no readable text. Check the URL in a signed-out browser. |
error.code: url_not_allowed | Private, internal or blocked address. Only public web addresses are read. |
error.code: unavailable | Temporary reader failure. Retry later. |
400 unsupported_tool | Web tools work on nulu-5-ultra only. Change the model. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- "Summarise this article" or "what does this page say about X?" in a chat.
- Comparing the content of several links the user pastes.
- Extracting data from a public page into JSON.
POST /v1/tools/search returns ranked results with title, URL, snippet and summary. Use it when you want to control the search yourself: your own RAG pipeline, a search box, or your own function tools.
| At a glance | |
|---|---|
| Endpoint | POST /v1/tools/search (JSON) |
| Models | No model involved |
| Protocols | REST only |
| Authentication | Authorization: Bearer <key> |
| Rate limit | 120 requests per minute per key; above it, 429 with a retry-after header |
| Billing unit | Successful request with results |
Examples
| Field | Type | Description |
|---|---|---|
query | string, required | 1–128 characters. Operators: site:, -site:, "exact phrase", lang:, after:, before:. |
count | integer | 1–50 results; default 10. |
need_content | boolean | If true, each result includes the page text in content. |
ori_question | string | Optional: the user's original question, to improve the ranking of results. |
curl -i https://api.nuluai.com/v1/tools/search \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{"query": "python release schedule site:python.org", "count": 3}'import requests
API = "https://api.nuluai.com/v1"
HEADERS = {"Authorization": "Bearer sk_wat_your_key"}
r = requests.post(
API + "/tools/search",
headers=HEADERS,
json={"query": "python release schedule site:python.org", "count": 3},
timeout=60,
)
r.raise_for_status()
for result in r.json()["results"]:
print(result["title"], "-", result["url"])
print(" ", (result["snippet"] or "")[:100])
print("charged (cents):", r.headers["x-nulu-charge-cents"], "| billed:", r.headers["x-nulu-billed-units"])const API = "https://api.nuluai.com/v1";
const headers = { Authorization: "Bearer sk_wat_your_key" };
const r = await fetch(API + "/tools/search", {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({ query: "python release schedule site:python.org", count: 3 }),
});
if (!r.ok) throw new Error((await r.json()).error.message);
const { results } = await r.json();
for (const result of results) {
console.log(result.title, "-", result.url);
console.log(" ", (result.snippet ?? "").slice(0, 100));
}
console.log("charged (cents):", r.headers.get("x-nulu-charge-cents"), "| billed:", r.headers.get("x-nulu-billed-units"));HTTP/1.1 200 OK
x-nulu-billed-units: 1 request
x-nulu-charge-cents: 0.225
x-request-id: 2dcd9c5c-62fe-4778-b9a3-0cc454a51be3
{
"object": "search.result",
"query": "python release schedule site:python.org",
"results": [{
"title": "Status of Python versions",
"url": "https://devguide.python.org/versions/",
"snippet": "...",
"summary": "...",
"content": null,
"site_name": "Python Developer's Guide",
"site_icon": null,
"date": "2026-05-26T16:00:00+00:00",
"authority": 4,
"rerank_score": 2.52
}]
}Pricing
- $2.25 per 1,000 successful requests. Billed per request, not per result: asking for 3 or 50 results costs the same.
- Example: 400 searches in a day cost 400 × $2.25 / 1,000 = $0.90. One search costs $0.00225.
- Not charged: a search with no results, a 4xx or 5xx error. There are no model tokens: this API calls no model.
- Public price list: www.nuluai.com/pricing
Tracking usage
- Every successful response carries
x-nulu-charge-cents(what was charged, in US cents) andx-nulu-billed-units(the units billed). GET /v1/account/usagelists every operation and groups it undernulu-searchinsummary.by_model.- In the dashboard, the Usage page shows the same operations with their cost.
Known limitations
- The query is limited to 128 characters.
- Unknown fields are rejected with 400
unsupported_parameter: there is no pagination and no filters beyond the operators. date,site_icon,contentandsummarycan benulldepending on the source.- Web results only: no image or video results.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
400 unsupported_parameter | You sent a field that does not exist. Use only the ones in the table. |
Empty results | The query is too narrow (for example, several site:). It is not charged; widen the query. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- Retrieval for RAG with your own prompt and model.
- A search box inside your product.
- Monitoring mentions or news of a domain with
site:andafter:.
POST /v1/tools/fetch downloads a public URL and returns its title and main content as Markdown, without menus or ads. The result is ready to index, summarise or pass to a model as context.
| At a glance | |
|---|---|
| Endpoint | POST /v1/tools/fetch (JSON: {"url": "https://..."}) |
| Models | No model involved |
| Protocols | REST only |
| Authentication | Authorization: Bearer <key> |
| Rate limit | 60 requests per minute per key; above it, 429 with a retry-after header |
| Billing unit | Successful request with content |
Examples
curl -i https://api.nuluai.com/v1/tools/fetch \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com"}'import requests
API = "https://api.nuluai.com/v1"
HEADERS = {"Authorization": "Bearer sk_wat_your_key"}
r = requests.post(API + "/tools/fetch", headers=HEADERS, json={"url": "https://example.com"}, timeout=60)
if r.status_code != 200:
error = r.json()["error"]
print("not fetched (not charged):", r.status_code, error["code"])
else:
page = r.json()
print(page["title"])
print(page["content"][:200]) # Markdown
print("charged (cents):", r.headers["x-nulu-charge-cents"])const API = "https://api.nuluai.com/v1";
const headers = { Authorization: "Bearer sk_wat_your_key" };
const r = await fetch(API + "/tools/fetch", {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({ url: "https://example.com" }),
});
if (!r.ok) {
const { error } = await r.json();
console.log("not fetched (not charged):", r.status, error.code);
} else {
const page = await r.json();
console.log(page.title);
console.log(page.content.slice(0, 200)); // Markdown
console.log("charged (cents):", r.headers.get("x-nulu-charge-cents"));
}HTTP/1.1 200 OK
x-nulu-billed-units: 1 request
x-nulu-charge-cents: 0.225
{
"object": "fetch.result",
"url": "https://example.com",
"title": "Example Domain",
"content": "This domain is for use in documentation examples ..."
}Pricing
- $2.25 per 1,000 successful requests. One request reads one URL.
- Example: reading 250 pages costs 250 × $2.25 / 1,000 = $0.5625.
- A failed fetch (400, 403, 404 or 5xx) is not charged. There are no model tokens; if you later pass the Markdown to a model, that request is billed by its tokens.
- Public price list: www.nuluai.com/pricing
Tracking usage
- Every successful response carries
x-nulu-charge-cents(what was charged, in US cents) andx-nulu-billed-units(the units billed). GET /v1/account/usagelists every operation and groups it undernulu-fetchinsummary.by_model.- In the dashboard, the Usage page shows the same operations with their cost.
Known limitations
- One URL per request.
- Public web addresses only: private, internal or blocked ones return 403.
- Pages that need a sign-in, or without readable text, return 404
url_not_accessible. - It returns the main content as Markdown, not the original HTML or the images.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
400 invalid_url | The URL is malformed. Include https://. |
403 url_not_allowed | Private, internal or blocked address. Do not retry. |
404 url_not_accessible | The page is unreachable, needs a sign-in or has no readable content. Check it in a signed-out browser. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- Filling a knowledge base from public pages.
- Reading the full text of Search API results.
- Implementing your own "open link" function for an agent.
Document Intelligence
POST /v1/files stores a file in your account and returns an id (file-api-…). That id is then referenced in any conversation. Files are private to your account: another account using the id gets a 404.
The purpose field decides what happens to the file: user_data stores it as is (images, plain text, spreadsheets, ebooks); text_recognition and rich_layout_recognition also parse it during the upload (see Document parsing).
| At a glance | |
|---|---|
| Endpoint | POST /v1/files (multipart) · GET /v1/files · GET /v1/files/{id} · DELETE /v1/files/{id} |
| Models | No model involved |
| Protocols | REST only; the id is then used on all three protocols |
| Authentication | Authorization: Bearer <key> |
| Rate limit | 20 uploads per minute per key; above it, 429 with a retry-after header |
| Retention | 30 days by default and at most; expires_after[seconds] from 3,600 to 2,592,000 |
| Storage | 500 files and 2 GB per account; 64 MB per file |
Examples
| Form field | Description |
|---|---|
file | Required. The file. |
purpose | user_data (default), text_recognition or rich_layout_recognition. |
expires_after[anchor], expires_after[seconds] | Optional. anchor must be created_at; seconds between 3600 and 2592000. |
curl https://api.nuluai.com/v1/files \
-H "Authorization: Bearer sk_wat_your_key" \
-F "purpose=user_data" \
-F "expires_after[anchor]=created_at" \
-F "expires_after[seconds]=86400" \
-F "[email protected]"from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
with open("photo.jpg", "rb") as f:
uploaded = client.files.create(
file=f,
purpose="user_data",
expires_after={"anchor": "created_at", "seconds": 86400}, # optional; default is 30 days
)
print(uploaded.id, uploaded.bytes, uploaded.expires_at)
print([f.id for f in client.files.list(limit=5).data]) # list
print(client.files.retrieve(uploaded.id).filename) # metadata
print(client.files.delete(uploaded.id).deleted) # deleteimport fs from "node:fs";
import { toFile } from "openai";
import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const uploaded = await client.files.create({
file: await toFile(fs.readFileSync("photo.jpg"), "photo.jpg"), // a buffer, not a stream: the upload needs its length
purpose: "user_data",
expires_after: { anchor: "created_at", seconds: 86400 }, // optional; default is 30 days
});
console.log(uploaded.id, uploaded.bytes, uploaded.expires_at);
console.log((await client.files.list({ limit: 5 })).data.map((f) => f.id)); // list
console.log((await client.files.retrieve(uploaded.id)).filename); // metadata
console.log((await client.files.delete(uploaded.id)).deleted); // delete# List (newest first), read one, delete one
curl "https://api.nuluai.com/v1/files?limit=5&order=desc" -H "Authorization: Bearer sk_wat_your_key"
curl https://api.nuluai.com/v1/files/file-api-1234 -H "Authorization: Bearer sk_wat_your_key"
curl -X DELETE https://api.nuluai.com/v1/files/file-api-1234 -H "Authorization: Bearer sk_wat_your_key"{
"id": "file-api-379dc6b7-d138-4e4f-b92f-ee6a8dff44d2",
"object": "file",
"bytes": 11892,
"created_at": 1796335334,
"filename": "photo.jpg",
"purpose": "user_data",
"expires_at": 1796421734
}
// GET /v1/files
{"object": "list", "data": [ ...files ], "first_id": "file-api-...", "last_id": "file-api-...", "has_more": false}
// DELETE /v1/files/{id}
{"id": "file-api-379dc6b7-d138-4e4f-b92f-ee6a8dff44d2", "object": "file", "deleted": true}GET /v1/files accepts limit, after (id to continue from), order (asc or desc) and purpose.
Pricing
- Uploading, storing, listing and deleting
user_datafiles is free. - Files uploaded with
text_recognitionorrich_layout_recognitionpay for parsing once, at upload: $0.675 per 1,000 pages. - When a file is referenced in a conversation, its content counts as model input tokens on every request.
- A rejected upload is not charged.
- Public price list: www.nuluai.com/pricing
Tracking usage
- The upload response carries
x-nulu-charge-cents(0 foruser_data). GET /v1/filesshows what you have stored, withbytesandexpires_atper file.
Known limitations
- There are no permanent files: all expire after 30 days at most. Upload them again if you need them longer.
- Neither the original nor the parsed text can be downloaded: keep your own copy.
- The upload must send
Content-Length: send a file or a buffer, not a stream without a length (a stream returns 411). user_dataaccepts images (JPEG, PNG, GIF, WebP), plain text, spreadsheets (XLSX, XLS) and ebooks (EPUB, MOBI).
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
404 file_not_found | The id does not exist, expired, was deleted or belongs to another account. |
409 storage_limit | You reached 500 files or 2 GB. Delete files with DELETE /v1/files/{id}. |
| 411 | The upload arrived without Content-Length. Send the file from a buffer or a file on disk. |
400 "purpose must be one of…" | Only user_data, text_recognition and rich_layout_recognition are accepted. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- Chat attachments: the user uploads a file and asks about it several times.
- Reusing the same document across many requests without sending it again.
- Temporary files with a short expiry (
expires_after).
Upload the document to /v1/files with purpose=text_recognition (text only) or purpose=rich_layout_recognition (text and figures). Parsing happens during the upload and can take up to about 2 minutes. The response includes pages, the number of pages parsed and billed.
Then reference the id in the conversation: the model receives the parsed content. With rich_layout_recognition the figures are given to the model as images.
| At a glance | |
|---|---|
| Endpoint | POST /v1/files (multipart) |
| Models | For conversations: nulu-5-ultra and nulu-5-pro (the latter, text only) |
| Protocols | Upload over REST; reference on all three protocols |
| Authentication | Authorization: Bearer <key> |
| Rate limit | 20 uploads per minute per key; above it, 429 with a retry-after header |
| Formats | PDF, DOC, DOCX, PPT, PPTX, PNG, JPEG, WebP, GIF, BMP, TIFF |
| Maximum size | 64 MB and 1,000 pages per file |
| Billing unit | Page parsed, once |
Examples
curl -i https://api.nuluai.com/v1/files \
-H "Authorization: Bearer sk_wat_your_key" \
-F "purpose=text_recognition" \
-F "[email protected]"import requests
API = "https://api.nuluai.com/v1"
HEADERS = {"Authorization": "Bearer sk_wat_your_key"}
# 1. Upload once. The document is parsed during the upload (it can take up to ~2 minutes).
with open("invoice.pdf", "rb") as f:
r = requests.post(
API + "/files",
headers=HEADERS,
data={"purpose": "text_recognition"}, # or "rich_layout_recognition" to keep figures
files={"file": f},
timeout=180,
)
r.raise_for_status()
document = r.json()
print(document["id"], document["pages"], "pages, charged (cents):", r.headers["x-nulu-charge-cents"])
# 2. Reference it by id in as many requests as you need. Its text is billed as input tokens.
r = requests.post(
API + "/chat/completions",
headers=HEADERS,
json={
"model": "nulu-5-ultra",
"max_tokens": 100,
"messages": [{
"role": "user",
"content": [
{"type": "file", "file_id": document["id"]},
{"type": "text", "text": "Who is the customer on this invoice?"},
],
}],
},
timeout=120,
)
print(r.json()["choices"][0]["message"]["content"])import fs from "node:fs";
const API = "https://api.nuluai.com/v1";
const headers = { Authorization: "Bearer sk_wat_your_key" };
// 1. Upload once. The document is parsed during the upload (it can take up to ~2 minutes).
const form = new FormData();
form.append("purpose", "text_recognition"); // or "rich_layout_recognition" to keep figures
form.append("file", new Blob([fs.readFileSync("invoice.pdf")], { type: "application/pdf" }), "invoice.pdf");
const upload = await fetch(API + "/files", { method: "POST", headers, body: form });
if (!upload.ok) throw new Error((await upload.json()).error.message);
const document = await upload.json();
console.log(document.id, document.pages, "pages, charged (cents):", upload.headers.get("x-nulu-charge-cents"));
// 2. Reference it by id in as many requests as you need. Its text is billed as input tokens.
const chat = await fetch(API + "/chat/completions", {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({
model: "nulu-5-ultra",
max_tokens: 100,
messages: [{
role: "user",
content: [
{ type: "file", file_id: document.id },
{ type: "text", text: "Who is the customer on this invoice?" },
],
}],
}),
});
console.log((await chat.json()).choices[0].message.content);HTTP/1.1 200 OK
x-nulu-charge-cents: 0.0675
x-request-id: fc41e814-4c8d-4718-9fa3-ca729d9cbd9e
{
"id": "file-api-947e1f21-0bb2-4ca6-b556-bf5e69fc4333",
"object": "file",
"bytes": 633,
"created_at": 1796335343,
"filename": "invoice.pdf",
"purpose": "text_recognition",
"pages": 1,
"expires_at": 1798927343
}How to reference the file on each protocol is in File input.
Pricing
- $0.675 per 1,000 pages, charged once at upload. Referencing the file later does not charge parsing again.
- Example: a 35-page PDF costs 35 × $0.675 / 1,000 = $0.0236 to upload.
- Model tokens: every request that references the file pays its text as input tokens ($0.45 per 1M on Nulu 5 Ultra; $0.009 when cached). A 20,000-token document with 200 output tokens: 20,000 × $0.45 / 1M + 200 × $1.80 / 1M = $0.00936.
- If parsing fails (unsupported format, damaged file), the upload is rejected and not charged.
- Public price list: www.nuluai.com/pricing
Tracking usage
- The upload response carries
x-nulu-charge-centsand thepagesfield. GET /v1/account/usagegroups parsing undernulu-document-parsing; the dashboard Usage page shows the same.- Consumption in conversations appears as the input tokens of each request (
usage.prompt_tokens).
Known limitations
- At most 64 MB and 1,000 pages per file; up to 20 documents per request.
- The parsed text cannot be downloaded. If you need the text in your own system, use the OCR API.
- The upload is synchronous: wait for the response (up to ~2 min) and use a generous client timeout.
nulu-5-proreceives the text only; the figures ofrich_layout_recognitionneednulu-5-ultra.- Files expire after 30 days at most.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
| 400 "the file format is not supported" | The file is not a recognisable format (PDF, DOC, DOCX, PPT, PPTX, PNG, JPEG, WebP, GIF, BMP, TIFF) or is damaged. For plain text use purpose=user_data. |
404 file_not_found | The referenced id does not exist, expired or belongs to another account. Upload the document again. |
| Client timeout during the upload | Parsing long documents takes time. Use a timeout of 3 minutes or more. |
409 storage_limit | Delete files you no longer use. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- "Chat with your PDF": contracts, manuals, reports.
- Questions about slide decks or office documents without converting them yourself.
- Analysing scanned documents together with their charts (
rich_layout_recognition).
POST /v1/tools/ocr takes a file and returns the recognised text page by page. It stores no file and calls no model: you get the text and decide what to do with it.
purpose=text_recognition returns text only. purpose=rich_layout_recognition keeps the page layout; that text may include position tokens.
| At a glance | |
|---|---|
| Endpoint | POST /v1/tools/ocr (multipart: purpose, file) |
| Models | No model involved |
| Protocols | REST only |
| Authentication | Authorization: Bearer <key> |
| Rate limit | 20 requests per minute per key; above it, 429 with a retry-after header |
| Formats | PDF, DOC, DOCX, PPT, PPTX, PNG, JPEG, WebP, GIF, BMP, TIFF |
| Maximum size | 64 MB and 1,000 pages per file |
| Billing unit | Page recognised |
Examples
curl -i https://api.nuluai.com/v1/tools/ocr \
-H "Authorization: Bearer sk_wat_your_key" \
-F "purpose=text_recognition" \
-F "[email protected]"import requests
API = "https://api.nuluai.com/v1"
HEADERS = {"Authorization": "Bearer sk_wat_your_key"}
with open("scan.png", "rb") as f:
r = requests.post(
API + "/tools/ocr",
headers=HEADERS,
data={"purpose": "text_recognition"}, # or "rich_layout_recognition"
files={"file": f},
timeout=180,
)
r.raise_for_status()
result = r.json()
for page in result["pages"]:
print("page", page["index"], page["finish_reason"])
print(page["text"])
print("pages billed:", r.headers["x-nulu-billed-units"], "| charged (cents):", r.headers["x-nulu-charge-cents"])import fs from "node:fs";
const API = "https://api.nuluai.com/v1";
const headers = { Authorization: "Bearer sk_wat_your_key" };
const form = new FormData();
form.append("purpose", "text_recognition"); // or "rich_layout_recognition"
form.append("file", new Blob([fs.readFileSync("scan.png")], { type: "image/png" }), "scan.png");
const r = await fetch(API + "/tools/ocr", { method: "POST", headers, body: form });
if (!r.ok) throw new Error((await r.json()).error.message);
const result = await r.json();
for (const page of result.pages) {
console.log("page", page.index, page.finish_reason);
console.log(page.text);
}
console.log("pages billed:", r.headers.get("x-nulu-billed-units"), "| charged (cents):", r.headers.get("x-nulu-charge-cents"));HTTP/1.1 200 OK
x-nulu-billed-units: 1 page
x-nulu-charge-cents: 0.0675
{
"id": "ocr-4fb7ad9b-ff4f-4904-868e-2494bf099964",
"object": "ocr.result",
"created": 1796335351,
"purpose": "text_recognition",
"page_count": 1,
"pages": [{
"index": 0,
"text": "RECEIPT No. 20418\n\nCoffee beans 1 kg 18.50\n\nPaper filters x100 4.25\n\nTOTAL 22.75 USD",
"finish_reason": "stop"
}]
}Pricing
- $0.675 per 1,000 pages. An image counts as one page.
- Example: a 120-page scanned PDF costs 120 × $0.675 / 1,000 = $0.081.
- A failed recognition is not charged. There are no model tokens: this API calls no model.
- Public price list: www.nuluai.com/pricing
Tracking usage
- Every successful response carries
x-nulu-charge-cents(what was charged, in US cents) andx-nulu-billed-units(the units billed). GET /v1/account/usagelists every operation and groups it undernulu-ocrinsummary.by_model.- In the dashboard, the Usage page shows the same operations with their cost.
Known limitations
- At most 64 MB and 1,000 pages per file.
- The request is synchronous: long documents can take a couple of minutes.
- Layout text (
rich_layout_recognition) may carry position tokens you may want to filter out. - It returns no per-word coordinates or confidence scores. A
finish_reasonother thanstopmarks an incomplete page.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
| 400 "the file format is not supported" | The file is not a recognisable format (PDF, DOC, DOCX, PPT, PPTX, PNG, JPEG, WebP, GIF, BMP, TIFF) or is damaged. For plain text use purpose=user_data. |
400 "purpose must be…" | purpose is required here: text_recognition or rich_layout_recognition. |
| Empty or garbled text | The image is low resolution or rotated. Send a sharper, upright image. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- Digitising invoices, receipts and forms into your database.
- Indexing scanned documents in your own search engine.
- Preparing text for your own pipeline, with any model.
| Native vision | OCR | Document parsing | |
|---|---|---|---|
| What it does | The model sees the image and answers about it. | Returns the recognised text. No model. | Parses the document once; you then reference it by id in conversations. |
| How | image_url part in the message | POST /v1/tools/ocr | POST /v1/files + file reference |
| You get | A model answer | Text per page | A file id; the text is not downloadable |
| Input | JPEG, PNG, GIF, WebP | PDF, DOC, DOCX, PPT, PPTX, PNG, JPEG, WebP, GIF, BMP, TIFF | PDF, DOC, DOCX, PPT, PPTX, PNG, JPEG, WebP, GIF, BMP, TIFF |
| Billing | Model input tokens | $0.675 per 1,000 pages | $0.675 per 1,000 pages, once; then input tokens |
| Choose it when | The visual content matters: photos, charts, screenshots. | You need the text in your own system. | You want to converse about long documents, repeatedly. |
They can be combined: OCR to keep the text in your database, and document parsing so your users can ask about the same file.
Audio and Voice
POST /v1/tools/tts takes text and returns the audio in the response body. The language is detected from the text. By default Markdown formatting (asterisks, hashes) is removed so it is not read aloud.
| At a glance | |
|---|---|
| Endpoint | POST /v1/tools/tts (JSON) |
| Models | No chat model involved |
| Protocols | REST only |
| Authentication | Authorization: Bearer <key> |
| Rate limit | 30 requests per minute per key; above it, 429 with a retry-after header |
| Languages | Chinese, Cantonese, English, Japanese, Korean, Malay, Arabic, Indonesian, Thai and Vietnamese |
| Streaming | No: the audio arrives complete |
| Billing unit | Character of text |
Examples
| Field | Values | Description |
|---|---|---|
text | string, required | Up to 10,000 billed characters per request. |
voice | stella | tide | Voice. Default stella. |
format | wav | pcm | wav (default) or headerless PCM: 16-bit, mono, 24 kHz. |
filter_markdown | boolean | Default true: strips Markdown formatting before synthesis. |
curl https://api.nuluai.com/v1/tools/tts \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{"text": "Your order has shipped and will arrive on Friday.", "voice": "stella", "format": "wav"}' \
-D headers.txt -o speech.wav
grep -i "x-nulu" headers.txtimport requests
API = "https://api.nuluai.com/v1"
HEADERS = {"Authorization": "Bearer sk_wat_your_key"}
r = requests.post(
API + "/tools/tts",
headers=HEADERS,
json={
"text": "Your order has shipped and will arrive on Friday.",
"voice": "stella", # or "tide"
"format": "wav", # or "pcm" (raw 16-bit mono 24 kHz)
},
timeout=120,
)
r.raise_for_status()
with open("speech.wav", "wb") as f:
f.write(r.content)
print(len(r.content), "bytes,", r.headers["x-nulu-billed-units"], "| charged (cents):", r.headers["x-nulu-charge-cents"])import fs from "node:fs";
const API = "https://api.nuluai.com/v1";
const headers = { Authorization: "Bearer sk_wat_your_key" };
const r = await fetch(API + "/tools/tts", {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({
text: "Your order has shipped and will arrive on Friday.",
voice: "stella", // or "tide"
format: "wav", // or "pcm" (raw 16-bit mono 24 kHz)
}),
});
if (!r.ok) throw new Error((await r.json()).error.message);
const audio = Buffer.from(await r.arrayBuffer());
fs.writeFileSync("speech.wav", audio);
console.log(audio.length, "bytes,", r.headers.get("x-nulu-billed-units"), "| charged (cents):", r.headers.get("x-nulu-charge-cents"));HTTP/1.1 200 OK
content-type: audio/wav
x-nulu-billed-units: 49 characters
x-nulu-charge-cents: 0.33075
<WAV audio: 16-bit PCM, mono, 24 kHz>Pricing
- $0.675 per 10,000 characters
- Promotional price; the standard price is $1.35 for the same quantity.
- Billed characters: wide East Asian characters (Chinese, Japanese, Korean) count 2; all others, including spaces and punctuation, count 1.
- Example: a 2,500-character text costs 2,500 × $0.675 / 10,000 = $0.1688.
- A rejected request (blocked text, invalid parameters) or a failed one is not charged. There are no model tokens.
- Public price list: www.nuluai.com/pricing
Tracking usage
- Every successful response carries
x-nulu-charge-cents(what was charged, in US cents) andx-nulu-billed-units(the units billed). GET /v1/account/usagelists every operation and groups it undernulu-ttsinsummary.by_model.- In the dashboard, the Usage page shows the same operations with their cost.
Known limitations
- Spanish is not on the list of supported languages. Spanish text is synthesised and intelligible, but pronunciation quality is not guaranteed: test it with your content before shipping.
- At most 10,000 billed characters per request; split long texts by paragraph.
- No streaming synthesis: the audio is delivered complete when it is ready.
- Two voices (
stella,tide) and two formats (wav,pcm); no MP3 and no speed control.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
400 content_filter | The text was blocked by the content filter. It is not charged. |
400 "text is required, up to 10000…" | The text is empty or over the limit. Split it. |
400 "voice must be one of…" / "format must be…" | Use stella or tide, and wav or pcm. |
| The PCM file does not play | PCM has no header: tell the player 16-bit, mono, 24,000 Hz, or ask for wav. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- Reading an assistant's answers aloud.
- Voice prompts and notifications in an application.
- Audio versions of articles or lessons.
POST /v1/tools/stt takes an audio file and returns its transcription and duration. The language is detected automatically among 21 languages, including Spanish, English, Portuguese, French, German, Italian, Chinese, Japanese, Korean, Russian, Arabic and Hindi.
| At a glance | |
|---|---|
| Endpoint | POST /v1/tools/stt (multipart: file) |
| Models | No chat model involved |
| Protocols | REST only |
| Authentication | Authorization: Bearer <key> |
| Rate limit | 30 requests per minute per key; above it, 429 with a retry-after header |
| Accepted audio | 16-bit PCM WAV or Ogg Opus; up to 8 MB and 120 s |
| Streaming | No |
| Billing unit | Second of audio, rounded up |
Examples
curl -i https://api.nuluai.com/v1/tools/stt \
-H "Authorization: Bearer sk_wat_your_key" \
-F "[email protected]"import requests
API = "https://api.nuluai.com/v1"
HEADERS = {"Authorization": "Bearer sk_wat_your_key"}
with open("speech.wav", "rb") as f:
r = requests.post(API + "/tools/stt", headers=HEADERS, files={"file": f}, timeout=120)
r.raise_for_status()
result = r.json()
print(result["text"])
print(result["duration_ms"], "ms |", r.headers["x-nulu-billed-units"], "| charged (cents):", r.headers["x-nulu-charge-cents"])import fs from "node:fs";
const API = "https://api.nuluai.com/v1";
const headers = { Authorization: "Bearer sk_wat_your_key" };
const form = new FormData();
form.append("file", new Blob([fs.readFileSync("speech.wav")], { type: "audio/wav" }), "speech.wav");
const r = await fetch(API + "/tools/stt", { method: "POST", headers, body: form });
if (!r.ok) throw new Error((await r.json()).error.message);
const result = await r.json();
console.log(result.text);
console.log(result.duration_ms, "ms |", r.headers.get("x-nulu-billed-units"), "| charged (cents):", r.headers.get("x-nulu-charge-cents"));HTTP/1.1 200 OK
x-nulu-billed-units: 3 seconds
x-nulu-charge-cents: 0.0145
{
"object": "transcription",
"text": "Your order has shipped and will arrive on Friday.",
"duration_ms": 2760
}Pricing
- $0.174 per hour of audio, billed per second and rounded up to the second.
- Promotional price; the standard price is $0.348 for the same quantity.
- Example: a 90-second clip costs 90 × $0.174 / 3,600 = $0.00435; a 2.76 s clip is billed as 3 seconds.
- A failed transcription or a rejected file is not charged. There are no model tokens.
- Public price list: www.nuluai.com/pricing
Tracking usage
- Every successful response carries
x-nulu-charge-cents(what was charged, in US cents) andx-nulu-billed-units(the units billed). GET /v1/account/usagelists every operation and groups it undernulu-sttinsummary.by_model.- In the dashboard, the Usage page shows the same operations with their cost.
Known limitations
- At most 120 seconds and 8 MB per file: split long recordings.
- Only 16-bit PCM WAV or Ogg Opus. Convert MP3, M4A or WebM first (for example with ffmpeg).
- It returns plain text: no timestamps, no speaker separation, and no way to choose the language.
- No real-time transcription.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
400 unsupported_audio | The file is not 16-bit PCM WAV or Ogg Opus. Convert it to 16-bit mono WAV (16 or 24 kHz both work) before sending it. |
| Empty transcription | The audio has no audible speech or the volume is very low. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- Voice notes and audio messages in a chat.
- Voice input for an assistant: speech → text → model → text to speech.
- Transcribing short answers in forms or surveys.
Build an AI Chatbot
Keep the messages in your own database. On each turn append the user message, call the API, and append the assistant turn to the history exactly as it arrived.
from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
messages = [{"role": "system", "content": "You are a concise assistant."}]
def ask(text):
messages.append({"role": "user", "content": text})
response = client.chat.completions.create(model="nulu-5-ultra", messages=messages, max_tokens=100)
messages.append(response.choices[0].message) # keep the assistant turn in the history
return response.choices[0].message.content
print(ask("What is the highest mountain on Earth?"))
print(ask("And the second highest?")) # the model sees the whole historyimport OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const messages = [{ role: "system", content: "You are a concise assistant." }];
async function ask(text) {
messages.push({ role: "user", content: text });
const response = await client.chat.completions.create({ model: "nulu-5-ultra", messages, max_tokens: 100 });
messages.push(response.choices[0].message); // keep the assistant turn in the history
return response.choices[0].message.content;
}
console.log(await ask("What is the highest mountain on Earth?"));
console.log(await ask("And the second highest?")); // the model sees the whole history- Every request pays for the whole history as input tokens. Context caching makes the repeated prefix cheaper; for very long conversations, summarise or trim old turns.
- Keep the system prompt identical between turns to benefit from the cache.
- There are no conversation ids on the server: on Responses,
previous_response_idandconversationreturn 400. - Store the complete assistant turn (not only the text) if you use functions or web tools: see Multi-turn tool usage.
Send stream: true. The response arrives as data: events (Server-Sent Events); each carries a fragment in choices[0].delta.content. The stream ends with data: [DONE].
curl -N https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"max_tokens": 100,
"stream": true,
"stream_options": {"include_usage": true},
"messages": [{"role": "user", "content": "Count from one to five in words."}]
}'from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
stream = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=100,
stream=True,
stream_options={"include_usage": True}, # adds a final chunk with usage
messages=[{"role": "user", "content": "Count from one to five in words."}],
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
if chunk.usage:
print("\ntokens:", chunk.usage.prompt_tokens, "+", chunk.usage.completion_tokens)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const stream = await client.chat.completions.create({
model: "nulu-5-ultra",
max_tokens: 100,
stream: true,
stream_options: { include_usage: true }, // adds a final chunk with usage
messages: [{ role: "user", content: "Count from one to five in words." }],
});
for await (const chunk of stream) {
const text = chunk.choices[0]?.delta?.content;
if (text) process.stdout.write(text);
if (chunk.usage) console.log("\ntokens:", chunk.usage.prompt_tokens, "+", chunk.usage.completion_tokens);
}data: {"id":"be281a01-...","object":"chat.completion.chunk","model":"nulu-5-ultra","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}],"usage":null}
data: {"id":"be281a01-...","object":"chat.completion.chunk","model":"nulu-5-ultra","choices":[{"index":0,"delta":{"content":"One"},"finish_reason":null}],"usage":null}
data: {"id":"be281a01-...","object":"chat.completion.chunk","model":"nulu-5-ultra","choices":[{"index":0,"delta":{"content":""},"finish_reason":"stop"}],"usage":{"prompt_tokens":237,"completion_tokens":10,"total_tokens":247}}
data: [DONE]from anthropic import Anthropic
client = Anthropic(api_key="sk_wat_your_key", base_url="https://api.nuluai.com")
with client.messages.stream(
model="nulu-5-ultra",
max_tokens=100,
messages=[{"role": "user", "content": "Count from one to five in words."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
usage = stream.get_final_message().usage
print("\ntokens:", usage.input_tokens, "+", usage.output_tokens)from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
stream = client.responses.create(
model="nulu-5-ultra",
max_output_tokens=100,
stream=True,
input="Count from one to five in words.",
)
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
elif event.type == "response.completed":
print("\ntokens:", event.response.usage.input_tokens, "+", event.response.usage.output_tokens)- The last chunk carries
finish_reasonandusage. With the SDKs, ask forstream_options: {"include_usage": true}to receive it. - With thinking on, the reasoning arrives before the text in
delta.reasoning_content. - Lines that start with
:(for example: keep-alive) are SSE comments: ignore them. - Streaming costs the same as a complete response: the same tokens are billed.
- Always stream deep thinking search and long answers: non-streaming requests are limited to ~95 s.
When the model searches the web, the response carries message.annotations. Each citation gives a URL, its title and the span of text it supports: start_index (inclusive) and end_index (exclusive) are character positions in message.content.
"annotations": [{
"type": "url_citation",
"url_citation": {
"url": "https://docs.python.org/3/whatsnew/3.13.html",
"title": "What's New In Python 3.13",
"start_index": 0,
"end_index": 45
}
}]from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
response = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=300,
tools=[{"type": "web_search"}],
messages=[{"role": "user", "content": "When was Python 3.13 released? One sentence."}],
)
message = response.choices[0].message
text = message.content
# Each annotation marks the span of the answer [start_index, end_index) that a source supports.
# Insert numbered markers from the end of the text so earlier offsets stay valid.
sources = []
for annotation in sorted(message.annotations or [], key=lambda a: a.url_citation.end_index, reverse=True):
citation = annotation.url_citation
if citation.url not in sources:
sources.append(citation.url)
marker = " [" + str(sources.index(citation.url) + 1) + "]"
text = text[:citation.end_index] + marker + text[citation.end_index:]
print(text)
for number, url in enumerate(sources, start=1):
print("[" + str(number) + "]", url)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const response = await client.chat.completions.create({
model: "nulu-5-ultra",
max_tokens: 300,
tools: [{ type: "web_search" }],
messages: [{ role: "user", content: "When was Python 3.13 released? One sentence." }],
});
const message = response.choices[0].message;
let text = message.content;
// Each annotation marks the span of the answer [start_index, end_index) that a source supports.
// Insert numbered markers from the end of the text so earlier offsets stay valid.
const sources = [];
const citations = (message.annotations ?? []).map((a) => a.url_citation);
for (const citation of citations.sort((a, b) => b.end_index - a.end_index)) {
if (!sources.includes(citation.url)) sources.push(citation.url);
const marker = " [" + (sources.indexOf(citation.url) + 1) + "]";
text = text.slice(0, citation.end_index) + marker + text.slice(citation.end_index);
}
console.log(text);
sources.forEach((url, index) => console.log("[" + (index + 1) + "]", url));- Insert the markers from the end of the text backwards so earlier positions stay valid.
- When streaming, citations arrive complete on the last chunk (
delta.annotations): show the text first and add the citations at the end. - Responses delivers them in
output_text.annotations; Messages, incitationson each text block (andcitations_deltawhile streaming). - All consulted sources, cited or not, are in
server_tool_calls[].calls[].sources. - An answer without a search has no citations: treat
annotationsas optional. Citations have no cost of their own.
Send title: {"enabled": true} on the first request of a conversation. The response includes a short title for your chat list. No second model call is needed.
| At a glance | |
|---|---|
| Models | nulu-5-ultra, nulu-5-pro |
| Chat Completions | message.title; when streaming, delta.title on the last chunk |
| Messages | top-level title; when streaming, message_delta.delta.title |
| Responses | top-level title |
| Authentication | Authorization: Bearer <key> (Messages also accepts x-api-key) |
| Rate limit | 120 model requests per minute per key; above it, 429 with a retry-after header |
| Billing unit | Free |
Examples
curl https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"max_tokens": 100,
"title": {"enabled": true},
"messages": [{"role": "user", "content": "How do I bake sourdough bread at home? Two sentences."}]
}'from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
question = "How do I bake sourdough bread at home? Two sentences."
response = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=100,
messages=[{"role": "user", "content": question}],
extra_body={"title": {"enabled": True}}, # first request of a conversation only
)
message = response.choices[0].message
title = getattr(message, "title", None) or question[:40] # the title can be absent: fall back
print("title:", title)
print(message.content)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const question = "How do I bake sourdough bread at home? Two sentences.";
const response = await client.chat.completions.create({
model: "nulu-5-ultra",
max_tokens: 100,
messages: [{ role: "user", content: question }],
title: { enabled: true }, // first request of a conversation only
});
const message = response.choices[0].message;
const title = message.title ?? question.slice(0, 40); // the title can be absent: fall back
console.log("title:", title);
console.log(message.content);{
"choices": [{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "Mix flour, water, salt and an active starter ...",
"title": "Sourdough baking steps"
}
}]
}Pricing
- The title is free: it adds no charge and no billed tokens to the request.
- The request itself is billed as usual, by its input and output tokens. Example: a request costs the same with or without a title.
- A rejected request (4xx) is not charged.
- Public price list: www.nuluai.com/pricing
Tracking usage
- The cost is in the tokens:
usage.prompt_tokens(input) andusage.completion_tokens(output) of the same response. GET /v1/account/usagereturns every request with its tokens andcharge_usd; the dashboard Usage page shows the same.
Known limitations
- The title can be absent (for example, when the answer was a refusal or an error occurred): fall back to the start of the first message.
- Ask for it on the first request only; later it is not needed and the title could change.
- The length and style of the title cannot be set.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
title is missing from the response | Check that you sent title: {"enabled": true} (in the Python SDK, inside extra_body) and apply the fallback. |
| No title while streaming | It arrives on the last chunk, with finish_reason. Read delta.title there. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- The conversation list of a chat application.
- Automatic subjects for tickets or notes.
The model does not know what day it is or where the user is. The marker is a message with role: "latest_reminder" placed directly before the user message it belongs to. Its content is five comma-separated fields: <date>,<weekday>,<location>,<platform>,<language>.
Privacy: Nulu AI does not add a location by itself and does not derive one from the connection. The model knows the location only if your application sends it in the marker, and it is not stored beyond the normal request logs. Send it only with the user's consent; the field may be empty.
| At a glance | |
|---|---|
| Models | nulu-5-ultra, nulu-5-pro |
| Protocols | Chat Completions and Messages. Not available on Responses. |
| Authentication | Authorization: Bearer <key> (Messages also accepts x-api-key) |
| Rate limit | 120 model requests per minute per key; above it, 429 with a retry-after header |
| Billing unit | Model input tokens (a few) |
Examples
| Field | Format | Example |
|---|---|---|
| Date | YYYY-MM-DD | 2026-12-03 |
| Weekday | The weekday of that date, written in the marker language and capitalised | Thursday / Jueves |
| Location | Free text, optional (may be empty) | Caracas |
| Platform | App | Web | Web |
| Language | Native name of the user's language | English / español |
curl https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"max_tokens": 100,
"messages": [
{"role": "latest_reminder", "content": "2026-12-03,Jueves,Caracas,Web,español"},
{"role": "user", "content": "What day is it today, and where am I?"}
]
}'from datetime import date
from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
today = date.today()
# <date>,<weekday>,<location>,<platform>,<language>. Location is optional: leave it empty
# unless your user agreed to share it. Nulu AI never adds a location by itself.
marker = ",".join([today.isoformat(), today.strftime("%A"), "", "Web", "English"])
response = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=100,
messages=[
{"role": "latest_reminder", "content": marker}, # directly before the user message
{"role": "user", "content": "What is today's date?"},
],
)
print(marker)
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const now = new Date();
// <date>,<weekday>,<location>,<platform>,<language>. Location is optional: leave it empty
// unless your user agreed to share it. Nulu AI never adds a location by itself.
const marker = [
now.toISOString().slice(0, 10),
now.toLocaleDateString("en-US", { weekday: "long", timeZone: "UTC" }),
"",
"Web",
"English",
].join(",");
const response = await client.chat.completions.create({
model: "nulu-5-ultra",
max_tokens: 100,
messages: [
{ role: "latest_reminder", content: marker }, // directly before the user message
{ role: "user", content: "What is today's date?" },
],
});
console.log(marker);
console.log(response.choices[0].message.content);from anthropic import Anthropic
client = Anthropic(api_key="sk_wat_your_key", base_url="https://api.nuluai.com")
message = client.messages.create(
model="nulu-5-ultra",
max_tokens=100,
messages=[
{"role": "latest_reminder", "content": "2026-12-03,Thursday,,App,English"},
{"role": "user", "content": "What is today's date?"},
],
)
print(message.content[0].text)Pricing
- No charge of its own: the marker adds about 15–25 input tokens to the request ($0.45 per 1M on Nulu 5 Ultra).
- Example: 20 extra input tokens cost 20 × $0.45 / 1M + 0 × $1.80 / 1M = $0.000009.
- A marker with an invalid format returns 400 and is not charged.
- Public price list: www.nuluai.com/pricing
Tracking usage
- The cost is in the tokens:
usage.prompt_tokens(input) andusage.completion_tokens(output) of the same response. GET /v1/account/usagereturns every request with its tokens andcharge_usd; the dashboard Usage page shows the same.
Known limitations
- It does not work on the Responses protocol.
- The weekday must match the date and be written in the stated language; if it does not, the request is rejected and the error message states the expected value.
- The language is given by its native name. Verified:
English(withThursday) andespañol(withJueves). An unknown name returns 400. - It goes directly before the user message it refers to; on each new turn send an updated marker.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
| 400 "unknown language …" | Use the native name of the language: English, español. |
| 400 "weekday … does not match date" | Compute the weekday from the date and write it in the marker language (the error states the expected value). |
| 400 "unknown platform …" | The platform can only be App or Web. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- Making "today", "tomorrow" or "this week" mean the right thing.
- Current-events web searches with the real date.
- Local answers (weather, opening hours, currency) when the user shares their city.
Every request goes through the basic checks (level: "low"). With safety_check: {"level": "high"} you ask for a stricter review of the input and of the answer, meant for products open to the public.
If the input is blocked, the request returns 400 content_filter and is not charged. If the output is blocked, the answer ends as a refusal; text already streamed is not withdrawn.
| At a glance | |
|---|---|
| Models | nulu-5-ultra, nulu-5-pro |
| Chat Completions | Blocked output: finish_reason: "content_filter" (and message.refusal when images were blocked) |
| Messages | Blocked output: stop_reason: "refusal" |
| Responses | Blocked output: status: "incomplete", incomplete_details.reason: "content_filter" |
| Authentication | Authorization: Bearer <key> (Messages also accepts x-api-key) |
| Rate limit | 120 model requests per minute per key; above it, 429 with a retry-after header |
| Billing unit | Model output tokens |
Examples
curl https://api.nuluai.com/v1/chat/completions \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-5-ultra",
"max_tokens": 100,
"safety_check": {"level": "high"},
"messages": [{"role": "user", "content": "Give me three tips for a safe hiking trip."}]
}'import openai
from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
def moderated_reply(text):
try:
response = client.chat.completions.create(
model="nulu-5-ultra",
max_tokens=100,
messages=[{"role": "user", "content": text}],
extra_body={"safety_check": {"level": "high"}},
)
except openai.BadRequestError as error:
if error.code == "content_filter": # the input was blocked: nothing was charged
return "Sorry, I can't help with that request."
raise
choice = response.choices[0]
if choice.finish_reason == "content_filter": # the answer was cut by the output check
return (choice.message.content or "") + " [answer withheld]"
return choice.message.content
print(moderated_reply("Give me three tips for a safe hiking trip."))import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
async function moderatedReply(text) {
let response;
try {
response = await client.chat.completions.create({
model: "nulu-5-ultra",
max_tokens: 100,
messages: [{ role: "user", content: text }],
safety_check: { level: "high" },
});
} catch (error) {
if (error.code === "content_filter") return "Sorry, I can't help with that request."; // input blocked, not charged
throw error;
}
const choice = response.choices[0];
if (choice.finish_reason === "content_filter") return (choice.message.content ?? "") + " [answer withheld]";
return choice.message.content;
}
console.log(await moderatedReply("Give me three tips for a safe hiking trip."));// Input blocked: HTTP 400, nothing is charged
{"error": {"message": "...", "type": "invalid_request_error", "code": "content_filter"}}
// Output blocked: HTTP 200, the answer ends as a refusal
{"choices": [{"index": 0, "finish_reason": "content_filter", "message": {"role": "assistant", "content": "..."}}],
"usage": {"prompt_tokens": 239, "completion_tokens": 100, "total_tokens": 339,
"completion_tokens_details": {"reasoning_tokens": 0, "safety_tokens": 12}}}Pricing
- No charge of its own: the review tokens are billed as output tokens ($1.80 per 1M on Nulu 5 Ultra) and are reported in
usage.completion_tokens_details.safety_tokens. - Example: an answer with 300 input tokens and 100 output tokens, plus 12 review tokens: 300 × $0.45 / 1M + 112 × $1.80 / 1M = $0.0003366.
- A request blocked on input (400
content_filter) is not charged. An answer blocked on output is billed for what was generated up to that point. - Public price list: www.nuluai.com/pricing
Tracking usage
usage.completion_tokens_details.safety_tokensreports the review tokens of each request.GET /v1/account/usagereturns every request with its tokens andcharge_usd; the dashboard Usage page shows the same.
Known limitations
- Two levels only:
low(default) andhigh. There are no configurable categories. - When streaming, text already sent is not withdrawn when the output is blocked: your interface must hide or flag it on
finish_reason: "content_filter". - It does not replace your own product rules, or human moderation where the law requires it.
Common errors and troubleshooting
| Error or symptom | What to do |
|---|---|
400 content_filter | The input was blocked. Show the user a neutral message; do not retry with the same text. |
finish_reason: "content_filter" | The output was blocked. Treat the answer as incomplete. |
400 "level must be low or high" | Fix the value of safety_check.level. |
401 invalid_api_key | The key is missing, mistyped or revoked. Check the Authorization header. |
402 insufficient_credit | The balance is below $0.50. Add balance in the dashboard; do not retry. |
| 429 | You went over the per-minute limit. Wait the retry-after seconds and retry. |
Use cases
- Chats open to the public or used by minors.
- Generated content that is published without human review.
- Regulated sectors that require an extra control.
One rule: send the assistant turn back exactly as it arrived. Do not rebuild it from the text. Keep server_tool_calls (or the tool blocks on Messages and Responses) with every id, signature and encrypted_content, plus tool_calls and reasoning_content when present.
from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
tools = [{"type": "web_search"}]
messages = [{"role": "user", "content": "Who maintains the Python programming language? One sentence."}]
first = client.chat.completions.create(model="nulu-5-ultra", messages=messages, tools=tools, max_tokens=200)
# Echo the assistant turn exactly as it arrived: content, annotations and server_tool_calls
# with every id and signature. Do not rebuild it from the text.
messages.append(first.choices[0].message.model_dump(exclude_none=True))
messages.append({"role": "user", "content": "In which year was it founded? Answer with the year."})
second = client.chat.completions.create(model="nulu-5-ultra", messages=messages, tools=tools, max_tokens=200)
print(first.choices[0].message.content)
print(second.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk_wat_your_key", baseURL: "https://api.nuluai.com/v1" });
const tools = [{ type: "web_search" }];
const messages = [{ role: "user", content: "Who maintains the Python programming language? One sentence." }];
const first = await client.chat.completions.create({ model: "nulu-5-ultra", messages, tools, max_tokens: 200 });
// Echo the assistant turn exactly as it arrived: content, annotations and server_tool_calls
// with every id and signature. Do not rebuild it from the text.
messages.push(first.choices[0].message);
messages.push({ role: "user", content: "In which year was it founded? Answer with the year." });
const second = await client.chat.completions.create({ model: "nulu-5-ultra", messages, tools, max_tokens: 200 });
console.log(first.choices[0].message.content);
console.log(second.choices[0].message.content);from anthropic import Anthropic
client = Anthropic(api_key="sk_wat_your_key", base_url="https://api.nuluai.com")
tools = [{"type": "web_search", "name": "web_search"}]
messages = [{"role": "user", "content": "Who maintains the Python programming language? One sentence."}]
first = client.messages.create(model="nulu-5-ultra", max_tokens=200, tools=tools, messages=messages)
# Send every content block back unchanged (server_tool_use, web_search_tool_result, text + citations).
messages.append({"role": "assistant", "content": [block.model_dump(exclude_none=True) for block in first.content]})
messages.append({"role": "user", "content": "In which year was it founded? Answer with the year."})
second = client.messages.create(model="nulu-5-ultra", max_tokens=200, tools=tools, messages=messages)
print("".join(block.text for block in second.content if block.type == "text"))- From earlier turns with a search, the model re-reads only the answer text, not the results: the history does not grow with every search.
- Pages read with
read_urlare restored from theirsignature, without downloading them again. If you alter or drop the signature, the page is no longer available to the model. - Store the complete JSON of the assistant turn in your database, not only
content. - Declare the same tools in
toolson every turn of the conversation. - With your own functions: every
tool_calls[].idneeds itsrole: "tool"message with the sametool_call_idbefore the next user turn.
API Reference
| Endpoint | Purpose | Billing |
|---|---|---|
POST /v1/chat/completions | Chat (Chat Completions protocol). All chat models. | Tokens |
POST /v1/responses | Chat (Responses protocol). | Tokens |
POST /v1/messages | Chat (Messages protocol). | Tokens |
GET /v1/models | Models available to the key. | Free |
POST /v1/tools/search | Web search as JSON. | Per successful request |
POST /v1/tools/fetch | Web page to Markdown. | Per successful request |
POST /v1/tools/ocr | Text from images and documents. | Per page |
POST /v1/tools/tts | Text to speech. | Per character |
POST /v1/tools/stt | Speech to text. | Per second |
POST /v1/files | Upload a file (and parse it, depending on purpose). | Per parsed page; user_data free |
GET /v1/files, GET /v1/files/{id}, DELETE /v1/files/{id} | List, read and delete files. | Free |
POST /v1/images/generations | Generate images (JSON). | Per image |
POST /v1/images/edits | Edit images (multipart). | Per image |
GET /v1/account | Account and balance of the key. | Free |
GET /v1/account/usage | Usage history and totals. | Free |
GET /v1/pricing | Prices in force and peak-hour status. Public, no key. | Free |
Chat Completions
| Field | Required | Description |
|---|---|---|
model | Yes | Public model id. |
messages | Yes | Messages with role (system, user, assistant, tool, latest_reminder) and content (text or text, image_url, file parts). |
max_tokens | No | Maximum generated tokens, reasoning included. |
temperature | No | Randomness. Typical range: 0 to 2. |
top_p | No | Nucleus sampling. Use this or temperature. |
stream | No | true returns SSE events. |
stream_options | No | {"include_usage": true} adds usage at the end of the stream. |
reasoning_effort | No | low, medium, high or max. Turns thinking on. |
thinking | No | {"type": "enabled"} or {"type": "disabled"}. Off by default. |
response_format | No | {"type": "json_object"} for JSON output. |
tools | No | Functions ({"type": "function", …}) and server tools ({"type": "web_search"}, {"type": "read_url"}). |
tool_choice | No | For your own functions only; it cannot force server tools. |
title | No | {"enabled": true} asks for a conversation title. |
safety_check | No | {"level": "high"} for the reinforced review; low by default. |
Differences on Responses and Messages
| Concept | Chat Completions | Responses | Messages |
|---|---|---|---|
| Input | messages | input (text or list of messages) | messages (+ separate system) |
| Output limit | max_tokens | max_output_tokens | max_tokens (required) |
| Thinking | reasoning_effort / thinking | reasoning.effort | thinking |
| Web search | {"type": "web_search"} | {"type": "web_search"} | {"type": "web_search", "name": "web_search"} |
| File | {"type": "file", "file_id"} | {"type": "input_file", "file_id"} | {"type": "document", "source": {"type": "file", "file_id"}} |
| Image | image_url | input_image | image block |
| Not supported | — | previous_response_id, conversation, background | — |
The parameters of each standalone API (search, fetch, OCR, speech, files) are in its own section. Unknown fields on those APIs return 400 unsupported_parameter.
{
"id": "250147e1-ee9e-468d-becb-c9d678ef809a",
"object": "chat.completion",
"created": 1796335292,
"model": "nulu-5-ultra",
"choices": [{
"index": 0,
"finish_reason": "stop", // stop | length | tool_calls | content_filter
"message": {
"role": "assistant",
"content": "...",
"reasoning_content": "...", // only with thinking on
"tool_calls": [ ... ], // only when the model asks for your functions
"annotations": [ ... ], // citations, only after a web search
"server_tool_calls": [ ... ], // web_search / read_url activity
"title": "...", // only with title.enabled
"refusal": "..." // only when images were blocked by content safety
}
}],
"usage": {
"prompt_tokens": 8028,
"completion_tokens": 46,
"total_tokens": 8074,
"prompt_tokens_details": {"cached_tokens": 0},
"completion_tokens_details": {"reasoning_tokens": 0, "safety_tokens": 0},
"server_tool_use": {"tool_search": 3, "tool_fetch": 0, "tool_image_search": 0}
}
}| Object | Fields |
|---|---|
Responses (object: "response") | status (completed | incomplete), incomplete_details, output[] (reasoning, web_search_call, message with content[].text and annotations), title, usage (input_tokens, output_tokens, input_tokens_details.cached_tokens, output_tokens_details.reasoning_tokens). |
Messages (type: "message") | content[] (thinking, text with citations, tool_use, server_tool_use, web_search_tool_result blocks), stop_reason (end_turn | max_tokens | tool_use | refusal), title, usage (input_tokens, output_tokens, cache_read_input_tokens). |
search.result | query, results[]: title, url, snippet, summary, content, site_name, site_icon, date, authority, rerank_score |
fetch.result | url, title, content (Markdown) |
ocr.result | id, created, purpose, page_count, pages[]: index, text, finish_reason |
transcription | text, duration_ms |
file | id, bytes, created_at, filename, purpose, pages (when parsed), expires_at |
server_tool_calls[].calls[] | id, type (web_search | read_url), kind (search | deep_search | image_search | read_link), action, status (completed | failed), and depending on the case sources[], page, signature or error.code. |
Headers: the standalone APIs and file uploads return x-nulu-charge-cents; the standalone APIs also return x-nulu-billed-units. x-request-id identifies the request for support.
| Protocol | Events |
|---|---|
| Chat Completions | data: lines with chat.completion.chunk objects: delta.content, delta.reasoning_content, delta.tool_calls; choices[0].server_tool_event (call_started, call_completed, step_reasoning_done) during server tools. The last chunk carries finish_reason, usage, delta.annotations, delta.server_tool_calls and delta.title. Ends with data: [DONE]. |
| Responses | response.created, response.in_progress, response.output_item.added, response.content_part.added, response.output_text.delta, response.output_text.done, response.content_part.done, response.output_item.done, response.completed (with usage). With web search: response.web_search_call.* and response.output_text.annotation.added. |
| Messages | message_start, content_block_start, content_block_delta (text, thinking, citations_delta), content_block_stop, message_delta (with stop_reason, usage and delta.title), message_stop, and an occasional ping. Server tools arrive as content blocks. |
Code samples are in Streaming responses and in Web search.
// Chat Completions, Responses and every /v1/tools and /v1/files endpoint
{"error": {"message": "Unsupported parameter: foo.", "type": "invalid_request_error", "code": "unsupported_parameter"}}
// Messages
{"type": "error", "error": {"type": "invalid_request_error", "message": "`max_tokens` is required."}}| HTTP | `code` | Meaning | Retry? |
|---|---|---|---|
| 400 | provider_rejected_request / — | Invalid JSON or invalid parameters. The message says which. | No |
| 400 | unsupported_parameter | Unsupported field (for example previous_response_id, or an unknown field on a standalone API). | No |
| 400 | unsupported_tool | Web tool with a model other than nulu-5-ultra. | No |
| 400 | unsupported_tool_choice | tool_choice tries to force a server tool. | No |
| 400 | content_filter | Input blocked by content safety. Not charged. | No |
| 400 | invalid_url | Malformed URL (Fetch API). | No |
| 400 | unsupported_audio | Audio that is not 16-bit PCM WAV or Ogg Opus. | No |
| 401 | invalid_api_key | Missing, invalid or revoked key. | No |
| 402 | insufficient_credit | Balance below $0.50. | No: add balance |
| 403 | url_not_allowed | Private, internal or blocked address. | No |
| 404 | file_not_found | File missing, expired or owned by another account. | No |
| 404 | url_not_accessible | Page unreachable, behind a sign-in or without readable content. | Maybe later |
| 404 | — | Model not available: use an id from GET /v1/models. | No |
| 409 | storage_limit | File or storage limit reached. | After deleting files |
| 411 | — | Upload without Content-Length. | With a buffer or file |
| 429 | — | Per-minute limit exceeded. See retry-after. | Yes, after retry-after |
| 5xx | — | Temporary failure while processing the request. Not charged. | Yes, with backoff |
import time
import openai
from openai import OpenAI
client = OpenAI(api_key="sk_wat_your_key", base_url="https://api.nuluai.com/v1")
def complete(messages, attempts=3):
for attempt in range(attempts):
try:
return client.chat.completions.create(model="nulu-5-ultra", messages=messages, max_tokens=50)
except openai.RateLimitError as error: # 429: wait for the retry-after header
time.sleep(float(error.response.headers.get("retry-after", 2)))
except openai.APIStatusError as error:
if error.status_code == 402: # insufficient_credit: do not retry
raise RuntimeError("Add balance in the dashboard") from error
if error.status_code < 500: # 400 / 401 / 404: fix the request, do not retry
raise
time.sleep(2 ** attempt) # 5xx: retry with backoff
raise RuntimeError("The request kept failing")
print(complete([{"role": "user", "content": "Say OK."}]).choices[0].message.content)
try: # the Responses protocol is stateless: stored conversations are refused
client.responses.create(model="nulu-5-ultra", input="hi", previous_response_id="resp_123")
except openai.APIStatusError as error:
print(error.status_code, error.code, "-", error.body["message"])- Retries: there are no idempotency keys. A failed operation is never charged, so retrying after an error is safe; repeating a request that succeeded is a new billable request.
- Not every 400 error carries a
code: branch on the HTTP status and log themessage. - Inside a successful response a server tool can fail on its own: check the
statusanderror.codeof each call (url_not_accessible,url_not_allowed,unavailable).
| Endpoint | Limit per key |
|---|---|
/v1/chat/completions, /v1/responses, /v1/messages | 120 requests per minute |
/v1/tools/search | 120 per minute |
/v1/tools/fetch | 60 per minute |
/v1/tools/ocr | 20 per minute |
/v1/tools/tts | 30 per minute |
/v1/tools/stt | 30 per minute |
POST /v1/files | 20 uploads per minute |
/v1/account, /v1/account/usage | 60 per minute |
- Above a limit the API answers 429 with a
retry-afterheader (seconds). Wait that long before retrying. - Requests rejected with 429 are not charged.
- Other limits: 500 files and 2 GB stored per account; 20 documents per request; non-streaming requests up to ~95 s.
- Need more? Write to support from the dashboard.
| Where | What it shows |
|---|---|
usage on every model response | Input, output, cached (prompt_tokens_details.cached_tokens), reasoning and review tokens (completion_tokens_details), and server_tool_use with the number of searches and page reads. |
x-nulu-charge-cents and x-nulu-billed-units headers | On the standalone APIs: what that operation was charged (US cents) and the units billed (1 request, 3 seconds, 49 characters). |
GET /v1/account/usage | Every billed request with its tokens and charge_usd, the totals of the period and the breakdown per model or tool. |
| Dashboard → Usage | The same, with filters and charts: https://platform.nuluai.com/dashboard/usage |
GET /v1/account | Current balance (balance_usd) and whether the key can use the API (can_use_api). |
curl "https://api.nuluai.com/v1/account/usage?limit=5" \
-H "Authorization: Bearer sk_wat_your_key"import requests
API = "https://api.nuluai.com/v1"
HEADERS = {"Authorization": "Bearer sk_wat_your_key"}
r = requests.get(API + "/account/usage", headers=HEADERS, params={"limit": 5}, timeout=30)
r.raise_for_status()
usage = r.json()
for row in usage["data"]:
print(row["created_at"], row["model"], row["status"], row["charge_usd"])
for entry in usage["summary"]["by_model"]:
print(entry["model"], entry["requests"], "requests,", entry["charge_usd"], "USD")
print("total:", usage["summary"]["charge_usd"], usage["currency"])const API = "https://api.nuluai.com/v1";
const headers = { Authorization: "Bearer sk_wat_your_key" };
const r = await fetch(API + "/account/usage?limit=5", { headers });
if (!r.ok) throw new Error((await r.json()).error.message);
const usage = await r.json();
for (const row of usage.data) console.log(row.created_at, row.model, row.status, row.charge_usd);
for (const entry of usage.summary.by_model) {
console.log(entry.model, entry.requests, "requests,", entry.charge_usd, "USD");
}
console.log("total:", usage.summary.charge_usd, usage.currency);{
"object": "list",
"since": "2026-11-03T21:54:43.988Z",
"until": "2026-12-03T21:54:43.988Z",
"data": [{
"request_id": "b3269171-c360-42ae-8bcd-b971cf620e26",
"created_at": "2026-12-03T21:54:30.015Z",
"model": "nulu-5-ultra",
"status": "succeeded",
"input_tokens": 11796,
"cached_input_tokens": 4864,
"output_tokens": 936,
"reasoning_tokens": 543,
"charge_usd": 0.00484798,
"pricing_period": "off-peak"
}],
"has_more": true,
"next_cursor": "WyIyMDI2LTEyLTAzVDIxOjU0...",
"summary": {
"requests": 29,
"input_tokens": 38740,
"cached_input_tokens": 6912,
"output_tokens": 1614,
"reasoning_tokens": 573,
"charge_usd": 0.02730184,
"by_model": [
{"model": "nulu-5-ultra", "requests": 19, "input_tokens": 38457, "cached_input_tokens": 6784, "output_tokens": 1610, "charge_usd": 0.0172119},
{"model": "nulu-search", "requests": 2, "input_tokens": 0, "cached_input_tokens": 0, "output_tokens": 0, "charge_usd": 0.003375}
]
},
"pending": {"requests": 0, "held_usd": 0},
"currency": "usd"
}- Parameters:
sinceanduntil(ISO 8601; default the last 30 days, at most a 90-day range),limit(1–100, default 50) andcursor(thenext_cursorof the previous page). - Tools appear under the names
nulu-search,nulu-fetch,nulu-ocr,nulu-document-parsing,nulu-ttsandnulu-stt. pricing_periodsays whether the request was billed at peak (peak) or off-peak (off-peak) rates.pending.held_usdis the balance held by requests in progress.usage.prompt_tokensincludes a short fixed platform instruction (about 230 tokens, almost always served from the cache) besides your messages.
| Tool | Endpoint | Price | Billed for |
|---|---|---|---|
| Search API | /v1/tools/search | $2.25 per 1,000 successful requests | Successful request with results |
| Fetch API | /v1/tools/fetch | $2.25 per 1,000 successful requests | Successful request with content |
| OCR | /v1/tools/ocr | $0.675 per 1,000 pages | Page recognised |
| Document parsing | /v1/files | $0.675 per 1,000 pages | Page of a parsed document |
| Text to speech | /v1/tools/tts | $0.675 per 10,000 characters (promotional; standard $1.35) | Character of text |
| Speech to text | /v1/tools/stt | $0.174 per hour of audio (promotional; standard $0.348) | Second of audio |
| Integrated capability | Billing | Detail |
|---|---|---|
| Web search | Model tokens | Search results count as input tokens. |
| Deep thinking search | Model tokens | Search results and opened pages count as input tokens; reasoning counts as output tokens. |
| URL reading | Model tokens | Page content counts as input tokens. |
| File input | Model tokens | The text of a referenced file counts as input tokens. Parsing is charged once, at upload. |
| Conversation title | Free | No charge. |
| User context marker | Model tokens | A few input tokens. |
| Content safety | Model tokens | Review tokens are billed as output tokens. A request blocked on input is not charged. |
- Charges are prorated per unit, with six decimals of a cent: one operation costs exactly the price divided by the quantity in the table.
- Failed operations are not charged. Tools and models draw from the same prepaid balance.
GET /v1/pricingreturns these same prices as JSON (tools[],integrated[]), without a key.
curl https://api.nuluai.com/v1/pricing| Type | Off-peak | Peak |
|---|---|---|
| Input — cache miss | $0.45 | $0.90 |
| Input — cache hit | $0.009 | $0.018 |
| Output | $1.80 | $3.60 |
| Type | Off-peak | Peak |
|---|---|---|
| Input — cache miss | $1.98 | $3.96 |
| Input — cache hit | $0.066 | $0.132 |
| Output | $5.94 | $11.88 |
A request with 1M uncached input tokens + 1M output tokens costs $0.45 + $1.80 = $2.25 off-peak, and $0.90 + $3.60 = $4.50 during peak.
If those 1M input tokens were already cached: $0.009 + $1.80 = $1.809 off-peak, and $0.018 + $3.60 = $3.618 during peak.
| Chat Completions | Responses | Messages | |
|---|---|---|---|
| Models | All chat models | nulu-5-ultra, nulu-5-pro | nulu-5-ultra, nulu-5-pro |
| Key header | Authorization: Bearer | Authorization: Bearer | x-api-key or Authorization: Bearer |
| End of the answer | finish_reason | status | stop_reason |
| Blocked output | finish_reason: "content_filter" | status: "incomplete" | stop_reason: "refusal" |
| Input / output tokens | prompt_tokens / completion_tokens | input_tokens / output_tokens | input_tokens / output_tokens |
| Cached tokens | prompt_tokens_details.cached_tokens | input_tokens_details.cached_tokens | cache_read_input_tokens |
| Error shape | {"error": {…}} | {"error": {…}} | {"type": "error", "error": {…}} |
| User context marker | Yes | No | Yes |
The full capability matrix is in API protocols. The price is the same on all three protocols.
- Stateless: there are no conversations stored on the server (
previous_response_id,conversationandbackgroundreturn 400). Your application sends the history. - Web tools (
web_search,read_url) onnulu-5-ultraonly;tool_choicecannot force them. - Non-streaming requests are limited to ~95 s: stream deep thinking search and long answers.
- The user context marker is not available on Responses.
- Files: 30-day maximum retention, no download of the original or of the parsed text, 64 MB and 1,000 pages per file, 500 files and 2 GB per account.
- Speech: text to speech without streaming, with two voices and WAV or PCM output; speech to text up to 120 s and 8 MB, 16-bit PCM WAV or Ogg Opus only, no timestamps.
- The Search API takes queries up to 128 characters and 50 results; the Fetch API, one public URL per request.
- JSON mode guarantees valid JSON, not a schema.
- The standalone APIs are REST only: they are not part of the chat SDKs.
Images and Integrations
| Size | Quality | Generate | Edit |
|---|---|---|---|
| 1024×1024 | Medium | $0.012371 | $0.012371 |
| 1024×1024 | Low | $0.040562 | $0.040562 |
| 1024×1024 | High | $0.04065 | $0.04065 |
| 1536×1024 | Low | $0.058536 | $0.058536 |
| 1536×1024 | Medium | $0.05865 | $0.05865 |
| 1536×1024 | High | $0.012291 | $0.012291 |
| 2048×2048 | Low | $0.04065 | $0.04065 |
| 2048×2048 | Medium | $0.04065 | $0.04065 |
| 2048×2048 | High | $0.04065 | $0.04065 |
curl https://api.nuluai.com/v1/images/generations \
-H "Authorization: Bearer sk_wat_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "nulu-image-3",
"prompt": "Modern wooden chair in a bright studio",
"size": "1024x1024",
"quality": "medium",
"n": 1
}'curl https://api.nuluai.com/v1/images/edits \
-H "Authorization: Bearer sk_wat_your_key" \
-F "model=nulu-image-3" \
-F "prompt=Same chair in vivid red" \
-F "[email protected]" \
-F "size=1024x1024"import OpenAI from "openai";
import fs from "node:fs";
const client = new OpenAI({
apiKey: "sk_wat_your_key",
baseURL: "https://api.nuluai.com/v1"
});
// Generate
const generated = await client.images.generate({
model: "nulu-image-3",
prompt: "Minimal kitchen product on a white background",
size: "1024x1024"
});
// Edit (multipart)
const edited = await client.images.edit({
model: "nulu-image-3",
image: fs.createReadStream("product-photo.png"),
prompt: "Same scene with a red finish"
});| Field | Generation | Editing |
|---|---|---|
| model | Yes — `nulu-image-3` | Yes — `nulu-image-3` |
| prompt | Yes | Yes |
| image | No | Yes — PNG/JPEG/WebP file |
| mask | No | Optional — transparent PNG |
| size | Optional | Optional |
| quality | Optional (`low`, `medium`, `high`) | Optional |
| n | Optional (1–10) | Optional (1–10) |
{
"provider": {
"world-app-technologies-api": {
"npm": "@ai-sdk/openai-compatible",
"name": "Nulu API",
"options": {
"baseURL": "https://api.nuluai.com/v1",
"apiKey": "sk_wat_your_key"
},
"models": {
"nulu-5-pro": {
"name": "Nulu 5 Pro",
"reasoning": true,
"tool_call": true,
"interleaved": { "field": "reasoning_content" },
"limit": { "context": 1000000, "output": 384000 },
"variants": {
"low": { "reasoningEffort": "low" },
"medium": { "reasoningEffort": "medium" },
"high": { "reasoningEffort": "high" },
"max": { "reasoningEffort": "max" }
}
},
"nulu-5-ultra": {
"name": "Nulu 5 Ultra",
"reasoning": true,
"tool_call": true,
"interleaved": { "field": "reasoning_content" },
"limit": { "context": 1000000, "output": 384000 },
"variants": {
"low": { "reasoningEffort": "low" },
"medium": { "reasoningEffort": "medium" },
"high": { "reasoningEffort": "high" },
"max": { "reasoningEffort": "max" }
}
},
"nulu-image-1.5": {
"name": "Nulu Image 1.5 (Legacy)"
},
"nulu-image-3": {
"name": "Nulu Image 3"
}
}
}
}
}
