文档

将 AIFuel 集成到你的应用所需的一切。

OpenClaw 配置指南

在 OpenClaw 中使用 AIFuel API 作为你的 AI 提供商

1. 获取 AIFuel API 密钥

访问 aifuel.fun 连接钱包并创建你的 API 密钥(格式为 fuel_sk_xxx)

2. 配置 OpenClaw

在 OpenClaw 的设置中添加 AIFuel 作为 provider:

json
{
  "models": {
    "mode": "merge",
    "providers": {
      "aifuel": {
        "baseUrl": "https://api.aifuel.fun/v1",
        "apiKey": "fuel_sk_your_api_key_here",
        "api": "openai-completions",
        "models": [
          {
            "id": "anthropic/claude-3.5-sonnet",
            "name": "Claude 3.5 Sonnet",
            "reasoning": false
          },
          {
            "id": "openai/gpt-4o",
            "name": "GPT-4o",
            "reasoning": false
          },
          {
            "id": "deepseek/deepseek-r1",
            "name": "DeepSeek R1",
            "reasoning": true
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "aifuel/anthropic/claude-3.5-sonnet"
      },
      "models": {
        "aifuel/anthropic/claude-3.5-sonnet": {},
        "aifuel/openai/gpt-4o": {},
        "aifuel/deepseek/deepseek-r1": {}
      }
    }
  }
}

配置说明

  • provider: provider 名称可以自定义(如 aifuel)
  • baseUrl: baseUrl 必须是 https://api.aifuel.fun/v1
  • apiKey: apiKey 填写你的 AIFuel 密钥
  • model id: model ID 使用 AIFuel 的完整模型 ID(如 anthropic/claude-3.5-sonnet)

3. 开始使用

配置完成后,你就可以在 OpenClaw 中使用 AIFuel 提供的所有模型了。

快速开始

1. 获取 API 密钥

首页 连接钱包并创建 API 密钥。

2. 安装 SDK

使用官方 OpenAI SDK - 我们的 API 完全兼容。

bash
# Python
pip install openai

# Node.js
npm install openai

3. 发起第一个请求

python
from openai import OpenAI

client = OpenAI(
    api_key="fuel_sk_your_key_here",
    base_url="https://api.aifuel.fun/v1"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "user", "content": "Hello, AIFuel!"}
    ]
)

print(response.choices[0].message.content)

API 参考

基础 URL

https://api.aifuel.fun/v1

认证

在 Authorization 头中包含你的 API 密钥:

http
Authorization: Bearer fuel_sk_your_key_here

端点

POST/v1/chat/completions
POST/v1/completions
POST/v1/embeddings
GET/v1/models
GET/v1/credits

可用模型

模型 ID提供商等级
openai/gpt-5.2-proOpenAIpremium
openai/gpt-5.2-codexOpenAIpremium
openai/gpt-5.2-chatOpenAIpremium
openai/gpt-5.2OpenAIpremium
openai/gpt-5.1-codex-maxOpenAIpremium
openai/gpt-5.1-codexOpenAIpremium
openai/gpt-5.1-chatOpenAIpremium
openai/gpt-5.1OpenAIpremium
openai/gpt-5-proOpenAIpremium
openai/gpt-5-imageOpenAIpremium

代码示例

Python

python
from openai import OpenAI

client = OpenAI(
    api_key="fuel_sk_xxx",
    base_url="https://api.aifuel.fun/v1"
)

# Chat completion
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain quantum computing in simple terms."}
    ],
    temperature=0.7,
    max_tokens=500
)

print(response.choices[0].message.content)

# Streaming
stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Write a short poem"}],
    stream=True
)

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

Node.js / TypeScript

typescript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'fuel_sk_xxx',
  baseURL: 'https://api.aifuel.fun/v1',
});

async function main() {
  const response = await client.chat.completions.create({
    model: 'gpt-4o',
    messages: [
      { role: 'user', content: 'Hello, AIFuel!' }
    ],
  });

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

main();

cURL

bash
curl https://api.aifuel.fun/v1/chat/completions \
  -H "Authorization: Bearer fuel_sk_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'

🔄 Switch Models (Claude, DeepSeek, Gemini)

python
# Use Claude 3.5 Sonnet
response = client.chat.completions.create(
    model="anthropic/claude-3.5-sonnet",
    messages=[{"role": "user", "content": "Explain Solana"}]
)

# Use DeepSeek R1 (reasoning)
response = client.chat.completions.create(
    model="deepseek/deepseek-r1",
    messages=[{"role": "user", "content": "Solve: x^2 + 5x + 6 = 0"}]
)

# Use Gemini 2.0 Flash
response = client.chat.completions.create(
    model="google/gemini-2.0-flash-001",
    messages=[{"role": "user", "content": "Write a haiku about coding"}]
)

额度系统

额度如何计算

你的每日额度基于持有的 $FUEL 代币计算:

每日额度 = (你的余额 / 流通量) × 每日池 × 倍数
  • 额度基于当前余额实时计算
  • 钻石手(从未转出)获得 100% 倍数
  • 曾经转出过的钱包最高 80% 倍数
  • 通过 GET /v1/credits 查询额度余额