Before you start
You need a Prefill Systems API key. Existing pilot users can create one in the dashboard; other developers can request direct API access.
1. Install the client
python -m pip install openai
2. Configure the client
Keep the API key in an environment variable rather than source code.
# PowerShell
$env:PREFILL_API_KEY = "pf_your_key_here"# bash
export PREFILL_API_KEY="pf_your_key_here"import os
from openai import OpenAI
client = OpenAI(
base_url="https://prefillsystems.com/v1",
api_key=os.environ["PREFILL_API_KEY"],
)3. Create a completion
response = client.chat.completions.create(
model="qwen/qwen3.8-27b",
messages=[
{"role": "system", "content": "Answer clearly and concisely."},
{"role": "user", "content": "Why does prefix caching reduce prefill work?"},
],
)
print(response.choices[0].message.content)
print(response.usage)The response includes prompt and completion token counts. Cached prompt tokens are reported separately when the inference worker identifies a cache hit.
4. Stream tokens
stream = client.chat.completions.create(
model="qwen/qwen3.8-27b",
messages=[{"role": "user", "content": "Write a short explanation of speculative decoding."}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
if chunk.usage:
print("\nusage:", chunk.usage)Streaming uses server-sent events. A final usage-bearing chunk arrives before the [DONE] marker.
Compatibility notes
- The API base is https://prefillsystems.com/v1.
- The model ID is qwen/qwen3.8-27b.
- Capacity pressure returns HTTP 429 rather than holding requests in a long queue.
- Prompts and completions are not persisted; account and usage metadata is retained separately.
Next: see the Qwen3.8 tool-calling guide
or the complete API documentation.