Migrate an OpenAI client to Zumik

You already call the OpenAI SDK and want reuse measurement and reproducible routing without a rewrite.

01

Swap the base URL

Point the OpenAI client at api.zumik.ai/v1 and use your Zumik key. Request and response bodies stay byte-for-byte OpenAI-compatible.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.zumik.ai/v1",
    api_key="zk_live_...",
)

r = client.responses.create(
    model="code.balanced",      # a Zumik alias, resolved at request time
    input="Summarize the open PRs.",
)
print(r.output_text)
02

Keep stable content first

Put system instructions, tool definitions, and long-lived context at the front so the provider prefix cache can match. Volatile content (timestamps, ids) goes last.

curl
# stable -> volatile ordering maximizes cache hits
# 1. system policy   2. tools   3. workspace context   4. latest message
03

Read what was reused

The usage object carries cached-token counts where the provider reports them. That is your provider_reported evidence level - no extra instrumentation.

print(r.usage.input_tokens, r.usage.input_tokens_cached)

Got it running? Measure it.

Once requests flow through Zumik, a diagnostic shows exactly what you are reusing.