Python and Node.js library
How to Use Ruvicode with OpenAI SDK
Ruvicode serves the OpenAI chat completions API, so the official OpenAI SDKs work by changing two settings: the base URL and the key. This guide shows both languages, streaming, and where to read the cost of each call.
Tested on November 3, 2026. openai 3.42.1 for Python (plain and streamed calls) and openai 7.47.0 for Node.js completed chat completions through api.ruvicode.com with the code below.
Set up OpenAI SDK
Base URL
https://api.ruvicode.com/v1
API key
rvcd_...
- 1Install the SDK: pip install openai, or npm install openai.
- 2Create the client with base_url https://api.ruvicode.com/v1 (baseURL in Node.js) and your rvcd_ key.
- 3Call chat.completions.create with any model id from the catalog.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["RUVICODE_API_KEY"],
base_url="https://api.ruvicode.com/v1",
)
resp = client.chat.completions.create(
model="glm-5.3-flash",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
print(resp.usage) # includes cost, the exact charge in USDimport OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.RUVICODE_API_KEY,
baseURL: "https://api.ruvicode.com/v1",
});
const resp = await client.chat.completions.create({
model: "glm-5.3-flash",
messages: [{ role: "user", content: "Hello" }],
});
console.log(resp.choices[0].message.content);stream = client.chat.completions.create(
model="glm-5.3-flash",
messages=[{"role": "user", "content": "Count from 1 to 3."}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if not chunk.choices: # the last chunk carries only usage
continue
print(chunk.choices[0].delta.content or "", end="")Good to know
- Every response's usage object includes cost, the exact charge for that call in USD.
- With stream_options include_usage, the final chunk has an empty choices list and the usage. Skip it in the loop, as above, or the SDK code raises an IndexError.
- Ruvicode serves /v1/chat/completions, /v1/models and the Images API. The Responses API, embeddings and audio endpoints are not available.
Models for coding agents
These models completed streamed tool calls through Ruvicode on November 3, 2026. Every model in the catalog works with the same base URL and key; each model page shows its live rate, context window and max output.
- GLM 5.3 Flash
glm-5.3-flash - Claude Sonnet 5.5
claude-sonnet-5.5 - Kimi K2.7 Code
kimi-k2.7-code
Common errors
- 401 Invalid API key
- The key is mistyped, revoked or not a Ruvicode key. Copy it again from the dashboard; it starts with rvcd_.
- 404 Model not found
- The model id is not in the catalog. Use an id exactly as listed on the models page or by GET /v1/models. A plain 404 page instead of a JSON error means the base URL is missing /v1.
- 402 insufficient_balance
- The wallet cannot cover the request. Top up in the dashboard; the balance never expires.
- 429 rate limit
- Too many requests per minute, on the key or across the account. Agents that fire many calls in parallel can hit it; most tools retry on their own after a short wait.
OpenAI SDK with Ruvicode: FAQ
- Do I need a different SDK for Claude or Gemini models?
- No. Every chat model on Ruvicode, Claude and Gemini included, is called through the same OpenAI chat completions API with the same client.
- Does client.responses.create work?
- No. Ruvicode serves chat completions, not the Responses API. Use client.chat.completions.create.
- Where do I get a Ruvicode API key?
- Create an account, top up your wallet with QRIS or USDC, then open API Keys in the dashboard and create a key. Keys start with rvcd_. You can set a daily or monthly spend limit per key and restrict a key to a list of models.
Guides for other tools
The same base URL and key work everywhere. Setup for each tool: