# OpenCredits > AI credits that work everywhere. One balance, every model, any app. OpenCredits is an open marketplace for AI credits. Users buy credits that apps use to make AI requests. The API is compatible with both OpenAI and Anthropic SDKs. ## Quick Start Point your SDK at `https://api.opencredits.ai` and authenticate with a user key (`oc_sk_...`). ## Base URLs - OpenAI SDK / fetch: `https://api.opencredits.ai/v1` - Anthropic SDK: `https://api.opencredits.ai` (SDK adds /v1 automatically) - Claude Code: `ANTHROPIC_BASE_URL=https://api.opencredits.ai` ## Authentication All AI requests require a user key (starts with `oc_sk_`). Pass it as: - `Authorization: Bearer oc_sk_...` header - `X-User-Key: oc_sk_...` header - `api_key` parameter in OpenAI or Anthropic SDKs ## Endpoints - `POST /v1/chat/completions` — OpenAI-compatible chat completions (supports streaming) - `POST /v1/messages` — Anthropic-compatible messages (supports streaming) - `GET /v1/models` — List all available models (no auth required) - `POST /v1/credits/pricing` — Credit estimates per model (body: publishable_key, optional: models[], input_tokens, output_tokens). Also available as GET with query params. - `GET /v1/credits/balance` — Check user's credit balance (requires auth) ## Code Examples ### OpenAI SDK (Python) ```python from openai import OpenAI client = OpenAI( base_url="https://api.opencredits.ai/v1", api_key="oc_sk_...", # user key ) response = client.chat.completions.create( model="anthropic/claude-sonnet-4-20250514", messages=[{"role": "user", "content": "Hello!"}], ) ``` ### OpenAI SDK (Node.js) ```javascript import OpenAI from 'openai'; const client = new OpenAI({ baseURL: 'https://api.opencredits.ai/v1', apiKey: 'oc_sk_...', // user key }); const response = await client.chat.completions.create({ model: 'anthropic/claude-sonnet-4-20250514', messages: [{ role: 'user', content: 'Hello!' }], }); ``` ### Anthropic SDK (Python) ```python import anthropic client = anthropic.Anthropic( base_url="https://api.opencredits.ai", # no /v1 api_key="oc_sk_...", # user key ) message = client.messages.create( model="anthropic/claude-sonnet-4-20250514", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}], ) ``` ### Anthropic SDK (Node.js) ```javascript import Anthropic from '@anthropic-ai/sdk'; const client = new Anthropic({ baseURL: 'https://api.opencredits.ai', // no /v1 apiKey: 'oc_sk_...', // user key }); const message = await client.messages.create({ model: 'anthropic/claude-sonnet-4-20250514', max_tokens: 1024, messages: [{ role: 'user', content: 'Hello!' }], }); ``` ### Claude Code ```shell export ANTHROPIC_BASE_URL=https://api.opencredits.ai export ANTHROPIC_API_KEY=oc_sk_... # user key claude ``` ### Raw fetch (OpenAI format) ```javascript const response = await fetch('https://api.opencredits.ai/v1/chat/completions', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer oc_sk_...', }, body: JSON.stringify({ model: 'anthropic/claude-sonnet-4-20250514', messages: [{ role: 'user', content: 'Hello!' }], }), }); ``` ## Model Names Models use provider-prefixed identifiers. Call `GET /v1/models` for the full list. Common models: - `anthropic/claude-sonnet-4-20250514` — Claude Sonnet 4 - `anthropic/claude-haiku-4-5-20251001` — Claude Haiku 3.5 - `openai/gpt-4o` — GPT-4o - `openai/gpt-4o-mini` — GPT-4o Mini - `google/gemini-2.0-flash` — Gemini 2.0 Flash ## Key Concepts - **User key** (`oc_sk_...`) — authenticates a user's credit balance. Issued on purchase. - **Publishable key** (`oc_pk_...`) — identifies a partner app. Used in the checkout widget. - **Credits** — 100 credits = $1 USD. Deducted per request based on token usage. - **Referral share** — a percentage added to each request that goes to the partner app. ## Error Codes - `401` — Missing or invalid user key - `402` — Insufficient credits (prompt user to top up) - `429` — Rate limited - `500` — Internal server error ## Pricing $1 = 100 credits. Credits are deducted based on token usage at provider rates. ## Links - Integration skill (step-by-step): https://opencredits.ai/skill.md - Developer docs: https://opencredits.ai/docs - Developer docs (markdown): https://opencredits.ai/docs.md - Dashboard: https://opencredits.ai/dashboard - Available models: https://api.opencredits.ai/v1/models