Skip to main content
Tokonomics acts as a transparent proxy between your application and OpenAI. You change one URL, add your Tokonomics key as an Authorization header, and every call you make to GPT-4o, o1, or any other OpenAI model is automatically metered, tagged, and attributed to your budget — no SDK wrappers, no middleware, no refactoring required.

The URL change

Swap the OpenAI base URL for your Tokonomics proxy URL. That is the only code change you need to make.
URL
Beforehttps://api.openai.com/v1
Afterhttps://tokonomics.ca/proxy/openai
The upstream path stays exactly the same. For example, a chat completion request hits:
https://tokonomics.ca/proxy/openai/chat/completions
from openai import OpenAI

client = OpenAI(
    api_key="your-openai-api-key",
    base_url="https://tokonomics.ca/proxy/openai",
    default_headers={"Authorization": "Bearer mk_your_tokonomics_key"}
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)

print(response.choices[0].message.content)

Supported OpenAI paths

Tokonomics forwards requests to any path under https://api.openai.com/v1. The most commonly used paths are:
  • chat/completions — chat models including GPT-4o, GPT-4o mini, and the o-series
  • embeddings — text embedding models such as text-embedding-3-small
  • completions — legacy text completion endpoint

Tagging your calls

Add the X-Metering-Tags header to any request to attach structured metadata. Tokonomics stores these tags and lets you query spend broken down by any key.
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Summarise this report."}],
    extra_headers={
        "X-Metering-Tags": '{"team":"growth","feature":"chatbot"}'
    }
)
See Tagging for the full list of supported headers and querying options.
Streaming works natively. Tokonomics forwards the SSE response back to your client chunk by chunk without buffering, so your time-to-first-token is unaffected.