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

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

<Info>
  **Current release:** `bb-ai-sdk` **0.1.9** on Backbase Artifactory. Pin this version in `pyproject.toml` when installing from the index (see [Installation](/agentic-ai/bb-ai-sdk/installation)). 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.
</Info>

```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

<CardGroup cols={2}>
  <Card title="AI gateway" icon="plug" href="/agentic-ai/bb-ai-sdk/ai-gateway">
    Access AI models through a unified OpenAI-compatible interface
  </Card>

  <Card title="Observability" icon="chart-line" href="/agentic-ai/bb-ai-sdk/observability">
    Trace and monitor your agents with OpenTelemetry; export to Langfuse, Grafana, or an OTLP endpoint
  </Card>

  <Card title="Logging and redaction" icon="shield-halved" href="/agentic-ai/bb-ai-sdk/logging">
    Secure logs with trace correlation; same redaction rules as span attributes
  </Card>

  <Card title="Framework adapters" icon="puzzle-piece" href="/agentic-ai/bb-ai-sdk/ai-gateway#framework-adapters">
    Integrate with LangChain, LangGraph, and Agno
  </Card>
</CardGroup>

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

<Tabs>
  <Tab title="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>

  <Tab title="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>

  <Tab title="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>

  <Tab title="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
    ```
  </Tab>
</Tabs>

## Next steps

<CardGroup cols={2}>
  <Card title="Get started" icon="rocket" href="/agentic-ai/bb-ai-sdk/get-started">
    Install the SDK and build your first agent
  </Card>

  <Card title="AI gateway" icon="plug" href="/agentic-ai/bb-ai-sdk/ai-gateway">
    Learn about model access and authentication
  </Card>

  <Card title="Observability" icon="chart-line" href="/agentic-ai/bb-ai-sdk/observability">
    Set up tracing and monitoring
  </Card>

  <Card title="Examples" icon="code" href="https://github.com/backbase/bb-ai-sdk/tree/main/examples">
    View complete working examples
  </Card>
</CardGroup>
