Using an OpenAI SDK with Revoye
- Updated
- Reading time
- 2 min
- Level
- beginner
Change base_url to https://revoyeapi.degird.com/v1, use your Revoye key as the API key, and set the model to
revoye/auto or revoye/<provider>. Existing code keeps working, apart from three documented
differences.
Python
import os
from openai import OpenAI
client = OpenAI(
base_url="https://revoyeapi.degird.com/v1",
api_key=os.environ["REVOYE_KEY"],
timeout=300.0, # a browser is doing the work — do not leave this at default
)
answer = client.chat.completions.create(
model="revoye/chatgpt", # or revoye/auto
messages=[{"role": "user", "content": "Summarise the CAP theorem."}],
)
print(answer.choices[0].message.content)TypeScript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: `${process.env.REVOYE_API_BASE}/v1`,
apiKey: process.env.REVOYE_KEY,
timeout: 300_000,
});
const answer = await client.chat.completions.create({
model: "revoye/auto",
messages: [{ role: "user", content: "Summarise the CAP theorem." }],
});The three differences
Messages are flattened. A system message is prepended and prior assistant turns become
context in a single prompt. The provider's own UI holds the real thread; if you need to continue an
actual conversation, use the native endpoint with conversation_ref and mode: "continue".
stream: true returns 400. There is nothing to stream. Any UI code that assumes a stream needs
a non-streaming path before it can talk to Revoye.
usage is null. No token counts exist. Guard any code that does arithmetic on it — cost
estimation, budget enforcement, context-window maths — because None + int is the failure you will
hit first.
The timeout, again
Every OpenAI SDK ships with a timeout tuned for a model API answering in seconds. Revoye answers in tens of seconds. Set it explicitly to at least 300 seconds or your client will abandon healthy jobs and report a timeout that did not happen on our side.
Model pickers
GET /v1/models returns your enabled providers in OpenAI's list shape, with revoye/auto first. A
picker built against an OpenAI client populates itself with no changes.
What you give up
The compatibility layer covers submitting a prompt and getting an answer. Everything Revoye-specific
lives on /v1/completions: asynchronous submission, webhooks, per-attempt
timeouts, job deadlines, priority, metadata, pinning a specific agent, and continuing a
conversation. For new code, use the native endpoint. The compatibility layer is for saving a
rewrite, not for building on.