myopenai is an OpenAI-compatible API gateway. The only change required in your code is swapping the base_url.
base_url in your existing code to https://myopenai.site/v1.from openai import OpenAI
client = OpenAI(
api_key="mo_live_YOUR_KEY",
base_url="https://myopenai.site/v1",
)
response = client.chat.completions.create(
model="claude-sonnet-5",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'mo_live_YOUR_KEY',
baseURL: 'https://myopenai.site/v1',
});
const response = await client.chat.completions.create({
model: 'claude-sonnet-5',
messages: [{ role: 'user', content: 'Hello' }],
});
console.log(response.choices[0].message.content);curl https://myopenai.site/v1/chat/completions \
-H "Authorization: Bearer mo_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5",
"messages": [{"role": "user", "content": "Hello"}]
}'When a key’s spend cap is reached, the gateway returns HTTP 402 before forwarding the request to the upstream provider. No tokens are consumed; no charge is made for the blocked request.
The response body is OpenAI-compatible:
HTTP/2 402
{
"error": {
"message": "api key spend cap exceeded: cap $5.00, spent $5.00",
"type": "invalid_request_error"
}
}Handle this in your application by catching the 402 status and alerting the user or pausing automated requests.
day, month, total. “Total” never resets.| Model ID | Provider | Input / 1M | Output / 1M |
|---|---|---|---|
| gpt-5.5 | OpenAI | $6.00 | $36.00 |
| claude-opus-5 | Anthropic | $6.00 | $30.00 |
| claude-sonnet-5 | Anthropic | $2.64 | $13.20 |
| claude-haiku-4-5 | Anthropic | $0.96 | $4.80 |