Skip to main content
This section assumes you have already:
  1. Completed registration.
  2. Created an API key.
  3. Have available credit on your account (the new-user trial credit is enough).

Basics

ItemValue
Base URLhttps://openp.ai/v1
AuthAuthorization: Bearer sk-...
Default protocolOpenAI-compatible (/v1/chat/completions, etc.)
Recommended starter modelsgpt-5.5, claude-opus-4-8, gemini-3.1-pro-preview

Test with cURL

curl https://openp.ai/v1/chat/completions \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [
      {"role": "user", "content": "Explain what RAG is in one sentence"}
    ]
  }'
Expected response:
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "gpt-5.5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "RAG (Retrieval-Augmented Generation) is a technique that feeds external knowledge-retrieval results to an LLM as context to improve answer accuracy."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 21, "completion_tokens": 41, "total_tokens": 62 }
}

Python — official openai SDK

pip install openai
from openai import OpenAI

client = OpenAI(
    api_key="sk-XXXXXXXXXXXXXXXX",
    base_url="https://openp.ai/v1",
)

resp = client.chat.completions.create(
    model="gpt-5.5",
    messages=[
        {"role": "system", "content": "You are a senior product manager."},
        {"role": "user", "content": "Write 3 selling points for OpenPAI."},
    ],
)

print(resp.choices[0].message.content)
print("Tokens used:", resp.usage.total_tokens)

Node.js / TypeScript

npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.OPENPAI_API_KEY!,
  baseURL: "https://openp.ai/v1",
});

const resp = await client.chat.completions.create({
  model: "gpt-5.5",
  messages: [
    { role: "system", content: "You are a senior product manager." },
    { role: "user", content: "Write 3 selling points for OpenPAI." },
  ],
});

console.log(resp.choices[0].message.content);

Streaming output

Add stream: true to the request body to use an SSE stream:
stream = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Tell a 100-word sci-fi short story"}],
    stream=True,
)

for chunk in stream:
    delta = chunk.choices[0].delta.content or ""
    print(delta, end="", flush=True)

Switch to the Claude / Gemini native protocols

If your code originally uses the Anthropic or Google SDK, there’s no need to rewrite it — just point base_url at OpenPAI:
from anthropic import Anthropic

client = Anthropic(
    api_key="sk-XXXXXXXXXXXXXXXX",
    base_url="https://openp.ai",
)

resp = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.content[0].text)
from google import genai

client = genai.Client(
    api_key="sk-XXXXXXXXXXXXXXXX",
    http_options={"base_url": "https://openp.ai"},
)

resp = client.models.generate_content(
    model="gpt-5.5",
    contents="Hello",
)
print(resp.text)

Debugging tips

  • Log the x-openpai-request-id response header — it speeds up diagnosis when you open a support ticket.
  • Use https://openp.ai/v1/models to list the models the current key can access.
  • Console → Logs shows each call’s model, token usage and billing details (prompt / response content is not recorded).

Next steps

Client integrations

Connect in Cherry Studio / LobeChat / Cursor / Dify.

Advanced features

Streaming, tool calls, vision, reasoning, structured output.