Python quickstart
Fire Mission is wire-compatible with the official OpenAI and Anthropic Python SDKs. Install once, then point each client at our base URL.
1. Install
pip install openai anthropic2. OpenAI SDK (chat completions)
hello_openai.py python
from openai import OpenAI
client = OpenAI(
api_key="fm_live_...", # your Fire Mission key
base_url="https://firemission.us/v1", # point SDK at Fire Mission
)
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)3. Streaming
Streaming works exactly like upstream OpenAI — the wire format is byte-identical SSE.
stream.py python
stream = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Stream a haiku."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content or ""
print(delta, end="", flush=True)4. Anthropic SDK (messages)
hello_anthropic.py python
from anthropic import Anthropic
client = Anthropic(
api_key="fm_live_...",
base_url="https://firemission.us/v1",
)
msg = client.messages.create(
model="claude-3-5-sonnet-latest",
max_tokens=256,
messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content[0].text)5. Optional: MoE auto-routing
Replace the model with firemission/auto and add the x-fm-route header to let Fire Mission pick the best model across
your configured providers. See the MoE guide.
moe.py python
# Engage MoE auto-routing — Fire Mission picks the best model
# for your stated objective and your configured BYOK providers.
resp = client.chat.completions.create(
model="firemission/auto",
messages=[{"role": "user", "content": "Summarize this PDF in 5 bullets."}],
extra_headers={"x-fm-route": "cost"}, # cost | speed | quality | balanced
)
print(resp.headers.get("x-fm-moe-routed")) # e.g. "openai/gpt-4o-mini"What changes vs. native OpenAI / Anthropic
- API key. Use your
fm_live_*key instead ofsk-*orsk-ant-*. - Base URL. Set
base_urltohttps://firemission.us/v1. - Everything else. Models, parameters, response shapes, streaming events, error envelopes — unchanged.