Route your first AI call through ModelSpend.
This guide uses the OpenAI-compatible proxy. In most server-side applications, you change the API key and base URL, then keep the rest of your code unchanged.
1. Create an API key
Register through the public ModelSpend registration page, then create a server-side API key from the dashboard API key settings area.
2. Set your environment variables
Use the key only from trusted backend code, serverless functions, jobs or internal tools.
export OPENAI_API_KEY=modelspend_api_key_here
export OPENAI_BASE_URL=https://api.modelspend.best/proxy/v1
3. Make a routed request
Send requests to the OpenAI-compatible proxy endpoint and use model: auto when you want ModelSpend to choose the route.
-H "Authorization: Bearer modelspend_api_key_here"
-H "Content-Type: application/json"
-d '{ "model": "auto", "messages": [{ "role": "user", "content": "Reply with READY" }] }'
4. Check the routing result
Review the request, selected model, provider, estimated cost and latency in the ModelSpend dashboard.
Confirm whether the request was handled by the expected route, fallback or policy-controlled path.
Compare routed cost against the model you would otherwise have used by default.