Keep your OpenAI code. Change the base URL.
SwyrmCompute speaks the OpenAI API: /v1/chat/completions with streaming, /v1/models and /v1/images/generations. Point the official SDK at https://swyrmcompute.com/v1, use your SwyrmCompute key and the model ID swyrm/qwen3.8-flash-next.
Python
from uuid import uuid4
from openai import OpenAI
client = OpenAI(base_url="https://swyrmcompute.com/v1", api_key="sw_live_...")
stream = client.chat.completions.create(
model="swyrm/qwen3.8-flash-next",
messages=[{"role": "user", "content": "Explain MoE models in two sentences."}],
max_tokens=256,
stream=True,
extra_headers={"Idempotency-Key": str(uuid4())}, # one new key per request
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")Node.js / TypeScript
import OpenAI from "openai";
import { randomUUID } from "node:crypto";
const client = new OpenAI({ baseURL: "https://swyrmcompute.com/v1", apiKey: process.env.SWYRM_API_KEY });
const res = await client.chat.completions.create(
{ model: "swyrm/qwen3.8-flash-next", messages: [{ role: "user", content: "Hello" }], max_tokens: 256 },
{ headers: { "Idempotency-Key": randomUUID() } },
);
console.log(res.choices[0].message.content);curl
curl https://swyrmcompute.com/v1/chat/completions \
-H "Authorization: Bearer $SWYRM_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"model":"swyrm/qwen3.8-flash-next","messages":[{"role":"user","content":"Hello"}],"stream":true}'Images
The images endpoint has the shape of OpenAI's Images API, so client.images.generate works too:
img = client.images.generate(
model="swyrm/z-image-turbo",
prompt="a red fox in the snow at dawn",
size="1024x1024",
extra_headers={"Idempotency-Key": str(uuid4())},
)
print(img.data[0].url) # signed link, valid for 24 hours$0.0025 per 1024×1024 image. Asynchronous jobs and signed webhooks are described in the Images API docs.
Faster, cheaper follow-ups
Pass user (or an X-Session-Id header) with the same value for every turn of a conversation. Follow-ups go back to the GPU that already holds the context: a 32K-token prompt that takes about a minute the first time is answered in about 0.2 seconds on the next turn, and the repeated context is billed at the cached rate of $0.03 per million tokens.
Differences from OpenAI
- Idempotency-Key is required on every POST (16–100 characters, a UUID is fine). It is what guarantees a retry never runs or charges twice.
- Text messages only (
system,user,assistant): no tool calling and no image input yet. - Up to 16,384 output tokens per request and a few concurrent requests per account.
- Billing is prepaid in USDT or USDC; requests reserve their maximum cost and are settled on delivered tokens.
Frequently asked questions
Is SwyrmCompute compatible with the OpenAI SDK?
Yes. Set base_url to https://swyrmcompute.com/v1, use a SwyrmCompute API key and the model swyrm/qwen3.8-flash-next. Chat completions (with streaming), the models list and image generation follow OpenAI's request and response shapes. Add an Idempotency-Key header to each request.
Why is an Idempotency-Key header required?
Because billing is prepaid: the key guarantees that a network retry with the same key never runs the request or charges you twice. Generate a new UUID for every request.
Which model should I use?
swyrm/qwen3.8-flash-next: a mixture-of-experts model with up to 262K tokens of context, about 50 tokens per second, at $0.12 per million input tokens and $0.45 per million output tokens.
Does it support streaming?
Yes. Set stream to true and you receive standard server-sent events, exactly as from OpenAI. If the stream breaks you pay only for the tokens that arrived.
Does it support function calling or vision?
Not yet. Messages are text only (system, user and assistant).