/v1. Use the official OpenAI SDK or plain HTTP. This guide shows both for every common operation, and notes where Core differs from OpenAI.
New to the API? Run the quickstart first.
Before you start
Base URL and key. Your administrator gives you the API base URL, such ashttps://core.example/v1, and a Project API key.
/agents and /vaults also need OpenAI-Beta: agents=v1; /files and /skills do not. The SDK sets both. The HTTP examples below use this shell helper:
-H @<(printf 'Authorization: Bearer %s\n' "$OPENAI_API_KEY") keeps the key out of the process list.
Resources at a glance
Core has exactly the routes of the pinned SDK, listed in upstream-routes.json. It adds no route; its additions live in
x_agents_core.
Common tasks
Conventions
Pagination
Lists return:
The SDK pages for you:
GET /files returns up to 10,000 files at once, and workspace files use an opaque page token (see Workspace files).
Idempotency
Send anIdempotency-Key (up to 128 bytes) when creating a Session or sending input. A retry with the same key and body returns the original result instead of doing the work twice. The same key with a different body fails with 409 idempotency_conflict.
Errors
Every response carries
X-Request-Id; include it when reporting a problem.
Core extensions: x_agents_core
Core runs several harnesses and accepts your own model access. Those settings are the only additions to the OpenAI shapes, and they sit inside x_agents_core:
Any other member is rejected with 400.
api_key is write-only: reads return api_key_configured. harness_config replaces the whole object; {} clears it. With the SDK, pass these through extra_body.
Choose a harness and a model
The harness is the agent program that runs a Session: Codex (codex), Claude Code (claude_sdk) or MiniMax Code (mcode). Set x_agents_core.harness on the Agent or the inline agent; without it, the installation’s default harness applies (core.default_harness, Codex unless the operator changed it).
- Model.
modelis the provider’s exact model ID. An inline Agent on anopenai_hostedornoneSession may omit it to use the default model configuration of its harness. A saved Agent always needs one. - Provider. The harness calls your provider directly, with one of the harness’s native protocols; there is no conversion, and a mismatch is rejected when the Session is created. Model execution lists each harness’s protocols and which provider a Session uses on each Environment type. A Session freezes its provider at creation.
- Native parameters.
harness_configcarries the harness’s own model settings; see native model parameters.
Agents
An Agent is saved configuration. Sessions copy it when they start, so editing an Agent affects only new Sessions.
(
agents is client.beta.agents throughout.)
- Update changes only the fields you send.
metadatareplaces all pairs;nullclearsnameorinstructions. - Delete keeps existing Sessions.
- Tools are functions, MCP servers,
tool_search(Claude) andweb_searchwithmode: "disabled". Support depends on harness and Environment; see execution tools.
Sessions
A Session is one conversation with a fixed configuration and its own Environment.Create a Session
A new
openai_hosted Session reads idle while Core prepares its sandbox; its first Turn starts when the Environment is ready. The Environment contract owns placement, expiry and preparation.
Session status
Readstatus, error and required_actions to decide whether to send input, return a function result, connect a machine or diagnose a failure. Session status defines every state and which failures allow new input.
Update, list and delete
Send input
All input goes to one endpoint as a list of events. It returns 202 after durable admission, before native application. On an idleopenai_hosted or self_hosted Session, a message request can wait up to five minutes for its Turn to start and can end with a 409 expiry, cancellation or Environment error; allow that wait in client timeouts (Environment input).
Send a message
- When idle, a message starts a new Turn. While a Turn runs, it joins that Turn (steering); it does not start a parallel task.
- Content is
input_text, plusinput_imageas an inline PNG or JPEG data URI. Codex and Claude Code accept images; MiniMax Code rejects them. The whole request is limited to 1 MiB. - Full rules: message content.
Cancel
cancelled, not when the request returns. A cancel while idle does nothing when no input is pending; a pending Environment input reservation returns 409. A self-hosted machine keeps its workspace and history when you restart the same installation; see operate the installation.
Stream events
GET /agents/sessions/{id}/events is a server-sent event stream. It is live only: events sent while you were disconnected are not replayed. Open it before sending input, and recover gaps from Turns and Items.
The stream stays open across Turns. To stream one Turn and handle function calls automatically, the SDK’s
sessions.stream helper does both.
Stream the creation itself with stream=True on sessions.create. You get agent.session.created first, and the stream ends at the first idle or failed.
Reconnecting: resubscribe, then read Items and drop any you already have by ID. An open stream closes when its Project key is revoked or its Project archived. Details: recovery model.
Turns and Items
A Turn is one piece of work started by input. Items are its recorded content: messages, reasoning, tool calls and their results. Both are durable; read them to check results or recover after a disconnect.- Usage (
input_tokens,output_tokens,total_tokens, …) is null when unknown, never zero. A Session’s usage stays null while a Turn runs; Claude Code and MiniMax Code report none (usage rules). - Turn lists contain top-level Turns only. Read child work under
/subagents.
Function tools
Declare a function on the Agent. When the model calls it, the Session entersrequires_action and the Turn waiting until you return a result.
session.required_actions, then send:
Files
Three kinds of file serve different purposes:Source Files
purpose=user_data is accepted, up to 512 MiB. No Beta header. Their content cannot be downloaded again; use the ID in workspace files or templates.
Workspace files
Copy a file into the workspace of the Session’s Environment (session.environment.id):
inlinedata is base64, up to 5 MiB decoded;file_idup to 50 MiB.- Parent directories are created. An existing file is never overwritten (400).
- The list shows regular files in one directory, not recursively. It pages with a
pagetoken and returnsnext.
Artifacts
When a Turn completes, Core captures the regular files under the workspace’soutputs/ directory. Artifacts stay readable after the Environment is gone.
path, size_bytes, turn_id and environment_id. Deleting one leaves the workspace file alone.
Skills
A Skill is a versioned bundle of instructions and files an agent can use. Upload a directory or a ZIP; each upload is a version.- No Beta header. Select up to 50 Skills per Environment; each archive is at most 5 MiB compressed and 20 MiB expanded.
- SDK 3.13.0 drops a single ZIP file from the upload; use HTTP for a ZIP.
- Attach Skills to a Session through its
environment.skillsor a template.
Environment Templates
A template saves workspace setup for reuse.openai_hosted Sessions reference it in environment; self_hosted Sessions in x_agents_core.environment:
A Session freezes the template when it starts. Details: Environment Templates.
Vaults
Vaults hold credentials for HTTP MCP servers: astatic_bearer token or an mcp_oauth token with optional refresh. Tokens are write-only.
/vaults, with the Beta header. A Session selects credentials from its vault_ids, optionally by credential_id; the MCP server’s URL must match the selected credential’s mcp_server_url exactly in either case. The Vaults contract owns selection, errors, OAuth refresh and deletion. An MCP tool’s connection_origin decides whether Core’s side or the workspace connects to the server, and each harness supports a different set: see MCP connection origin.
Diagnose a failure
- Read the Session’s
statusanderror, and the latest Turn’serror. A failed Turn reports only a genericinternal_error. - Check that the Environment is connected and its harness is available.
- Check the harness, model and tool combination in Harness capabilities.
- Ask the administrator for the Session’s diagnostics, which name the failure category, and to check troubleshooting for service logs, credentials and node readiness.