Skip to main content

将 OpenAI Agents SDK (Python) 连接到 aicharged.io

215 个工具,一个端点:https://aicharged.io/api/v1/mcp

OpenAI Agents SDK (Python)

OpenAI Agents SDK for Python:带 Authorization 请求头的 MCPServerStreamableHttp,通过 mcp_servers 传给智能体。

  • API 密钥(Bearer)

智能体代码

推荐
import asyncio, os
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

async def main():
    async with MCPServerStreamableHttp(
        name="aicharged",
        params={
            "url": "https://aicharged.io/api/v1/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['AICHARGED_API_KEY']}"},
            "timeout": 30,
        },
    ) as server:
        agent = Agent(name="Assistant", instructions="Use the aicharged.io tools.", mcp_servers=[server])
        result = await Runner.run(agent, "List my recent aicharged.io runs")
        print(result.final_output)

asyncio.run(main())

安装软件包

pip install openai-agents

或者让 CLI 自动设置

aicharged setup 会自动查找此电脑上的 AI 客户端,通过浏览器引导您登录,并写入相应的配置。

一行命令,轻松连接

安装 CLI · macOS / Linux
curl -fsSL https://aicharged.io/install.sh | sh && aicharged setup
安装 CLI · Windows
irm https://aicharged.io/install.ps1 | iex; aicharged setup
MCP 端点
https://aicharged.io/api/v1/mcp

流式 HTTP。发送 Authorization: Bearer <API_KEY> 请求头,或者在客户端支持的情况下通过 OAuth 登录。

或者告诉您的智能体
阅读 https://aicharged.io/agent.md,并为我设置 aicharged.io

使用此提示词打开于 Claude (在新标签页中打开) ChatGPT (在新标签页中打开) Perplexity (在新标签页中打开)