API Documentation - Chat, Image & Video Generation - LayerCloud AI

LayerCloud AI docs: authentication, chat, image generation and video generation over the OpenAI-compatible endpoint, model catalogue, client quickstarts.

Base URL and authentication

Every request goes to one base URL: https://ai.layercloud.org. The OpenAI-compatible paths live under /v1; the Anthropic-compatible path sits on the root so Claude Code works with no extra configuration.

Authentication is the Authorization header with an API key. You create the key in the panel and it is shown once, so keep it in an environment variable rather than in source.

curl https://ai.layercloud.org/v1/models \
  -H "Authorization: Bearer $LAYERCLOUD_API_KEY"

Endpoints

Four paths cover the gateway. Everything else - streaming, tools, structured output, reasoning effort - is a parameter on these.

POST /v1/chat/completionsChat over the OpenAI protocol; supports stream, tools and response_format
POST /v1/messagesChat over the Anthropic protocol; the path Claude Code calls
GET /v1/modelsLive models with their exact ids and context windows
POST /v1/embeddingsText to vectors for search and retrieval

Your first request

Send one plain request before you configure an editor. If the response carries choices, the key and the model id are right and anything left is client configuration.

curl https://ai.layercloud.org/v1/chat/completions \
  -H "Authorization: Bearer $LAYERCLOUD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek/deepseek-v4.1-flash","messages":[{"role":"user","content":"hi"}]}'

Client setup

Any client that accepts a custom base URL works without code changes. Three common ones:

  • Claude Code: set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, then name the model with ANTHROPIC_MODEL.
  • Cursor: enable Override OpenAI Base URL in Settings, Models and set it to https://ai.layercloud.org/v1, then add the model id by hand.
  • Python SDK: pass the key as usual and set base_url to https://ai.layercloud.org/v1. Nothing else in the code changes.

Models and billing

Read the model list from /v1/models at runtime, because models are added and retired. The pricing page shows the same catalogue with input and output price per million tokens and is the authority for billing.

Billing is per token. A request rejected for a client error (400 or 401) is not charged; only a successful response with its token usage is. Create one token per device or project to see spend per project.

Errors and limits

Errors use the standard OpenAI shape and carry a message in the error field.

401Key invalid, revoked, or missing from the header
404Unknown model id, or the wrong path was called
400The body does not match the schema - usually a field name or message type
429Token quota or rate limit; wait or raise the token quota
499The client closed the connection before the response finished

Status and support

The status page is readable without an account. If you hit something this page does not explain, send the request id and the exact time from the contact page.