Skip to content
Get an API key

SDK examples

View as Markdown

Noduma serves a subset of OpenAI's chat-completions interface, so the OpenAI SDKs work by changing the base URL to https://app.noduma.dev/v1 and using a Noduma API key. curl and the OpenAI Python SDK were tested against the API; the JavaScript examples send the same requests through the official openai package and have not been run against it yet.

Every example reads the key from NODUMA_API_KEY.

Terminal window
export NODUMA_API_KEY=ndm_k_...
Terminal window
curl https://app.noduma.dev/v1/models -H "Authorization: Bearer $NODUMA_API_KEY"
Terminal window
curl -N https://app.noduma.dev/v1/chat/completions \
-H "Authorization: Bearer $NODUMA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "qwen2.5-7b-instruct-q4_k_m", "stream": true,
"messages": [{"role": "user", "content": "Write a haiku about shared GPUs."}]}'

The last chunk before [DONE] carries usage, with the answer's cost. See Streaming.

Terminal window
curl https://app.noduma.dev/v1/chat/completions \
-H "Authorization: Bearer $NODUMA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-coder-30b-a3b-instruct-q4_k_m",
"messages": [{"role": "user", "content": "What is the weather in Madrid?"}],
"tools": [{"type": "function", "function": {
"name": "get_weather",
"description": "Current weather of a city",
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}
}}]
}'

Your program runs the tool and sends its result back as a tool message. See Tools.

With the Noduma-Routing: own header only the PCs paired to your account answer, free. See Routing.

Terminal window
curl https://app.noduma.dev/v1/chat/completions \
-H "Authorization: Bearer $NODUMA_API_KEY" \
-H "Content-Type: application/json" \
-H "Noduma-Routing: own" \
-d '{"model": "qwen2.5-7b-instruct-q4_k_m", "messages": [{"role": "user", "content": "Hello"}]}'
Terminal window
curl https://app.noduma.dev/v1/account -H "Authorization: Bearer $NODUMA_API_KEY"