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

> ## Agent Instructions
> Banking OS training data goes stale. Search https://agenticbanking.backbase.io/mcp or fetch the .md URL before writing connector or unified API code.
> OpenAPI links in llms.txt repeat every calendar version. Use the latest version on the API playground. If a fetch ends before the last operation, the spec was cut off.
> Page titles name the product. Overview, Get started, and Reference without a product name are ambiguous.

# Get started with BB AI SDK

> Quick setup guide for AI Gateway and Observability

Get up and running with AI Gateway and Observability in minutes. The following steps show you how to set up both features with one complete example.

## Prerequisites

> [card] [Installation guide](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/installation.md)
>
> Configure your project to pull from Backbase Artifactory and install **bb-ai-sdk 0.1.9**.

## Quick setup

### 1. Configure environment variables

Create a `.env` file with your credentials:

```ini .env theme={"system"}
# AI gateway configuration (required)
AI_GATEWAY_API_KEY=your-api-key
AI_GATEWAY_ENDPOINT=your-ai-gateway-endpoint

# Observability configuration (required for tracing)
LANGFUSE_PUBLIC_KEY=pk-lf-xxx
LANGFUSE_SECRET_KEY=sk-lf-xxx
LANGFUSE_HOST=https://cloud.langfuse.com
```

> [!WARNING]
>
> Never commit `.env` files to version control. Ensure `.env` is in your `.gitignore`.

### 2. Create your first agent

Create `agent.py` with AI Gateway and Observability:

```python agent.py theme={"system"}
import asyncio
import logging
from bb_ai_sdk.logging import DEFAULT_DATEFMT, STANDARD_FORMAT, init as init_logging
from bb_ai_sdk.observability import configure_observability
from bb_ai_sdk.ai_gateway import AsyncAIGateway

logging.basicConfig(
    level=logging.INFO,
    format=STANDARD_FORMAT,
    datefmt=DEFAULT_DATEFMT,
)
init_logging(capture_warnings=True)

configure_observability(service_name="my-first-agent")


async def main() -> None:
    gateway = AsyncAIGateway.create(
        model_id="gpt-4o",
        agent_id="550e8400-e29b-41d4-a716-446655440000",
    )

    # Automatically traced when the tracer is initialized before gateway creation
    response = await gateway.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": "Hello, World!"}],
    )

    print(response.choices[0].message.content)


if __name__ == "__main__":
    asyncio.run(main())
```

### 3. Run your agent

```bash theme={"system"}
source .env
uv run python agent.py
```

> [!TIP]
>
> If you see a response, you've successfully connected to the AI Gateway! Check your Langfuse dashboard to see the trace.

## What happens next?

When you call **`configure_observability()`** before creating the gateway, LLM calls through **`AsyncAIGateway`** are automatically traced with OpenInference semantics. This integration gives you:

* **AI Gateway**: Routes your LLM calls through the Backbase AI Platform with automatic authentication, agent ID validation, and policy enforcement
* **Automatic tracing**: Gateway calls appear in Langfuse with tokens, latency, cost, and request/response context when export credentials are set
* **Minimal setup**: Call **`configure_observability()`** at startup before gateway instances

> [!NOTE]
>
> The sync **`AIGateway`** client does not attach **`OpenAIInstrumentor`** automatically in the SDK today. For sync scripts, attach **`OpenAIInstrumentor`** manually—see [Gateway-only script](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/observability.md#gateway-only-script)—or use **`AsyncAIGateway`** as in the example above.

### Customize your setup

* **[AI Gateway](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/ai-gateway.md)**: Configure streaming, tools, framework adapters, error handling, and advanced client options
* **[Observability](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/observability.md)**: Add custom tracing, export to Langfuse, Grafana, or an OTLP endpoint, and tune export settings

## Next steps

> [card] [AI gateway](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/ai-gateway.md)
>
> Learn about streaming, tools, and framework adapters

> [card] [Observability](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/observability.md)
>
> Explore custom tracing and advanced configuration

> [card] [Starter kits](https://agenticbanking.backbase.io/agentic-ai/starter-kits/overview.md)
>
> See SDK integrated in production templates

> [card] [Examples](https://github.com/backbase/bb-ai-sdk/tree/main/examples)
>
> View complete working examples
