API quickstart
CedarLLM is an OpenAI-compatible API. Any app or library that lets you set a custom OpenAI base URL works with it.
https://api.cedarllm.com/v1qwen3.8-27bqwen3-coder-nextsee Models
Models
| Model | Best for | Input | Output |
|---|---|---|---|
qwen3.8-27b | General chat, thinking, images, tool calling, JSON. Fastest (about 35 tokens/s). | $0.03 / M | $1.15 / M |
qwen3-coder-next | Coding and coding agents: writing and editing code, tool calling. Text only, no thinking mode. About 20 tokens/s. | $0.12 / M | $0.80 / M |
Both take up to 262,144 tokens per request. Choose the model with the model field; the examples below use qwen3.8-27b, and they all work with qwen3-coder-next too, except thinking and images.
1. Get an API key
- Create an account and confirm your email address.
- Open Wallet and add credit with a card (minimum $5).
- Open API Keys, create a key and copy it. It starts with
sk-. Treat it like a password.
2. Make a request
curl
curl https://api.cedarllm.com/v1/chat/completions \
-H "Authorization: Bearer $CEDARLLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-27b",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Python (pip install openai)
from openai import OpenAI
client = OpenAI(base_url="https://api.cedarllm.com/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="qwen3.8-27b",
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
JavaScript (npm install openai)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.cedarllm.com/v1", apiKey: process.env.CEDARLLM_API_KEY });
const resp = await client.chat.completions.create({
model: "qwen3.8-27b",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);
Streaming
Add "stream": true (or stream=True in Python) to receive the reply as it is generated. Use streaming for long replies: a non-streamed request that runs longer than about 100 seconds can be cut off by our network provider.
3. Thinking (reasoning)
Thinking is available on qwen3.8-27b only (qwen3-coder-next always answers directly). It is off by default, for fast answers. Turn it on for harder problems with "reasoning_effort": "high" (any value except "none"; low, medium and high all switch thinking on, there is no separate effort level), or "reasoning": {"enabled": true}, or "chat_template_kwargs": {"enable_thinking": true}. "reasoning_effort": "none" turns it off. When it is on, the reasoning is returned separately in message.reasoning_content (streamed in delta.reasoning_content), and the final answer is in message.content. Reasoning tokens count as output tokens.
- Use thinking for maths, logic and multi-step problems. Answers are noticeably more reliable with it, at the cost of more output tokens and time.
- Leave room for the answer when thinking. If you turn thinking on and set
max_tokens, make it generous (1,000 or more), or leave it out. If thinking uses the whole budget,contentcomes back empty. - JSON answers (
response_format). If you turn thinking on, usemax_tokensof 2,048 or more. If the budget runs out first, the reply ends withfinish_reason: "length"and the JSON is incomplete; raisemax_tokensrather than retrying.
{
"model": "qwen3.8-27b",
"chat_template_kwargs": {"enable_thinking": true},
"messages": [{"role": "user", "content": "What is 17 * 23?"}]
}
4. Images
qwen3.8-27b can read pictures (photos, screenshots, scanned pages); qwen3-coder-next is text only. Send them in OpenAI's format, either as a normal https:// link or embedded as a data: URL (base64). An image costs input tokens like text (typically a few hundred per image). Images are processed on the server's CPU, so allow a second or two extra per image.
{
"model": "qwen3.8-27b",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is in this picture?"},
{"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
]
}]
}
Python, with a local file:
import base64
from openai import OpenAI
client = OpenAI(base_url="https://api.cedarllm.com/v1", api_key="YOUR_KEY")
b64 = base64.b64encode(open("photo.jpg", "rb").read()).decode()
resp = client.chat.completions.create(
model="qwen3.8-27b",
messages=[{"role": "user", "content": [
{"type": "text", "text": "Describe this image."},
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{b64}"}},
]}],
)
print(resp.choices[0].message.content)
5. Tool calling (function calling)
Describe your functions in tools. When the model wants one, the reply has finish_reason: "tool_calls" and a tool_calls list (it can ask for several at once). Run the function yourself, send the result back as a {"role": "tool", "tool_call_id": ..., "content": ...} message, and the model writes its final answer.
from openai import OpenAI
import json
client = OpenAI(base_url="https://api.cedarllm.com/v1", api_key="YOUR_KEY")
tools = [{"type": "function", "function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]}}}]
messages = [{"role": "user", "content": "What's the weather in Portland, Oregon?"}]
resp = client.chat.completions.create(model="qwen3.8-27b", messages=messages, tools=tools)
msg = resp.choices[0].message
if msg.tool_calls:
messages.append(msg)
for call in msg.tool_calls:
args = json.loads(call.function.arguments)
result = {"city": args["city"], "temp_f": 54, "sky": "cloudy"} # your real lookup here
messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(result)})
resp = client.chat.completions.create(model="qwen3.8-27b", messages=messages, tools=tools)
print(resp.choices[0].message.content)
6. Web search, file uploads and chat apps
The API itself does not browse the web or read PDF/Word files; it works with the text and images you send. To get search, document uploads and chat history, use an app that adds these on top of any OpenAI-compatible API. It runs the searches and extracts text from your files, then sends it to CedarLLM. For example:
- Open WebUI (self-hosted web app): web search, document uploads, images.
- LibreChat (self-hosted web app): agents, file uploads, search.
- Cherry Studio and Chatbox (desktop apps): easy setup, file and image attachments, web search options.
In any of them, add an "OpenAI-compatible" (or "custom OpenAI") provider with:
| Setting | Value |
|---|---|
| Base URL / API host | https://api.cedarllm.com/v1 (some apps want just https://api.cedarllm.com) |
| API key | your sk-... key |
| Model | qwen3.8-27b (or qwen3-coder-next for coding) |
Web search in these apps uses a search provider you set up in the app; the searches themselves are not billed by CedarLLM, but the page text the app sends to the model counts as input tokens. Coding assistants and other tools that accept a custom OpenAI endpoint work the same way; for coding agents, qwen3-coder-next is the better fit.
Pricing and billing
| Model | Input (prompt) tokens | Output (completion) tokens |
|---|---|---|
qwen3.8-27b | $0.03 per million | $1.15 per million |
qwen3-coder-next | $0.12 per million | $0.80 per million |
Credit is prepaid in US dollars and deducted per request. Your dashboard shows every request's token counts and cost. Requests that fail are not charged.
Limits and good to know
- Rate limit: up to 60 successful requests per minute per account. Requests over the limit get HTTP
429; wait and retry. - Capacity: CedarLLM runs on our own GPU server. At busy times requests queue for a moment; there is no uptime guarantee.
- Models: Qwen3.8-27B and Qwen3-Coder-Next, open-weights models from the Qwen team (Apache 2.0), both served as 4-bit builds with up to 262,144 tokens per request (prompt plus reply). Qwen3.8-27B supports chat, streaming, thinking on/off, images, JSON output and tool calling. Qwen3-Coder-Next supports chat, streaming, tool calling and JSON output via
response_formatwith ajson_schema(plainjson_objectmode is not enforced on it); it is text only. - Speed (qwen3.8-27b): about 35 tokens per second for a single request. Prompts are read at several hundred tokens per second, so a very long prompt (over 100,000 tokens) can take several minutes before the first token: use streaming for those.
- Speed (qwen3-coder-next): about 20 tokens per second, a little less in very long conversations. It reads prompts at about 100 tokens per second, so the first request with a large codebase takes a while (about 3 minutes for 17,000 tokens). Follow-up turns in the same conversation reuse that work and start within a second or two. It handles one request at a time; others wait their turn. Always use streaming with it.
- Prompt caching: when a request starts with the same text as a recent one (for example the same long system prompt), the shared beginning is reused automatically, so the reply starts sooner. Reused tokens appear in
usage.prompt_tokens_details.cached_tokensand are billed at the normal input price. - Privacy: we do not store the text of your prompts or responses. See the Privacy Policy.
- Availability: US residents only, as set out in the Terms of Service.
Common errors
| Code | Meaning |
|---|---|
401 | Missing or wrong API key. |
403 | Not enough credit, or the key is disabled or expired. Top up in Wallet or check the key. |
429 | Too many requests, or qwen3.8-27b is at capacity (all request slots busy; we answer at once instead of queueing). Wait a moment (see the Retry-After header) and retry. |
503 | Unknown model name (use qwen3.8-27b or qwen3-coder-next) or the server is temporarily unavailable. |