Documentation

myopenai is an OpenAI-compatible API gateway. The only change required in your code is swapping the base_url.

Quickstart

  1. Create an account and add credit from the billing page.
  2. Create an API key. Optionally set a dollar cap and reset window (daily / monthly / total).
  3. Change the base_url in your existing code to https://myopenai.site/v1.

SDK examples

Python

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)

Node.js

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

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"}]
  }'

HTTP 402 — spend cap exceeded

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.

Spend cap semantics

  • Caps are per-key, not per-account. One key per project, one budget per project.
  • Three reset windows: day, month, total. “Total” never resets.
  • The cap check happens before the upstream call. If the projected cost would exceed the cap, the request is blocked immediately.
  • Amounts are integer micro-dollars internally (1 USD = 1,000,000 micros). The 402 message renders the exact cap and spend to the cent.
  • You can change a key’s cap at any time from the keys page.

Available models

Model IDProviderInput / 1MOutput / 1M
gpt-5.5OpenAI$6.00$36.00
claude-opus-5Anthropic$6.00$30.00
claude-sonnet-5Anthropic$2.64$13.20
claude-haiku-4-5Anthropic$0.96$4.80