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

# Create Agent

> Create a reusable agent configuration with model, instructions, and optional table binding.

## Overview

An agent defines how sessions behave — which model to use, what system instructions to follow, and optionally which table to write extracted data into.

<ParamField body="name" type="string" required>
  Human-readable name for the agent.
</ParamField>

<ParamField body="model" type="string">
  Model to use for completions. Defaults to `"default"`.
</ParamField>

<ParamField body="system" type="string">
  System instructions for the agent. Guides how the agent processes documents and uses tools.
</ParamField>

<ParamField body="table_id" type="string">
  Bind a typed table to this agent. Sessions created with this agent will have `doc_sql` and `table_sql` tools available for reading documents and writing to the table.
</ParamField>

<ParamField body="output_schema" type="object">
  JSON Schema for structured output. When set, completions will conform to this schema.
</ParamField>

<RequestExample>
  ```bash theme={null}
  curl -X POST https://api.okrapdf.com/v1/agents \
    -H "Authorization: Bearer okra_YOUR_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "invoice-extractor",
      "system": "Extract vendor, amount, and date from each invoice. Insert one row per document.",
      "table_id": "tbl_abc123"
    }'
  ```
</RequestExample>

### Response (201)

```json theme={null}
{
  "id": "agent_cf3de29f5a384695",
  "name": "invoice-extractor",
  "model": "default",
  "system": "Extract vendor, amount, and date from each invoice. Insert one row per document.",
  "table_id": "tbl_abc123",
  "output_schema": null,
  "version": 1,
  "created_at": "2026-04-14T05:30:00Z",
  "updated_at": "2026-04-14T05:30:00Z"
}
```
