Nbility logoNbility Docs

Search documentation

Search guides and API reference content

You can use OpenAI SDKs directly with Nbility's OpenAI-compatible API. The only required configuration is an API key, Base URL, and model ID.

Completion path: create a key → configure the SDK → run the smallest example below → confirm the request in Usage Logs.

Prepare

  1. Create an API key in Token management.
  2. Put it in an environment variable instead of source code:
export NBILITY_API_KEY="YOUR_API_KEY"
  1. Use GET /v1/models to confirm a model ID available to that token.

Python

pip install -U openai
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["NBILITY_API_KEY"],
    base_url="https://api.nbility.ai/v1",
    timeout=60.0,
    max_retries=2,
)

response = client.chat.completions.create(
    model="gpt-5.4",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)

If the selected model supports Responses, you can also call:

response = client.responses.create(
    model="gpt-5.4",
    input="Explain API gateways in one sentence.",
)
print(response.output_text)

Node.js / TypeScript

npm install openai
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.NBILITY_API_KEY,
  baseURL: 'https://api.nbility.ai/v1',
  timeout: 60_000,
  maxRetries: 2,
});

const response = await client.chat.completions.create({
  model: 'gpt-5.4',
  messages: [{ role: 'user', content: 'Hello' }],
});

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

Claude and Gemini SDKs

For an existing Anthropic application, point the Anthropic SDK Base URL at https://api.nbility.ai; see Native Claude-compatible API. For Google Gen AI applications, use google-genai with a custom Base URL; see Native Gemini-compatible API.

Before production

  • Keep keys in server-side environment variables or a secrets manager.
  • Set both connection and overall request timeouts, with bounded retries.
  • Retry transient failures only; treat streaming and billable side-effecting requests separately.
  • Do not hard-code a complete model catalog. Configure the model per environment and keep a fallback path.
  • Log request IDs, models, and status codes, but never complete keys or sensitive input.

See Errors and retries and Authentication for the full policy.