LogoAICore Docs

快速开始

AiCore API 快速接入与使用指南

🔥 系统简介

AiCore API 提供多模型、多功能的 AI 服务接口,兼容 OpenAI、Claude、Midjourney 等主流平台,支持对话、绘图等多种 AI 能力,助力开发者快速集成智能应用。

⛱️ 主要特性

  • 多模型兼容:支持 GPT、Claude、Gemini、Deepseek 等主流大模型
  • 标准接口:遵循 OpenAI API 标准,易于迁移和集成
  • 高质量绘图:集成 Midjourney,支持高质量 AI 绘图
  • 统一格式:接口风格统一,调用方式简洁
  • 丰富文档:提供详细说明和多语言示例代码

🔖 快速上手

1. 获取 API Key

您可以通过以下两种方式获取 API Key:

  • 淘宝购买:访问淘宝店铺下单,系统自动发货,消息列表领取
  • 控制台自助创建:登录 API 控制台,在“API 令牌”页面添加令牌,设置名称、额度和权限后即可获得

2. 配置接口地址

调用 API 时请将 BaseURL 设置为:

  • 主地址:https://api.xty.app(备用加速:https://hk.xty.app
  • 带版本路径:https://api.xty.app/v1(备用加速:https://hk.xty.app/v1

如使用第三方 SDK,请将默认的 https://api.openai.com 替换为上述地址。

3. 调用示例

curl https://api.xty.app/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ],
    "stream": false
  }'
fetch('https://api.xty.app/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    model: "gpt-4o",
    messages: [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ],
    stream: false
  })
})
.then(response => response.json())
.then(data => console.log(data));
import requests
import json

url = "https://api.xty.app/v1/chat/completions"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_API_KEY"
}
data = {
    "model": "gpt-4o",
    "messages": [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"}
    ],
    "stream": False
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
from openai import OpenAI
import httpx

client = OpenAI(
    base_url="https://api.xty.app/v1",
    api_key="sk-xxx",
    http_client=httpx.Client(
        base_url="https://api.xty.app/v1",
        follow_redirects=True,
    ),
)

completion = client.chat.completions.create(
  model="gpt-3.5-turbo",
  messages=[
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ]
)

print(completion)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class ChatExample {
    public static void main(String[] args) throws Exception {
        String url = "https://api.xty.app/v1/chat/completions";
        String apiKey = "YOUR_API_KEY";
        String requestBody = "{\"model\":\"gpt-4o\",\"messages\":[{\"role\":\"system\",\"content\":\"You are a helpful assistant.\"},{\"role\":\"user\",\"content\":\"Hello!\"}],\"stream\":false}";

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Content-Type", "application/json")
                .header("Authorization", "Bearer " + apiKey)
                .POST(HttpRequest.BodyPublishers.ofString(requestBody))
                .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

🔐 密钥管理

  • 支持创建、禁用、删除 API 密钥
  • 可设置密钥权限和配额,查看使用情况
  • 请妥善保管密钥,避免泄露

🏷️ 免责声明

API 服务可能会根据实际情况调整,请关注更新通知。使用时请遵守相关法律法规和服务条款。

💬 技术支持

如有疑问,请联系微信客服:

微信联系方式