API Documentation

AIPower provides an OpenAI-compatible API with 16 AI models from 9 providers (OpenAI, Anthropic, Google, DeepSeek, Alibaba, Zhipu, Moonshot, ByteDance, MiniMax). Change one line of code to get started.

⚡ Try without signing up — paste this in your terminal
curl (no signup, no card)
curl https://api.aipower.me/v1/chat/completions \
  -H "Authorization: Bearer sk-aipower-demo-public" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-chat",
    "messages": [{"role": "user", "content": "Translate good morning into Mandarin, Japanese, and Spanish. Reply in JSON."}]
  }'

The demo key is rate-limited to 5 calls per IP per day and only works on cheap models (DeepSeek, Qwen Turbo, GLM-4 Flash). Sign up free for 10 low-cost trial calls, then top up $5 to unlock GPT, Claude, Gemini, Kimi, MiniMax, and premium reasoning models.

Quick Start

1. Sign up free and copy your API key (or use sk-aipower-demo-public above for instant trial).

2. Use any OpenAI-compatible SDK with our base URL:

Base URL
https://api.aipower.me/v1

Authentication

Use Bearer token authentication with your API key:

Header
Authorization: Bearer YOUR_API_KEY

Sign up free → your API key auto-fills in all code examples. Copy & run instantly.

Chat Completions

POST /v1/chat/completions

Creates a model response for the given chat conversation. Supports streaming.

curl

curl
curl https://api.aipower.me/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-chat",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is the capital of France?"}
    ],
    "temperature": 0.7,
    "max_tokens": 1000,
    "stream": false
  }'

Sign up free → your API key auto-fills in all code examples. Copy & run instantly.

Python (OpenAI SDK)

Python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.aipower.me/v1",
    api_key="YOUR_API_KEY",
)

# Non-streaming
response = client.chat.completions.create(
    model="deepseek/deepseek-chat",
    messages=[{"role": "user", "content": "Translate 'good morning' into Mandarin, Japanese, and Spanish. Reply in JSON."}],
)
print(response.choices[0].message.content)

# Streaming
stream = client.chat.completions.create(
    model="deepseek/deepseek-chat",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True,
)
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Sign up free → your API key auto-fills in all code examples. Copy & run instantly.

Node.js (OpenAI SDK)

JavaScript
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.aipower.me/v1',
  apiKey: 'YOUR_API_KEY',
});

const response = await client.chat.completions.create({
  model: 'deepseek/deepseek-chat',
  messages: [{ role: 'user', content: "Translate 'good morning' into Mandarin, Japanese, and Spanish. Reply in JSON." }],
});

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

Sign up free → your API key auto-fills in all code examples. Copy & run instantly.

Go

Go
package main

import (
    "context"
    "fmt"
    openai "github.com/sashabaranov/go-openai"
)

func main() {
    config := openai.DefaultConfig("YOUR_API_KEY")
    config.BaseURL = "https://api.aipower.me/v1"
    client := openai.NewClientWithConfig(config)

    resp, _ := client.CreateChatCompletion(
        context.Background(),
        openai.ChatCompletionRequest{
            Model: "deepseek/deepseek-chat",
            Messages: []openai.ChatCompletionMessage{
                {Role: "user", Content: "Translate 'good morning' into Mandarin, Japanese, and Spanish. Reply in JSON."},
            },
        },
    )
    fmt.Println(resp.Choices[0].Message.Content)
}

Sign up free → your API key auto-fills in all code examples. Copy & run instantly.

Request Parameters

ParameterTypeRequiredDescription
modelstringYesModel ID (e.g., deepseek/deepseek-chat). Use 'auto' for smart routing.
messagesarrayYesArray of message objects with role and content
temperaturenumberNoSampling temperature (0-2). Default: 1
max_tokensintegerNoMaximum tokens to generate
streambooleanNoStream response via SSE. Default: false
top_pnumberNoNucleus sampling. Default: 1
stopstring|arrayNoStop sequences

