> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openp.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Send your first request

> Make your first call with the OpenAI SDK / cURL / Python / Node.js

This section assumes you have already:

1. Completed [registration](/en/getting-started/register).
2. [Created an API key](/en/getting-started/get-api-key).
3. Have available credit on your account (the new-user trial credit is enough).

## Basics

| Item                       | Value                                                  |
| -------------------------- | ------------------------------------------------------ |
| Base URL                   | `https://openp.ai/v1`                                  |
| Auth                       | `Authorization: Bearer sk-...`                         |
| Default protocol           | OpenAI-compatible (/v1/chat/completions, etc.)         |
| Recommended starter models | `gpt-5.5`, `claude-opus-4-8`, `gemini-3.1-pro-preview` |

## Test with cURL

```bash theme={null}
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:

```json theme={null}
{
  "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

```bash theme={null}
pip install openai
```

```python theme={null}
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

```bash theme={null}
npm install openai
```

```ts theme={null}
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:

```python theme={null}
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:

<CodeGroup>
  ```python Anthropic SDK theme={null}
  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)
  ```

  ```python google-genai SDK theme={null}
  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)
  ```
</CodeGroup>

## 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

<CardGroup cols={2}>
  <Card title="Client integrations" icon="puzzle-piece" href="/en/integrations/overview">
    Connect in Cherry Studio / LobeChat / Cursor / Dify.
  </Card>

  <Card title="Advanced features" icon="bolt" href="/en/advanced/streaming">
    Streaming, tool calls, vision, reasoning, structured output.
  </Card>
</CardGroup>
