Connect ChatGPT and the OpenAI API
You need an API key; go through Essentials first. For Codex, OpenAI's coding agent, see Coding agents.
OpenAI API (Responses)
The OpenAI Responses API can use remote MCP servers and send them headers. It is the recommended way today to connect OpenAI models to Autonex:
from openai import OpenAI
import os
client = OpenAI()
resp = client.responses.create(
model="gpt-5",
input="Which classes are still uncovered tomorrow at the Joan Miró centre?",
tools=[{
"type": "mcp",
"server_label": "autonex",
"server_url": "https://mcp.autonexhub.es/mcp",
"headers": {"Authorization": f"Bearer {os.environ['AUTONEX_MCP_KEY']}"},
"require_approval": "always",
}],
)
print(resp.output_text)With require_approval: "always" your application decides on every call. At the very least, require approval for confirm_action, the tool that applies changes.
ChatGPT (app)
Custom connectors in the ChatGPT app authenticate with OAuth. OAuth access to the Autonex MCP is planned; we will announce it when it is available. Meanwhile, use the API as in the example above, or the OpenAI Agents SDK with an HTTP MCP server and the same header.
Tips
- Use a personal key if the assistant acts on behalf of a person, and a service key for an automated process.
- Limit the scopes to what the assistant needs (for example, only
…:read).