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

# Call Global AI: OpenAI, Claude, and Gemini Formats

> Get the Global AI API address, call with the OpenAI SDK or native Claude and Gemini formats, and review supported endpoints.

Global AI exposes an OpenAI-compatible API and also supports the native Claude and Gemini formats. Use the platform address as `base_url` and your [token](/en/usage/tokens) as `api_key` to start calling.

<h2 id="playground-online-testing">
  Playground online testing
</h2>

The playground is a built-in test tool that lets you chat with any model without writing code. It is a quick way to verify tokens and models.

<Steps>
  <Step title="Open the playground">
    Click **Playground** in the left sidebar, or go directly to [https://globalai.vip/playground](https://globalai.vip/playground).
  </Step>

  <Step title="Choose a model">
    Pick the model to test from the selector in the lower right of the page.
  </Step>

  <Step title="Send a message">
    Type a message and hit send. The reply appears in the conversation area on the right.
  </Step>
</Steps>

<Tip>
  Playground calls consume quota just like code calls, and they are recorded in [Logs](/en/usage/logs) so you can compare with production usage.
</Tip>

## Get the API address

<Steps>
  <Step title="Copy the base URL">
    Visit the home page, find the API base URL area in the middle of the page, and click the copy button. Example: `https://globalai.vip/v1`.
  </Step>

  <Step title="Paste into your client">
    Use the copied address as `base_url` in your client or code, together with the token key, to start calling.
  </Step>
</Steps>

<Note>
  `base_url is https://globalai.vip/v1`
</Note>

## Code examples

### Python (OpenAI SDK)

```python app.py icon=python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxxxxxx",              # Token issued by the platform
    base_url="https://globalai.vip/v1",
)

response = client.chat.completions.create(
    model="gpt-5.6-sol",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
```

### Streaming output

```python stream.py icon=python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxxxxxx",
    base_url="https://globalai.vip/v1",
)

stream = client.chat.completions.create(
    model="gpt-5.6-sol",
    messages=[{"role": "user", "content": "Introduce quantum computing in one sentence"}],
    stream=True,
)
for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)
```

### JavaScript / Node.js

```javascript app.js icon=js theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "sk-xxxxxxxx",
  baseURL: "https://globalai.vip/v1",
});

const response = await client.chat.completions.create({
  model: "gpt-5.6-sol",
  messages: [{ role: "user", content: "Hello" }],
});

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

### Shell / curl

```bash chat.sh icon=terminal theme={null}
curl https://globalai.vip/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxx" \
  -d '{
    "model": "gpt-5.6-sol",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
```

### Native Claude format

```bash Claude icon=terminal theme={null}
curl https://globalai.vip/v1/messages \
  -H "x-api-key: sk-xxxxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'
```

### Native Gemini format

```bash Gemini icon=terminal theme={null}
curl "https://globalai.vip/v1beta/models/gemini-3.7-flash:generateContent?key=sk-xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"parts": [{"text": "Hello"}]}]
  }'
```

## Supported endpoints

Global AI is compatible with the most common OpenAI ecosystem endpoints. Trust the [Pricing](/en/billing/pricing) page in the console as the source of truth for which models are available.

| Endpoint         | Path                                          | Description                                    |
| ---------------- | --------------------------------------------- | ---------------------------------------------- |
| Chat completions | `POST /v1/chat/completions`                   | Conversation generation with streaming support |
| Text completions | `POST /v1/completions`                        | Legacy completion endpoint                     |
| Embeddings       | `POST /v1/embeddings`                         | Text vectorization                             |
| Image generation | `POST /v1/images/generations`                 | Text to image                                  |
| Image editing    | `POST /v1/images/edits`                       | Image editing                                  |
| Speech to text   | `POST /v1/audio/transcriptions`               | Whisper and similar                            |
| Text to speech   | `POST /v1/audio/speech`                       | TTS                                            |
| Rerank           | `POST /v1/rerank`                             | Document reranking                             |
| Responses API    | `POST /v1/responses`                          | OpenAI Responses format                        |
| Realtime         | `GET /v1/realtime` (WebSocket)                | OpenAI Realtime API                            |
| Claude messages  | `POST /v1/messages`                           | Anthropic native format                        |
| Gemini generate  | `POST /v1beta/models/{model}:generateContent` | Google native format                           |
| Model list       | `GET /v1/models`                              | Query available models                         |

Global AI also exposes a balance query endpoint for automation scripts and third-party dashboards.

```bash Balance query icon=terminal theme={null}
curl -X GET "https://globalai.vip/api/user/self" \
  -H "new-api-user: [your user ID, the small number next to your username on the profile page]" \
  -H "Authorization: Bearer [obtain from Profile > Security > Access token]" \
  -H "Accept: */*" \
  -H "Host: globalai.vip" \
  -H "Connection: keep-alive"
```

In the returned JSON, `quota / 500000` is the current remaining balance.

<h2 id="common-errors">
  Common errors
</h2>

<AccordionGroup>
  <Accordion title="401 Unauthorized / invalid api key">
    Verify the token key is correct, not expired, and not deleted. Check the token status in [Token management](/en/usage/tokens).
  </Accordion>

  <Accordion title="403 Forbidden / model not allowed">
    The token has a model restriction or IP allowlist that the current request violates. Edit the token to adjust the settings, or switch to a permitted model or network.
  </Accordion>

  <Accordion title="Insufficient balance">
    The account or token has run out of quota. Top up on [Quota and top-up](/en/billing/topup), or raise the token's quota cap.
  </Accordion>

  <Accordion title="429 Too Many Requests">
    You hit the platform rate limit. Wait a moment and retry, or reduce concurrency.
  </Accordion>
</AccordionGroup>


## Related topics

- [Global AI Token Management: Create, Limit, and Secure](/en/usage/tokens.md)
- [Welcome to Global AI](/en/index.md)
- [Add Global AI to Dify as a Model Provider](/en/clients/dify.md)
- [ChatWise Setup: Unified Multi-Provider Access via Global AI](/en/clients/chatwise.md)
- [Global AI Quickstart: From Sign-Up to First API Call](/en/quickstart.md)
