Documentation

API reference

Kakehashi exposes an OpenAI-compatible API. Any client that already speaks that protocol works here by changing two things: the base URL and the key.

Base URL

Every request goes to the same host. Which path prefix you need depends on the client:

The base URL to configure, per kind of client
ClientBase URL to configure
OpenAI SDKs, and anything OpenAI-compatiblehttps://api.kakehashi.classmethod.my/v1
Raw HTTPhttps://api.kakehashi.classmethod.my/v1/chat/completions
Anthropic SDKs and the Claude Code CLIhttps://api.kakehashi.classmethod.my

Authentication

Send your key as a bearer token on every request:

Authorization: Bearer $KAKEHASHI_API_KEY
  • There is no other credential: no account id, no signature, no second header.
  • The key identifies the account, the group its spending counts toward and the balance it draws on, so nothing about billing needs to be in the request.
  • A missing or unknown key is refused with 401 before the request reaches any model, so it costs nothing.

Supported endpoints

The endpoints a customer key can call
EndpointWhat it does
POST /v1/chat/completionsThe main one. OpenAI's Chat Completions protocol — messages in, a completion out.
POST /v1/messagesAnthropic's Messages protocol, for clients built against the Anthropic SDK rather than the OpenAI one. It is what the Claude Code CLI uses.
GET /v1/modelsLists the model ids your key can call, so a client can fill a model picker instead of hardcoding one.

The catalogue is made up of chat models, so chat is what the API serves. Embeddings, image generation, audio and the other OpenAI modalities are not part of the service today.

Making a request

The only field Kakehashi itself reads is model, which names a model from the catalogue. Everything else is that model's own vocabulary and is passed through unchanged.

curl https://api.kakehashi.classmethod.my/v1/chat/completions \
  -H "Authorization: Bearer $KAKEHASHI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "<model-id>", "messages": [{"role": "user", "content": "Hello"}]}'

Streaming

Set stream: true to receive the answer as server-sent events, exactly as the OpenAI protocol defines. Your SDK's usual streaming interface works unmodified.

The response

A successful call returns the standard shape, including a usage block with the token counts your charge was calculated from:

{
  "id": "chatcmpl-…",
  "object": "chat.completion",
  "created": 1770000000,
  "model": "<model-id>",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "…" },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}

Switching an existing integration

If your code already calls an OpenAI-compatible endpoint, there are two changes and no third:

  • Point the base URL at https://api.kakehashi.classmethod.my/v1.
  • Use your Kakehashi key in place of the old one.

Model names differ from your previous provider's, so check the catalogue for the id you want. Nothing else about your request or your response handling changes.

When something goes wrong

Errors come back in the OpenAI error shape, with the status code carrying the meaning. Each one, and what to do about it, is in Errors and limits.