How to use razorbill from an OpenAI client
This guide points existing OpenAI clients and frameworks at rzb serve. It assumes the server is running at http://127.0.0.1:7920 (add your key if you set one).
The rule is always the same: base URL http://127.0.0.1:7920/v1, API key any non-empty value (or the server's key), model a declared id or a Hugging Face id.
Python — openai
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:7920/v1", api_key="unused")
razorbill-specific fields go in extra_body, for example extra_body={"reasoning_effort": "none", "thinking_budget": 256}.
JavaScript / TypeScript — openai
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "http://127.0.0.1:7920/v1", apiKey: "unused" });
const answer = await client.chat.completions.create({
model: "mlx-community/Qwen3-4B-4bit",
messages: [{ role: "user", content: "Hello" }],
});
LangChain (Python)
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
llm = ChatOpenAI(base_url="http://127.0.0.1:7920/v1", api_key="unused", model="mlx-community/Qwen3-4B-4bit")
embeddings = OpenAIEmbeddings(base_url="http://127.0.0.1:7920/v1", api_key="unused",
model="BAAI/bge-small-en-v1.5", check_embedding_ctx_length=False)
check_embedding_ctx_length=False is required: otherwise LangChain sends token arrays, which the server refuses.
Environment variables
Many tools read the standard OpenAI variables:
export OPENAI_BASE_URL=http://127.0.0.1:7920/v1
export OPENAI_API_KEY=unused
Chat UIs (Open WebUI and others)
Add an "OpenAI API" connection with the base URL http://127.0.0.1:7920/v1 and any key. If the UI runs in Docker, 127.0.0.1 is the container itself: use http://host.docker.internal:7920/v1 and start the server with --host 0.0.0.0 and an API key. The UI lists the models of /v1/models.
Tools that use the legacy completions API
Code-completion plugins and benchmark harnesses (lm-eval…) that call /v1/completions work too: the prompt is continued as raw text. Fill-in-the-middle (suffix) and logprobs are refused.
curl
curl -s http://127.0.0.1:7920/v1/chat/completions -H "Content-Type: application/json" \
-H "Authorization: Bearer $RZB_API_KEY" \
-d '{"model": "mlx-community/Qwen3-4B-4bit", "messages": [{"role": "user", "content": "Hello"}]}'
When something does not work
- 404
model_not_found: the client sends a model name the server does not know (some UIs default togpt-4o). Pick a model from/v1/models. - 400 naming a field: the client sends something razorbill refuses rather than ignores (
n> 1,logprobs, images…). The message says which field. - 401: the server has a key and the client sends another one, or none.
See also
- What is supported, refused or ignored: HTTP API reference.
- How compatibility is defined and checked: OpenAI compatibility.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|