> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Phaseo Gateway base URL: https://api.phaseo.app/v1. Send `Authorization: Bearer $PHASEO_API_KEY` with every request.
> Model IDs look like `provider/model`, for example `openai/gpt-6-astra`. Do not guess IDs: list them with `GET /v1/models` or check https://phaseo.app/models. `phaseo/free` routes to an available free model and needs no wallet balance.
> For new text integrations prefer `POST /v1/responses`. `POST /v1/chat/completions` (OpenAI format) and `POST /v1/messages` (Anthropic format) suit existing code.
> The full API contract is https://phaseo.app/docs/openapi/v1/openapi.yaml. Official SDKs: `@phaseo/sdk` (TypeScript) and `phaseo` (Python), plus Go, C#, PHP, Ruby and Rust.
> Search these docs over MCP at https://phaseo.app/docs/mcp, and install Phaseo skills with `npx skills add https://phaseo.app/docs`. If a page is wrong or out of date, report it with the MCP `submit_feedback` tool.
> Manage Phaseo accounts with the `phaseo` CLI (`npm install -g @phaseo/cli`, then `phaseo login` or `phaseo login --device-code`), the `/v1` Management API or the MCP server at `https://mcp.phaseo.app/mcp?access=manage`. Do not send users to the dashboard for account tasks. A person is still needed for sign-up, approving a sign-in, paying the first top-up on the checkout link that `phaseo credits add` returns when no card is saved, confirming each saved-card top-up from the emailed link, and account security (password, MFA, passkeys). Create API keys with `phaseo keys create --name <name> --json`; never guess one. Credit top-ups need `phaseo login --scopes billing:write` first. Task map: https://phaseo.app/docs/v1/developers/manage-from-an-agent.md.

# Agent SDK Overview

> Build local, resumable agent loops on top of Phaseo Gateway across the supported Agent SDK languages.

Use the Phaseo Agent SDKs when your application needs more than one-shot generation:

* multi-step tool loops
* local runtime tools
* gateway-backed model turns
* resumable application-owned run state
* exact-call approvals, human-in-the-loop tools, manual tools, and resumable continuation
* runtime validation, progress-producing tools, and recoverable tool errors
* streamed model output with replayable event consumers
* dynamic turn configuration, composable stop conditions, and normalized usage/cost
* model retries, tool timeouts, bounded tool concurrency, and lifecycle events
* local Phaseo Devtools capture
* consistent request routing across the same languages as the core client SDKs

## Supported languages

The current Agent SDK language set matches the primary client SDK set exposed in Phaseo quickstart:

