# SDK quickstart for Python

> Install the typed Agent Router Python SDK from the local sdist and make a first read-only identity (whoami) call against the gateway.

# SDK quickstart for Python

  This quickstart installs the typed Agent Router SDK for Python, then makes a first read-only identity lookup (whoami) against the gateway. The lookup resolves the identity behind an API key with a <code>GET /v1/me</code> call and is safe to run as-is, so it confirms that the SDK, the key, and the base URL are wired together correctly before any billable request is sent.

## Prerequisites

Two values and a runtime are required before starting:

- **An Agent Router API key.** Keys are minted in the Console or with the `tare` CLI. The secret is shown once, in the form `<keyid>.<secret>`, so it must be copied immediately. See [Make an API call](/agent-router-service/quickstarts/make-an-api-call) for the key-minting steps.
- **The gateway base URL** for the deployment, in the form `https://api.<your-domain>`. For the hosted service this is `https://api.tetrate.ai`.
- **A currently supported Python 3 runtime**, with `pip` available.

The SDK reads both values from the environment:

```bash
export AGENTROUTER_BASE_URL=https://api.<your-domain>
export AGENTROUTER_API_KEY=<keyid>.<secret>
```

## Install the SDK

The Python SDK is distributed as a source distribution (sdist) from the public stable channel and is installed from the local file rather than from PyPI. Replace `<version>` with the version shown on the [SDKs](/reference/sdk/) page.

```bash
curl -fLO https://tare.tetrate.ai/tools/sdks/stable/agentrouter-python-<version>.tar.gz
pip install ./agentrouter-python-<version>.tar.gz
```

Installing into a virtual environment is recommended, so the SDK and its dependencies are isolated from other projects:

```bash
python -m venv .venv && source .venv/bin/activate
pip install ./agentrouter-python-<version>.tar.gz
```

## Make the first call

Save the program below as `main.py`. It constructs a client from the two environment variables, calls `client.me.get()` (the read-only `GET /v1/me` endpoint), and prints the resolved identity.

```python title="main.py"
"""Runnable example for the Agent Router Python SDK.

Set AGENTROUTER_BASE_URL and AGENTROUTER_API_KEY in the environment, then run `python main.py`.
"""
import os

from agentrouter_sdk import Client

client = Client(
    base_url=os.environ["AGENTROUTER_BASE_URL"],
    api_key=os.environ["AGENTROUTER_API_KEY"],
)

try:
    result = client.me.get()
    print(result)
except Exception as err:
    print("Error:", err)
```

Run the program from the directory containing `main.py`:

```bash
python main.py
```

A successful run prints the identity associated with the API key. Because `GET /v1/me` only reads identity metadata, the call incurs no model usage and can be repeated freely while verifying setup.

Related references

  <Link to="/reference/sdk/" className="tare-nav-card">
    SDK Reference
    Download the SDK archives and API specifications, with versions and checksums.
  </Link>
  <Link to="/agent-router-service/quickstarts/make-an-api-call" className="tare-nav-card">
    Make an API call
    Mint a key with the tare CLI and make a first routed request across languages.
  </Link>
  <Link to="/reference/api/" className="tare-nav-card">
    Management API reference
    The HTTP endpoints the SDK calls, including the identity and inference APIs.
  </Link>
