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

# BB AI SDK

> Python SDK for building agentic applications on Backbase Agentic AI Platform

## What is the BB AI SDK?

The **BB AI SDK** is a Python package published on Backbase Artifactory (`repo.backbase.com`) that connects your agentic applications to platform services (AI Gateway, Observability) with minimal code. It enables you to build production-ready AI agents with enterprise-grade features while maintaining complete framework flexibility.

> [!NOTE]
>
> **Current release:** `bb-ai-sdk` **0.1.9** on Backbase Artifactory. Pin this version in `pyproject.toml` when installing from the index (see [Installation](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/installation.md)). The SDK acts as a bridge between any agentic framework (Agno, LangChain, LangGraph, or custom) and Backbase platform services, requiring a few lines of code to get started.

```python theme={"system"}
from bb_ai_sdk.ai_gateway import AIGateway
from bb_ai_sdk.observability import configure_observability

# Scripts: configure once (FastAPI apps: pass fastapi_app=app — see Observability)
configure_observability(service_name="customer-support", framework="agno")

gateway = AIGateway.create(
    model_id="gpt-4o",
    agent_id="550e8400-e29b-41d4-a716-446655440000"
)

response = gateway.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)
```

## Key features

* **OpenAI-Compatible**: Works with any framework that supports OpenAI SDK
* **Automatic Authentication**: Handles API keys and agent ID validation
* **Built-in Observability**: Automatic tracing via OpenTelemetry; export to Langfuse, Grafana, or an OTLP endpoint
* **Framework-independent**: Native support for LangChain, LangGraph, and Agno
* **Zero Vendor Lock-in**: Uses standard APIs - your code is fully portable

## Core modules

> [card] [AI gateway](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/ai-gateway.md)
>
> Access AI models through a unified OpenAI-compatible interface

> [card] [Observability](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/observability.md)
>
> Trace and monitor your agents with OpenTelemetry; export to Langfuse, Grafana, or an OTLP endpoint

> [card] [Logging and redaction](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/logging.md)
>
> Secure logs with trace correlation; same redaction rules as span attributes

> [card] [Framework adapters](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/ai-gateway.md#framework-adapters)
>
> Integrate with LangChain, LangGraph, and Agno

## Why the BB AI SDK?

### Framework flexibility

Use your preferred Agentic AI framework:

* ✅ **LangChain**: Full support with adapters
* ✅ **LangGraph**: Native async integration
* ✅ **Agno**: Direct client compatibility
* ✅ **Custom**: OpenAI SDK interface works anywhere

### Enterprise features

Production-ready capabilities built-in:

* 🔐 Multi model AI Gateway with content safety filters and policies
* 📊 Observability with Langfuse, Grafana, or OTLP export via OpenTelemetry
* 🏢 Multi-tenant context tracking
* 💰 Cost tracking per organization
* 🔍 Distributed tracing across services

### Zero vendor lock-in

Your code remains portable and future-proof:

* Uses standard OpenAI SDK interface
* OpenTelemetry for observability (switch backends anytime)
* Framework-native objects - no custom abstractions
* Works with or without the platform

## Quick examples

> [tab] Basic usage
>
> ```python theme={"system"}
> from bb_ai_sdk.ai_gateway import AIGateway
>
> gateway = AIGateway.create(
>     model_id="gpt-4o",
>     agent_id="550e8400-e29b-41d4-a716-446655440000"
> )
>
> response = gateway.chat.completions.create(
>     model="gpt-4o",
>     messages=[
>         {"role": "system", "content": "You are a helpful assistant"},
>         {"role": "user", "content": "What is AI?"}
>     ]
> )
>
> print(response.choices[0].message.content)
> ```

> [tab] With LangChain
>
> ```python theme={"system"}
> from bb_ai_sdk.ai_gateway import AIGateway
> from bb_ai_sdk.ai_gateway.adapters.langchain import to_langchain
>
> gateway = AIGateway.create(
>     model_id="gpt-4o",
>     agent_id="550e8400-e29b-41d4-a716-446655440000"
> )
>
> # Convert to LangChain model
> model = to_langchain(gateway)
>
> # Use with LangChain components
> from langchain.schema.output_parser import StrOutputParser
>
> chain = model | StrOutputParser()
> response = chain.invoke("Tell me a joke")
> print(response)
> ```

> [tab] With LangGraph
>
> ```python theme={"system"}
> from langgraph.graph import StateGraph, END
> from bb_ai_sdk.ai_gateway import AsyncAIGateway
> from bb_ai_sdk.ai_gateway.adapters.langchain import to_langchain_async
>
> gateway = AsyncAIGateway.create(
>     model_id="gpt-4o",
>     agent_id="550e8400-e29b-41d4-a716-446655440000"
> )
>
> model = to_langchain_async(gateway)
>
> async def generate(state):
>     response = await model.ainvoke(state["messages"])
>     return {"messages": [response]}
>
> graph = StateGraph(AgentState)
> graph.add_node("generate", generate)
> graph.add_edge("generate", END)
> graph.set_entry_point("generate")
>
> app = graph.compile()
> ```

> [tab] With observability
>
> ```python theme={"system"}
> 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 AIGateway
>
> logging.basicConfig(
>     level=logging.INFO,
>     format=STANDARD_FORMAT,
>     datefmt=DEFAULT_DATEFMT,
> )
> init_logging(capture_warnings=True)
>
> configure_observability(
>     service_name="my-agent",
> )
>
> # Gateway calls are automatically traced
> gateway = AIGateway.create(
>     model_id="gpt-4o",
>     agent_id="550e8400-e29b-41d4-a716-446655440000"
> )
>
> response = gateway.chat.completions.create(
>     model="gpt-4o",
>     messages=[{"role": "user", "content": "Hello"}]
> )
>
> # View traces in Langfuse dashboard
> ```

## Next steps

> [card] [Get started](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/get-started.md)
>
> Install the SDK and build your first agent

> [card] [AI gateway](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/ai-gateway.md)
>
> Learn about model access and authentication

> [card] [Observability](https://agenticbanking.backbase.io/agentic-ai/bb-ai-sdk/observability.md)
>
> Set up tracing and monitoring

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