* [TypeScript](https://phaseo.app/docs/v1/sdk-reference/typescript/agent-sdk.md)
* [Python](https://phaseo.app/docs/v1/sdk-reference/python/agent-sdk.md)
* [Go](https://phaseo.app/docs/v1/sdk-reference/go/agent-sdk.md)
* [C#](https://phaseo.app/docs/v1/sdk-reference/csharp/agent-sdk.md)
* [PHP](https://phaseo.app/docs/v1/sdk-reference/php/agent-sdk.md)
* [Ruby](https://phaseo.app/docs/v1/sdk-reference/ruby/agent-sdk.md)
* [Rust](https://phaseo.app/docs/v1/sdk-reference/rust/agent-sdk.md)

Ask a coding agent to build a first agent with the Phaseo Agent SDK in your language.

Build a small agent in this project with the Phaseo Agent SDK.

&#x20; 1\. Install the Phaseo skills: npx skills add [https://phaseo.app/docs](https://phaseo.app/docs)
&#x20;  For TypeScript, follow the phaseo-agent-sdk-typescript skill.
&#x20; 2\. Read the Agent SDK page for this project's language at [https://phaseo.app/docs/v1/sdk-reference/agent-sdk/overview](https://phaseo.app/docs/v1/sdk-reference/agent-sdk/overview.md) and use only the APIs it documents.
&#x20; 3\. Define one agent with at most two local tools that fit \[AGENT TASK]. Keep the loop bounded with a step limit, and require approval for any tool that changes data.
&#x20; 4\. Use a server-side PHASEO\_API\_KEY and check the model ID with GET /v1/models before using it.
&#x20; 5\. Stream the agent's steps to the console so a run can be inspected.
&#x20; 6\. Run the agent once, then report what you verified and what you could not verify.

## Common model

Each Agent SDK keeps the same runtime model:

* define one agent
* define zero or more local tools
* create a gateway-backed model client
* run a bounded loop over the `responses` API
* inspect lifecycle events or a Devtools trace
* persist the returned run and resume after a human decision

TypeScript is the reference API design. Python, Go, C#, PHP, and Ruby expose the broader cross-language contract using language-native callbacks, concurrency, timeout, and cancellation primitives. Rust is a supported synchronous runtime with local and external tools, exact-ID approvals, human review, model retries, serializable run state, lifecycle callbacks, and usage aggregation. Java and C++ remain work in progress.

> [!NOTE]
>
> The Rust Agent SDK is published as [`phaseo-agent`](https://crates.io/crates/phaseo-agent). It does not yet include streaming, async execution, concurrent local tools, runtime schema validation, or Devtools capture.

## Cross-language capability contract

| Capability | TypeScript | Python | Go | C# | PHP | Ruby | Rust |
| - | - | - | - | - | - | - | - |
| Executable tools and recoverable tool errors | Yes | Yes | Yes | Yes | Yes | Yes | Synchronous |
| Exact-ID approvals, HITL, and manual outputs | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Preliminary tool progress | Async generator | Iterator or callback | Callback | Callback | Callback | Callback | Not yet |
| Model streaming and replayable consumers | Async iterable | Iterator | Channel | Async enumerable | Iterable | Enumerator | Not yet |
| Composable stop conditions | Yes | Yes | Yes | Yes | Yes | Yes | Step limit |
| Dynamic turns and mutable context | Yes | Yes | Yes | Yes | Yes | Yes | Per-run model, step limit, and context |
| Application-owned persisted run state | Yes | Yes | Yes | Yes | Yes | Yes | Serializable `RunResult` |
| Normalized usage and cost | Yes | Yes | Yes | Yes | Yes | Yes | Tokens; custom-client cost only in `0.1` |

PHP and Ruby expose provider stream events through their normal synchronous iteration APIs. They do not require a hosted runtime or a background Phaseo service.

## Client SDK, Agent SDK, and API

| Use | Choose | What it owns |
| - | - | - |
| One API request or full endpoint coverage | Client SDK | Generated API types and transport |
| Tool-using, multi-step application logic | Agent SDK | Local loop, tools, checkpoints, review, events, and Devtools |
| Custom transport or an unsupported language | Raw API | HTTP request and response handling |

Agent SDK gateway adapters delegate model turns to the matching Client SDK. Languages with a `requestOptions` or equivalent hook can pass additional Responses API fields through while the Agent SDK continues to own `model`, `input`, `instructions`, and local function tools. The Rust `0.1` adapter currently sends the normalized agent fields without an additional request-options hook.

## Recipes

The cookbook includes TypeScript workflows and language-specific starting points:

* [Build a durable agent loop](https://phaseo.app/docs/v1/cookbook/agent-sdk-durable-loop.md)
* [Research with agent-backed web search](https://phaseo.app/docs/v1/cookbook/agent-sdk-research-brief.md)
* [Triage support with preset-driven agents](https://phaseo.app/docs/v1/cookbook/agent-sdk-support-triage.md)
* [Review code with local runtime tools](https://phaseo.app/docs/v1/cookbook/agent-sdk-coding-review.md)
* [Fan out local tools concurrently](https://phaseo.app/docs/v1/cookbook/agent-sdk-parallel-tools.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.