---
title: "AEO API Python SDK: Setup and Method Reference | AEO API"
description: "Install aeo-sdk for Python, make requests with the sync or async client, and look up method signatures, pagination, errors and polling."
url: "https://aeoapi.dev/docs/sdks/python"
canonical: "https://aeoapi.dev/docs/sdks/python"
last_updated: "2026-12-01"
---

# AEO API Python SDK

Use `AeoClient` in scripts and synchronous applications. In an async application, use `AsyncAeoClient` and await the same methods. Both clients accept the same operation arguments.

## Install the package

With Python 3.10 or later and Git installed, clone the [Python SDK repository](https://github.com/aeo-api/aeoapi-python-sdk) and install `aeo-sdk` from it with pip.

```
git clone https://github.com/aeo-api/aeoapi-python-sdk.git
python -m pip install ./aeoapi-python-sdk
```

Import the package as `aeo_sdk`. Pip also installs its dependencies, including `httpx` 0.28 or later.

## Create a client and read the account

Set `AEO_API_BASE_URL` to `https://api.aeoapi.dev` and `AEO_API_KEY` to your server's API key. The client adds the versioned path and sends the key in the `Authorization` header. This read requires `account:read`.

```
import os
from aeo_sdk import AeoClient

with AeoClient(os.environ["AEO_API_KEY"], base_url=os.environ["AEO_API_BASE_URL"]) as client:
    response = client.v2_get_account()
    print(response.data["plan"], response.request_id)
```

The `with` block closes the client when it exits. For `AsyncAeoClient`, use `async with` and `await client.v2_get_account()`. If your application manages the client itself, call `client.close()` or `await client.aclose()` at shutdown. Both clients expose their configured origin as `client.base_url`.

## Read a response

Each operation returns a `Response` with `status`, `headers` and `body`. The client parses JSON and returns CSV as text. For responses with a `data` field, `response.data` reads that field directly.

**`meta` and `warnings`**

Metadata and warning messages from the response. Both are empty when absent.

**`request_id`**

Value of X-Request-ID. Include it when asking about a request.

**`etag`**

ETag header, when supplied. Pass its quoted numeric revision as `if_match` on operations that check it.

**`usage_units`**

Integer from X-Usage-Units, or None if the header is absent or nonnumeric.

**`location`**

Location header, when present. Some run responses also include a poll URL in the body.

**`next_cursor`**

Next cursor in the metadata or X-Next-Cursor header. None marks the end of a cursor-based list.

## Page through results or wait for a run

Use [`iter_items`](https://aeoapi.dev/docs/sdks/python/iter-items) to process records, or [`iter_pages`](https://aeoapi.dev/docs/sdks/python/iter-pages) to inspect each response. For async iteration, use `async for` with `aiter_items` or `aiter_pages`. On an offset-based list, such as drafts, pass the returned `next_offset` yourself.

Call [`wait_for_run`](https://aeoapi.dev/docs/sdks/python/wait-for-run) or [`await_run`](https://aeoapi.dev/docs/sdks/python/await-run) with a qualified run ID or poll URL. For Brave submissions, both helpers return at `submitted` or `failed`. To check the status yourself, follow the [Brave polling example](https://aeoapi.dev/docs/guides/submit-to-brave#3-check-the-outcome).

## Handle errors and set timeouts

`AeoApiError` describes an API error response. Check `code`, `status`, `retryable` and `field_errors`. A `ValidationError` can identify the input that failed. `AeoTransportError` covers a transport failure after allowed retries or an unreadable JSON success response. Both inherit from `AeoError`.

The default connection and connection-pool timeouts are 5 seconds. Read and write timeouts are 30 seconds each. To change them, pass an `httpx.Timeout` when you construct the client.

```
import os
import httpx
from aeo_sdk import AeoApiError, AeoClient, RetryPolicy

timeout = httpx.Timeout(connect=5, read=15, write=15, pool=5)
with AeoClient(
    os.environ["AEO_API_KEY"],
    base_url=os.environ["AEO_API_BASE_URL"],
    timeout=timeout,
    retry=RetryPolicy(max_retries=1),
) as client:
    try:
        account = client.v2_get_account()
    except AeoApiError as error:
        print(error.status, error.code, error.request_id)
        raise
    print(account.status)
```

## Control retries

The default `RetryPolicy` allows two extra attempts for GET requests and writes whose selected operation requires `Idempotency-Key`. A write that merely accepts an optional key does not qualify. On qualifying writes, the client keeps the same key across retry attempts.

Retries apply to transport failures, HTTP 429 and retryable HTTP 503 responses. For a numeric `Retry-After` of up to 60 seconds, the client waits that long. It raises the error for longer waits. Without a delay from the API, it chooses a random delay up to the backoff limit, starting at 0.5 seconds and doubling to a cap of 8 seconds.

Set `RetryPolicy(max_retries=0)` to turn off retries. You can also set `base_backoff`, `max_backoff` and `max_retry_after` in seconds. For offline tests, pass an `httpx.MockTransport` as `transport`. The optional `sleep` and `rng` arguments control delays and randomness in tests.

## Method reference

The examples use sample IDs, dates, revisions and content. Replace them with values from your account. The linked REST operation lists each request variant and its access requirements.

### Client and response handling

- [`AeoClient.close`](https://aeoapi.dev/docs/sdks/python/aeoclient-close)
- [`AsyncAeoClient.aclose`](https://aeoapi.dev/docs/sdks/python/asyncaeoclient-aclose)
- [`RetryPolicy.backoff`](https://aeoapi.dev/docs/sdks/python/retrypolicy-backoff)

### Pagination and run polling

- [`iter_pages`](https://aeoapi.dev/docs/sdks/python/iter-pages)
- [`iter_items`](https://aeoapi.dev/docs/sdks/python/iter-items)
- [`wait_for_run`](https://aeoapi.dev/docs/sdks/python/wait-for-run)
- [`aiter_pages`](https://aeoapi.dev/docs/sdks/python/aiter-pages)
- [`aiter_items`](https://aeoapi.dev/docs/sdks/python/aiter-items)
- [`await_run`](https://aeoapi.dev/docs/sdks/python/await-run)

### Account and usage

- [`v2_get_account`](https://aeoapi.dev/docs/sdks/python/v2-get-account)
- [`v2_patch_account`](https://aeoapi.dev/docs/sdks/python/v2-patch-account)

### Brands, locations and connections

- [`v2_get_brands`](https://aeoapi.dev/docs/sdks/python/v2-get-brands)
- [`v2_post_brands`](https://aeoapi.dev/docs/sdks/python/v2-post-brands)
- [`v2_get_brands_brand_id`](https://aeoapi.dev/docs/sdks/python/v2-get-brands-brand-id)
- [`v2_patch_brands_brand_id`](https://aeoapi.dev/docs/sdks/python/v2-patch-brands-brand-id)

### Prompts and topics

- [`v2_get_prompts`](https://aeoapi.dev/docs/sdks/python/v2-get-prompts)
- [`v2_patch_prompts`](https://aeoapi.dev/docs/sdks/python/v2-patch-prompts)
- [`v2_post_prompts`](https://aeoapi.dev/docs/sdks/python/v2-post-prompts)
- [`v2_post_runs`](https://aeoapi.dev/docs/sdks/python/v2-post-runs)

### AI answer collection and runs

- [`v2_get_runs`](https://aeoapi.dev/docs/sdks/python/v2-get-runs)
- [`v2_post_runs`](https://aeoapi.dev/docs/sdks/python/v2-post-runs)
- [`v2_delete_runs_run_id`](https://aeoapi.dev/docs/sdks/python/v2-delete-runs-run-id)
- [`v2_get_runs_run_id`](https://aeoapi.dev/docs/sdks/python/v2-get-runs-run-id)

### Site audits and page checks

- [`v2_get_analytics_dataset`](https://aeoapi.dev/docs/sdks/python/v2-get-analytics-dataset)
- [`v2_post_runs`](https://aeoapi.dev/docs/sdks/python/v2-post-runs)
- [`v2_delete_runs_run_id`](https://aeoapi.dev/docs/sdks/python/v2-delete-runs-run-id)
- [`v2_get_runs_run_id`](https://aeoapi.dev/docs/sdks/python/v2-get-runs-run-id)

### Citations

- [`v2_get_analytics_dataset`](https://aeoapi.dev/docs/sdks/python/v2-get-analytics-dataset)
- [`v2_post_runs`](https://aeoapi.dev/docs/sdks/python/v2-post-runs)
- [`v2_get_runs_run_id`](https://aeoapi.dev/docs/sdks/python/v2-get-runs-run-id)

### Answer accuracy

- [`v2_get_analytics_dataset`](https://aeoapi.dev/docs/sdks/python/v2-get-analytics-dataset)
- [`v2_post_runs`](https://aeoapi.dev/docs/sdks/python/v2-post-runs)
- [`v2_get_runs_run_id`](https://aeoapi.dev/docs/sdks/python/v2-get-runs-run-id)

### Retrieval simulator and content testing

- [`v2_post_passages_search`](https://aeoapi.dev/docs/sdks/python/v2-post-passages-search)
- [`v2_post_runs`](https://aeoapi.dev/docs/sdks/python/v2-post-runs)
- [`v2_get_runs_run_id`](https://aeoapi.dev/docs/sdks/python/v2-get-runs-run-id)

### Recommendations and visibility analyst

- [`v2_get_recommendations`](https://aeoapi.dev/docs/sdks/python/v2-get-recommendations)
- [`v2_patch_recommendations`](https://aeoapi.dev/docs/sdks/python/v2-patch-recommendations)
- [`v2_post_runs`](https://aeoapi.dev/docs/sdks/python/v2-post-runs)
- [`v2_get_runs_run_id`](https://aeoapi.dev/docs/sdks/python/v2-get-runs-run-id)

### Content drafts and editorial generation

- [`v2_get_brands_brand_id`](https://aeoapi.dev/docs/sdks/python/v2-get-brands-brand-id)
- [`v2_patch_brands_brand_id`](https://aeoapi.dev/docs/sdks/python/v2-patch-brands-brand-id)
- [`v2_get_brands_brand_id_drafts`](https://aeoapi.dev/docs/sdks/python/v2-get-brands-brand-id-drafts)
- [`v2_get_brands_brand_id_drafts_draft_id`](https://aeoapi.dev/docs/sdks/python/v2-get-brands-brand-id-drafts-draft-id)
- [`v2_patch_brands_brand_id_drafts_draft_id`](https://aeoapi.dev/docs/sdks/python/v2-patch-brands-brand-id-drafts-draft-id)
- [`v2_put_brands_brand_id_drafts_draft_id`](https://aeoapi.dev/docs/sdks/python/v2-put-brands-brand-id-drafts-draft-id)
- [`v2_post_runs`](https://aeoapi.dev/docs/sdks/python/v2-post-runs)
- [`v2_get_runs_run_id`](https://aeoapi.dev/docs/sdks/python/v2-get-runs-run-id)

### Analytics and attribution

- [`v2_get_analytics_dataset`](https://aeoapi.dev/docs/sdks/python/v2-get-analytics-dataset)
- [`v2_post_attribution_events`](https://aeoapi.dev/docs/sdks/python/v2-post-attribution-events)

### Reports and sharing

- [`v2_get_reports`](https://aeoapi.dev/docs/sdks/python/v2-get-reports)
- [`v2_patch_reports`](https://aeoapi.dev/docs/sdks/python/v2-patch-reports)

### AI search topics

- [`v2_post_runs`](https://aeoapi.dev/docs/sdks/python/v2-post-runs)
- [`v2_get_runs_run_id`](https://aeoapi.dev/docs/sdks/python/v2-get-runs-run-id)

### Brand evidence

- [`v2_delete_brands_brand_id_evidence_kind_key`](https://aeoapi.dev/docs/sdks/python/v2-delete-brands-brand-id-evidence-kind-key)
- [`v2_get_brands_brand_id_evidence_kind_key`](https://aeoapi.dev/docs/sdks/python/v2-get-brands-brand-id-evidence-kind-key)
- [`v2_put_brands_brand_id_evidence_kind_key`](https://aeoapi.dev/docs/sdks/python/v2-put-brands-brand-id-evidence-kind-key)

### Submit to Brave

- [`v2_post_runs`](https://aeoapi.dev/docs/sdks/python/v2-post-runs)
- [`v2_get_runs_run_id`](https://aeoapi.dev/docs/sdks/python/v2-get-runs-run-id)