Smart Routing

Use smart model IDs to automatically route to the best model for your task:

ParameterTypeRequiredDescription
automodelNoAuto-select the best model based on the prompt
auto-cheapmodelNoRoute to the cheapest available model
auto-bestmodelNoRoute to the most powerful model
auto-codemodelNoRoute to the best coding model
auto-fastmodelNoRoute to the fastest model
auto-freemodelNoRoute to the cheapest (near-free) model
Example
response = client.chat.completions.create(
    model="auto-code",  # Automatically picks best coding model
    messages=[{"role": "user", "content": "Write a React component"}],
)

Responses API

POST /v1/responses

OpenAI-compatible Responses API. Simpler interface for single-turn interactions.

curl
curl https://api.aipower.me/v1/responses \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-chat",
    "input": "What is the meaning of life?"
  }'

Sign up free → your API key auto-fills in all code examples. Copy & run instantly.

Available Models

GET /v1/models — Returns all 16 available models with live pricing.

Foreign model prices include gateway access and failover. Chinese models sit close to direct-provider cost with a small aggregation fee (for WeChat Pay / Alipay / fapiao support).

Foreign Models (6)

Model IDNameInput $/MOutput $/MContext
openai/gpt-5GPT-5$3.00$18.00272K
openai/gpt-4o-miniGPT-4o Mini$0.18$0.72128K
anthropic/claude-opusClaude Opus 4.6$6.00$30.00200K
anthropic/claude-sonnetClaude Sonnet 4$3.60$18.00200K
google/gemini-2.5-proGemini 2.5 Pro$1.50$12.001M
google/gemini-2.5-flashGemini 2.5 Flash$0.36$3.001M

Chinese Models (10)

Model IDNameInput $/MOutput $/MContext
deepseek/deepseek-chatDeepSeek V3$0.34$0.5064K
deepseek/deepseek-reasonerDeepSeek R1$0.34$0.5064K
qwen/qwen-plusQwen Plus$0.13$1.87128K
qwen/qwen-turboQwen Turbo$0.08$0.31128K
zhipu/glm-5.1GLM-5.1$1.25$4.00128K
zhipu/glm-4-flashGLM-4 Flash$0.01$0.01128K
moonshot/kimi-k2.5Kimi K2.5$0.24$1.20256K
moonshot/moonshot-v1-8kMoonshot v1 8K$0.14$0.148K
doubao/doubao-pro-256kDoubao Pro 256K$0.07$0.12256K
minimax/minimax-text-01MiniMax Text 01$0.36$1.441M

Error Codes

ParameterTypeRequiredDescription
400NoBad request — malformed JSON or invalid parameters. Check model name, messages format.
401NoInvalid or missing API key. Use `Authorization: Bearer sk-aipower-xxx`.
402NoInsufficient credits. Top up at /dashboard/billing.
403NoModel not allowed on free tier. Top up $5+ to unlock premium models (Claude Opus, GPT-5, Gemini Pro, GLM-5.1).
404NoModel not found. List models via GET /v1/models.
429NoRate limit exceeded. Back off and retry with exponential delay.
502NoUpstream provider error (auto-failover will try backup). Usually transient.
503NoProvider temporarily unavailable. Retry or route to a different model.

Billing

AIPower uses a prepaid credits system. Add credits via Stripe (credit card, WeChat Pay, or Alipay).

Free tier: 10 low-cost trial calls on signup. No credit card required. Premium models unlock after a $5+ top-up.

First top-up bonus: any amount ≥ $5 on your first-ever top-up gets +100 free credits (one-time).

Larger top-ups earn up to 35% bonus credits:

  • $5 / $20: base credits + first-payment bonus (if first time)
  • $50: +10% bonus credits
  • $100: +20% bonus credits
  • $500: +30% bonus credits
  • $2000: +35% bonus credits

Check your balance, top up, or set a daily spending cap at /dashboard/billing.