Skip to content

Making requests

The Nodea API is compatible with the OpenAI Chat Completions API. Point any OpenAI SDK, or any tool that lets you set an OpenAI base URL, at Nodea and use a Nodea API key.

Base URL https://api.getnodea.com/openai/v1
Authentication Authorization: Bearer <your API key>
Endpoints POST /chat/completions, GET /models, GET /models/{model}

Your organization comes from the API key, so every organization uses the same base URL.

You need:

The examples below read the key from the NODEA_API_KEY environment variable:

Terminal window
export NODEA_API_KEY="<your API key>"

Set model to a model name from your Models page.

Terminal window
curl https://api.getnodea.com/openai/v1/chat/completions \
-H "Authorization: Bearer $NODEA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "bartowski/Llama-3.2-3B-Instruct-GGUF:Q4_K_M",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Explain what a GGUF file is in one sentence."}
],
"temperature": 0.7,
"max_tokens": 200
}'

The response has the same shape as OpenAI’s:

{
"id": "chatcmpl-6f1c2a9b8e7d4c3b2a1f0e9d",
"object": "chat.completion",
"created": 1760000000,
"model": "bartowski/Llama-3.2-3B-Instruct-GGUF:Q4_K_M",
"system_fingerprint": "fp_nodea_local",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A GGUF file packages a model's weights and metadata in a single file for local inference.",
"refusal": null
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 31, "completion_tokens": 19, "total_tokens": 50 }
}

Set stream: true to receive the answer as it’s generated, as server-sent events. Add stream_options: {"include_usage": true} to get token counts in a final chunk.

Terminal window
curl -N https://api.getnodea.com/openai/v1/chat/completions \
-H "Authorization: Bearer $NODEA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "bartowski/Llama-3.2-3B-Instruct-GGUF:Q4_K_M",
"messages": [{"role": "user", "content": "Write a haiku about laptops."}],
"stream": true
}'

The stream ends with data: [DONE]. If something goes wrong after streaming has started, you get a final chunk with an error object instead, and no [DONE]. See Streaming errors.

GET /models returns the models enabled for your organization. A model can be listed even when no device is serving it right now.

Terminal window
curl https://api.getnodea.com/openai/v1/models \
-H "Authorization: Bearer $NODEA_API_KEY"
{
"object": "list",
"data": [
{
"id": "bartowski/Llama-3.2-3B-Instruct-GGUF:Q4_K_M",
"object": "model",
"created": 1760000000,
"owned_by": "ai4all"
}
]
}

To fetch one model with GET /models/{model}, URL-encode the / in its name as %2F.

Describe your functions in tools. When the model wants one, the response has finish_reason: "tool_calls" and the call in message.tool_calls. Run it, send the result back as a tool message, and call the API again for the answer.

import json
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.getnodea.com/openai/v1",
api_key=os.environ["NODEA_API_KEY"],
)
MODEL = "unsloth/Qwen3-8B-GGUF:Q4_K_M"
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}]
messages = [{"role": "user", "content": "What's the weather in Oslo?"}]
response = client.chat.completions.create(
model=MODEL, messages=messages, tools=tools, max_completion_tokens=1000
)
message = response.choices[0].message
if message.tool_calls:
call = message.tool_calls[0]
args = json.loads(call.function.arguments)
result = {"city": args["city"], "temperature_c": 17, "sky": "sunny"} # your function
messages.append(message)
messages.append({
"role": "tool",
"tool_call_id": call.id,
"content": json.dumps(result),
})
response = client.chat.completions.create(
model=MODEL, messages=messages, tools=tools, max_completion_tokens=1000
)
print(response.choices[0].message.content)

To make sure the model calls a tool, set tool_choice to "required", or name the function:

tool_choice={"type": "function", "function": {"name": "get_weather"}}

Each response contains at most one tool call. Tool calling works with models trained for it; see What models can do.

response_format makes the model answer in JSON. With a JSON Schema, the output always matches it, because the schema is enforced during generation.

response = client.chat.completions.create(
model=MODEL,
messages=[{
"role": "user",
"content": "Invent a fictional person. Reply in JSON with their name and age.",
}],
response_format={
"type": "json_schema",
"json_schema": {
"name": "person",
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
},
"required": ["name", "age"],
"additionalProperties": False,
},
},
},
)
person = json.loads(response.choices[0].message.content)

Mention JSON in the prompt as well: small models given a prompt that doesn’t ask for JSON can produce valid but rambling values. For JSON without a schema, use response_format={"type": "json_object"}.

Errors use OpenAI’s format, so the official SDKs raise their usual exceptions. The ones you’re most likely to see:

  • 401: the key is wrong, deleted, or its creator has left the organization.
  • 403 model_disabled: an Admin has disabled or removed that model.
  • 503 model_unavailable: no device served the model within 120 seconds. Retry, or check the Fleet page.

See Errors for the full list.

Any tool that accepts a custom OpenAI base URL can use Nodea. Set:

  • base URL / API base to https://api.getnodea.com/openai/v1
  • API key to your Nodea key
  • model to a model name from your Models page

Tools that need the Responses API, embeddings, images or audio won’t work. Nodea provides only Chat Completions and Models.