> ## 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.

# Rust API Reference

> Public types and methods in phaseo 0.1.

This page describes the supported high-level API in [`phaseo 0.1`](https://docs.rs/phaseo/0.1.0/phaseo/).

## `Phaseo`

The synchronous authenticated Gateway client.

| Method                       | Returns                               | Purpose                                                                             |
| ---------------------------- | ------------------------------------- | ----------------------------------------------------------------------------------- |
| `Phaseo::new(api_key)`       | `Result<Phaseo, PhaseoError>`         | Create a client with the production base URL.                                       |
| `Phaseo::from_env()`         | `Result<Phaseo, PhaseoError>`         | Read `PHASEO_API_KEY` and optional `PHASEO_BASE_URL`.                               |
| `.with_base_url(url)`        | `Result<Phaseo, PhaseoError>`         | Replace the base URL. Remote URLs require HTTPS; exact loopback hosts may use HTTP. |
| `.with_header(name, value)`  | `Phaseo`                              | Add a header to subsequent requests.                                                |
| `.responses(request)`        | `Result<PhaseoResponse, PhaseoError>` | POST JSON to `/responses`.                                                          |
| `.chat_completions(request)` | `Result<PhaseoResponse, PhaseoError>` | POST JSON to `/chat/completions`.                                                   |
| `.post(path, request)`       | `Result<PhaseoResponse, PhaseoError>` | POST JSON to another path beneath the configured base URL.                          |

All request bodies are `&serde_json::Value`.

## `PhaseoResponse`

| Field        | Type                | Meaning                                                                      |
| ------------ | ------------------- | ---------------------------------------------------------------------------- |
| `status`     | `u16`               | HTTP status code.                                                            |
| `body`       | `serde_json::Value` | Parsed JSON response, or a JSON string when the response was not valid JSON. |
| `request_id` | `Option<String>`    | `x-request-id` response header when present.                                 |

## `PhaseoError`

| Field     | Type                        | Meaning                                             |
| --------- | --------------------------- | --------------------------------------------------- |
| `message` | `String`                    | Configuration, transport, or Gateway error message. |
| `status`  | `Option<u16>`               | Gateway HTTP status when a response was received.   |
| `body`    | `Option<serde_json::Value>` | Parsed Gateway error body when available.           |

`PhaseoError` implements `std::error::Error` and `Display`.

## Generated modules

The crate also exposes its generated OpenAPI client:

| Module               | Purpose                                                    |
| -------------------- | ---------------------------------------------------------- |
| `phaseo::gen`        | Complete generated client, models, and operations modules. |
| `phaseo::client`     | Re-export of `phaseo::gen::client`.                        |
| `phaseo::models`     | Re-export of `phaseo::gen::models`.                        |
| `phaseo::operations` | Re-export of `phaseo::gen::operations`.                    |
| `phaseo::model_ids`  | Generated Phaseo model identifiers.                        |

Generated operation names and types follow the OpenAPI output and may be lower-level than the `Phaseo` helpers. Prefer the high-level methods above for Responses and Chat Completions.

## External reference

* [`phaseo` on crates.io](https://crates.io/crates/phaseo)
* [`phaseo` on docs.rs](https://docs.rs/phaseo)
