• Playground
  • Models
  • Rankings
  • Pricing
  • Support
Docs
  • About Boundless
  • Quickstart
  • API Compatibility
  • Models
  • OpenAI SDK
  • Anthropic SDK
  • Vercel AI SDK
  • LangChain
  • Streaming
  • Tool calling
  • Reasoning
  • Errors
  • MPP & Agentic Payments
  • Credits & Billing
  • Rate Limits
  • Teams
  • Privacy & ZDR
  • FAQ
  • Coding agents
    Coding Agents & Harnesses
  • Claude Code
  • Claude Desktop
  • Codex CLI
  • Codex app
  • OpenCode
  • Cursor
  • Cline
  • GitHub Copilot
  • Kilo Code
  • Qwen Code
  • Amp
  • CodeBuddy
  • Hermes
  • Hermes Desktop
  • JetBrains AI & Junie
  • Cherry Studio
  • Mastra
  • MiMo Code
  • Muse
  • omp (Oh My Pi)
  • OpenClaw
  • OpenHands
  • T3 Code
  • Advanced
    System One
All systems operational
© 2026 BoundlessTermssupport@boundless.network

OpenAI SDK

Use the OpenAI Python and TypeScript SDKs with Boundless: install, base URL, a first request, streaming and a tool call.

The OpenAI SDKs work against Boundless with two changes: the base URL and the key. Everything else is the code you already have.

Install#

pip install openai
npm install openai

Base URL and key#

Set the base URL to https://api.inference.boundless.network/v1. Send a Boundless key where the OpenAI key goes. Create a key, then export it:

export BOUNDLESS_API_KEY="paste-your-key-here"

Use a model ID exactly as the models table lists it.

Make a request#

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["BOUNDLESS_API_KEY"],
    base_url="https://api.inference.boundless.network/v1",
)

response = client.chat.completions.create(
    model="deepseek/deepseek-v4.1-flash-1017",
    messages=[{"role": "user", "content": "Say hello"}],
)

print(response.choices[0].message.content)
print(response.usage)
import OpenAI from "openai"

const client = new OpenAI({
  apiKey: process.env.BOUNDLESS_API_KEY,
  baseURL: "https://api.inference.boundless.network/v1",
})

const response = await client.chat.completions.create({
  model: "deepseek/deepseek-v4.1-flash-1017",
  messages: [{ role: "user", content: "Say hello" }],
})

console.log(response.choices[0]?.message.content)
console.log(response.usage)

Stream the reply#

Set stream to true. Set stream_options.include_usage to true to get exact token counts in the last chunk. That chunk has an empty choices array.

stream = client.chat.completions.create(
    model="deepseek/deepseek-v4.1-flash-1017",
    messages=[{"role": "user", "content": "Say hello"}],
    stream=True,
    stream_options={"include_usage": True},
)

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(f"\n{chunk.usage}")
const stream = await client.chat.completions.create({
  model: "deepseek/deepseek-v4.1-flash-1017",
  messages: [{ role: "user", content: "Say hello" }],
  stream: true,
  stream_options: { include_usage: true },
})

for await (const chunk of stream) {
  const text = chunk.choices[0]?.delta?.content
  if (text) process.stdout.write(text)
  if (chunk.usage) console.log("\n", chunk.usage)
}

Streaming explains the chunk format.

Call a tool#

Pass your functions in tools. The model answers with the call it wants. This example forces the call and prints it. Tool calling shows the full loop, with streamed arguments and the result sent back.

response = client.chat.completions.create(
    model="deepseek/deepseek-v4.1-flash",
    messages=[{"role": "user", "content": "What is 20 + 22? Use the add tool."}],
    max_tokens=1024,
    tools=[{
        "type": "function",
        "function": {
            "name": "add",
            "description": "Add two integers.",
            "parameters": {
                "type": "object",
                "properties": {"a": {"type": "integer"}, "b": {"type": "integer"}},
                "required": ["a", "b"],
            },
        },
    }],
    tool_choice={"type": "function", "function": {"name": "add"}},
)

call = response.choices[0].message.tool_calls[0]
print(call.function.name, call.function.arguments)

Known differences#

  • Credits that run out return 402 with budget_exceeded. The SDK does not retry a 402. A rate-limit 429 is retried by default, which is what you want. See Errors.
  • Not every model supports tools. GET /v1/model/info lists the capability flags.
  • A reasoning model spends max_tokens on thinking too. See Reasoning.
  • The gateway does not serve /v1/embeddings, /v1/completions, /v1/batches, images or audio. See API Compatibility.
  • POST /v1/responses serves only the subset Codex CLI uses. Use chat completions from the SDK.
  • After a 502, a timeout or a dropped stream, check GET /v1/requests/{id} before you resend. See Retrying safely.
NextAnthropic SDK