OhMyGPT

Quickstart

Make your first call against the free test model, then switch to a real one by changing the model ID.

1. Get a key

Create a key on the API keys page and export it:

export OHMYGPT_API_KEY="sk-..."

Your key starts working after your first top-up on the Billing page.

Keep the key on your server. Don't commit it or ship it in a browser or mobile app.

2. Call the free test model

ohmygpt/mock costs nothing and answers every endpoint, streaming or not. Use it to check the base URL, the key and your response handling before you spend anything.

curl https://api.ohmygpt.com/v1/chat/completions \
  -H "Authorization: Bearer $OHMYGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "ohmygpt/mock", "messages": [{"role": "user", "content": "ping"}]}'
{
  "id": "chatcmpl-ohmygpt-mock",
  "object": "chat.completion",
  "model": "mock",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "This is a mock reply from OhMyGPT. Your integration works; switch to a real model when ready."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 15, "completion_tokens": 17, "total_tokens": 32 }
}

The mock also tests tool calling for free. If the request declares tools, it calls the first one (or the one tool_choice names) with every required argument set to its zero value. After it receives the tool result, it replies with text.

3. Switch to a real model

Change only the model ID. Take the ID from the model list.

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.ohmygpt.com/v1",
    api_key=os.environ["OHMYGPT_API_KEY"],
)

completion = client.chat.completions.create(
    model="openai/gpt-5.4-nano",
    messages=[{"role": "user", "content": "Say hello in one word."}],
)
print(completion.choices[0].message.content)

To try another model, change model to anthropic/claude-sonnet-5-5 or zhipu/glm-5.3-flash; nothing else changes. The same key also works with the Anthropic and Gemini SDKs; the protocol table lists their base URLs.

If the call fails

The error message says what to do. The most common fixes on a first call:

StatuscodeFix
401invalid_api_keyCheck the key in the Authorization: Bearer header.
402insufficient_creditsTop up on the Billing page.
404model_not_foundCopy the model ID from GET /v1/models.
404, body 404 page not found—Check the path. With the Anthropic SDK, remove /v1 from the base URL.

Errors covers every status.

Next steps

On this page