---
name: geekai
description: Use when building AI applications that need access to hundreds of
  models (OpenAI, Claude, Gemini, DeepSeek, etc.) through a unified API. Reach
  for this skill when you need to make chat requests, generate
  images/video/audio, handle streaming responses, implement tool calling, or
  optimize costs through routing policies.
metadata:
  mintlify-proj: geekai
  version: "1.0"
---

# GeekAI Skill Reference

## Product summary

GeekAI is a unified AI model proxy that aggregates hundreds of models from major providers (OpenAI, Claude, Gemini, DeepSeek, Grok, Zhipu, Doubao) into a single OpenAI-compatible API. Use it to build AI applications without managing separate provider accounts, learning different APIs, or tracking usage across platforms. The service offers discounted routing (10–80% of official prices), high availability, and support for chat, image generation, video, audio, embeddings, and web search. Access the API at `https://geekai.co/api/v1` (mainland China) or `https://geekai.dev/api/v1` (international). Authenticate with an API key set in the `Authorization: Bearer` header. See [Quick Start](https://docs.geekai.co/en/docs/quick_start) for setup and [Model Marketplace](https://geekai.co/models) to browse available models and pricing.

## When to use

- **Chat requests**: When you need to call any chat model (GPT, Claude, Gemini, DeepSeek, etc.) with a single endpoint and consistent request format.
- **Cost optimization**: When you want to reduce model costs by 70–90% using discounted routing policies (lowcost, balance, ha) instead of direct provider connections.
- **Multi-model applications**: When you need to switch between models or providers without rewriting integration code.
- **Streaming responses**: When you need real-time token-by-token output for chat, audio, or video generation.
- **Asynchronous tasks**: When handling long-running operations (image/video generation, reasoning, deep research) that need background processing.
- **Tool calling**: When you need models to call functions or use built-in tools (web search, image generation, code execution).
- **Multimodal input**: When you need to send images, audio, video, or PDFs alongside text in a single request.
- **Web search integration**: When you need models to search the web and cite sources in responses.

## Quick reference

### Endpoints and authentication

| Region | Base URL | Key creation |
|--------|----------|--------------|
| Mainland China | `https://geekai.co/api/v1` | [Create key](https://geekai.co/user/api_keys) |
| International | `https://geekai.dev/api/v1` | [Create key](https://geekai.dev/user/api_keys) |

Set `GEEKAI_API_KEY` environment variable or pass in `Authorization: Bearer $GEEKAI_API_KEY` header.

### Core API endpoints

| Task | Endpoint | Method |
|------|----------|--------|
| Chat completion | `/chat/completions` | POST |
| Chat result (background) | `/chat/result/{id}` | GET |
| Image generation | `/images/generations` | POST |
| Image result (async) | `/images/{task_id}` | GET |
| Video generation | `/videos/generations` | POST |
| Video result (async) | `/videos/{task_id}` | GET |
| Text-to-speech | `/audio/speech` | POST |
| Speech-to-text | `/audio/transcriptions` | POST |
| Embeddings | `/embeddings` | POST |
| Web search | `/web_search` | POST |

### Routing policies (tied to API key)

| Policy | Cost | Use case |
|--------|------|----------|
| `lowcost` | 10% of official | Testing, offline processing |
| `code` | 20% of official | AI coding tasks |
| `balance` | 30% of official | Internal business, personal use |
| `code-pro` | 40% of official | Production coding |
| `ha` | 50% of official | Enterprise applications |
| `ha-pro` | 80% of official | Premium high-availability |
| `office` | 100% of official | Direct provider connection |

Edit your API key on the [API Keys page](https://geekai.co/user/api_keys) to change routing policy. Not all models support all routes; GeekAI auto-switches to the next available route if needed.

### Common request parameters

```json
{
  "model": "gpt-6.1-sol",
  "messages": [{"role": "user", "content": "Hello"}],
  "stream": false,
  "temperature": 0.7,
  "max_completion_tokens": 2000,
  "tools": [],
  "tool_choice": "auto"
}
```

- `stream`: Set to `true` for token-by-token output (server-sent events).
- `background`: Set to `true` for async processing; returns `id` to poll later.
- `enable_search`: Enable web search (models with native search support).
- `thinking`: Configure reasoning mode (budget_tokens, reasoning_effort, thinking_level).

## Decision guidance

### When to use streaming vs. background mode

| Scenario | Use streaming | Use background |
|----------|---------------|-----------------|
| Real-time chat UI | ✓ | ✗ |
| Long-running tasks (image/video gen, deep research) | ✗ | ✓ |
| Reasoning models with high effort | ✗ | ✓ |
| Webhook/callback processing | ✗ | ✓ |
| Low-latency requirements | ✓ | ✗ |

### When to use which model type

| Need | Model examples | Notes |
|------|---|---|
| Fast, cheap chat | gpt-5-mini, gpt-4o-mini, gemini-2.5-flash | Best for most tasks |
| Complex reasoning | o3, o3-deep-research, gemini-3.1-pro | Higher cost, slower |
| Image generation | gpt-image-1, doubao-seedream-5.5, kling-image-v3 | Async recommended |
| Video generation | cogvideox-flash, kling-video-v3, sora-2 | Async required |
| Web search | gpt-5-search-api, deepseek-search, sonar | Native search built-in |
| Function calling | gpt-6.1-sol, claude-3.5-sonnet, gemini-2.5-pro | Check model marketplace |

### When to use Response API vs. Chat Completions

| Use case | Response API | Chat Completions |
|----------|---|---|
| Simple chat | ✗ | ✓ |
| Built-in tools (web search, image gen) | ✓ | ✗ |
| Function calling | ✓ | ✓ |
| Streaming | ✗ | ✓ |
| Background processing | ✗ | ✓ |

## Workflow

### 1. Make a basic chat request

1. **Set environment**: Export `GEEKAI_API_KEY` or store it securely.
2. **Choose a model**: Browse the [Model Marketplace](https://geekai.co/models) and copy the model ID (e.g., `gpt-6.1-sol`).
3. **Construct request**: Build a JSON payload with `model`, `messages`, and optional parameters.
4. **Send request**: POST to `/chat/completions` with `Authorization: Bearer` header.
5. **Parse response**: Extract `choices[0].message.content` from the JSON response.

### 2. Stream a response

1. Set `stream: true` in the request.
2. Read the response as server-sent events (SSE).
3. Parse each `data:` line as JSON until you receive `[DONE]`.
4. Concatenate `delta.content` fields to build the full response.

### 3. Handle long-running tasks (async)

1. Set `background: true` in the request (chat) or `async: true` (image/video).
2. Extract the `id` or `task_id` from the response.
3. Poll the result endpoint (`/chat/result/{id}` or `/images/{task_id}`) every 1–5 seconds.
4. Check `task_status` or `status` field: `pending`, `running`, `succeed`, or `failed`.
5. When status is `succeed`, extract the result from the response.

### 4. Call a function (tool calling)

1. Define the function schema in the `tools` array with `type`, `name`, `description`, and `parameters`.
2. Set `tool_choice: "auto"` to let the model decide when to call.
3. Send the request; the model returns `tool_calls` with `id`, `function.name`, and `function.arguments`.
4. Execute the function locally with the provided arguments.
5. Send the result back in a new message with `role: "tool"`, `tool_call_id`, and `content`.
6. The model uses the result to answer the original question.

### 5. Generate an image

1. Choose an image model (e.g., `gpt-image-1`, `doubao-seedream-5.5`).
2. POST to `/images/generations` with `model`, `prompt`, and optional `size`, `quality`, `n`.
3. For async: set `async: true` and poll `/images/{task_id}`.
4. Extract the image URL from `data[0].url` in the response.

### 6. Optimize costs

1. Identify your use case: testing, coding, production, or enterprise.
2. Create an API key and assign it a routing policy (lowcost, balance, ha, etc.).
3. Use that key for all requests in that category.
4. Monitor usage in [Billing Records](https://geekai.co/credit/transaction) to verify savings.

## Common gotchas

- **Missing `/v1` in base URL**: Some clients auto-append `/v1`. If you see `/v1/v1` in logs, remove the trailing `/v1` from your config.
- **Stream and background both true**: These are mutually exclusive. Set only one to `true`.
- **Polling too fast**: Results are retained for 7 days. Poll every 1–5 seconds, not every millisecond, to avoid rate limits (429 errors).
- **Model not available on chosen route**: Not all models support all routing policies. GeekAI auto-switches, but check the model's details page for available routes.
- **Streaming with non-streaming SDK**: If using an SDK that doesn't support streaming, set `stream: false` and wait for the full response.
- **Image/video generation without async**: Long-running tasks may timeout. Always use `async: true` for image and video generation.
- **Tool calling on unsupported models**: Function calling is not available on Baidu ERNIE or iFlytek Spark. Filter the marketplace by "Function Calling" to find compatible models.
- **Forgetting to handle SSE format in streaming**: Streaming responses use server-sent events. Parse `data:` prefixes and handle `[DONE]` terminator correctly.
- **Insufficient balance**: Error 402 means your account balance is too low. Top up on the [Recharge page](https://geekai.dev/credit/plans).
- **Rate limit (429)**: Exceeded TPM or RPM for the model. Check the model's rate limits in the marketplace and adjust request frequency.

## Verification checklist

Before submitting work with GeekAI:

- [ ] API key is set and valid (test with a simple chat request).
- [ ] Correct base URL for your region (geekai.co vs. geekai.dev).
- [ ] Model ID exists in the marketplace and supports your use case.
- [ ] Request parameters match the API reference (no typos in field names).
- [ ] For streaming: client correctly parses SSE format and handles `[DONE]`.
- [ ] For async: polling logic includes exponential backoff or reasonable intervals.
- [ ] For tool calling: function schema is valid JSON and matches the model's expectations.
- [ ] For images/video: `async: true` is set to avoid timeouts.
- [ ] Routing policy on the API key matches your cost/availability needs.
- [ ] Error handling covers 400, 401, 402, 429, 500, 503, 504 status codes.
- [ ] Token usage is tracked and monitored in billing records.

## Resources

- **Comprehensive navigation**: See [llms.txt](https://docs.geekai.co/llms.txt) for a complete page-by-page index of all documentation.
- **Quick Start**: [Make your first API call](https://docs.geekai.co/en/docs/quick_start) — setup, examples in curl/Python/JavaScript/Go.
- **Chat API Reference**: [Create a chat completion](https://docs.geekai.co/en/api/chat/completions) — full parameter documentation and response format.
- **Model Marketplace**: [Browse and filter models](https://geekai.co/models) — see pricing, routing support, and capabilities for all available models.

---

> For additional documentation and navigation, see: https://docs.geekai.co/llms.txt