Skip to main content
Quickstart

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.

Create beta account

2. Set your environment variables

Use the key only from trusted backend code, serverless functions, jobs or internal tools.

# Never commit real keys
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.

curl -X POST https://api.modelspend.best/proxy/v1/chat/completions
  -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

Dashboard logs

Review the request, selected model, provider, estimated cost and latency in the ModelSpend dashboard.

Routing decision

Confirm whether the request was handled by the expected route, fallback or policy-controlled path.

Cost impact

Compare routed cost against the model you would otherwise have used by default.

Next: read the routing guide to understand how ModelSpend chooses a model, or open the API reference for endpoint details.