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

# Aleph Alpha

> Trace Aleph Alpha model calls with Netra auto-instrumentation. Monitor prompts, completions, token usage, and performance metrics automatically.

<img src="https://mintcdn.com/netra/u6ajHWd7ki_9CRWQ/images/integration-logos/llm-providers/aleph-alpha.png?fit=max&auto=format&n=u6ajHWd7ki_9CRWQ&q=85&s=3ca6ec16e98405bec642c867faf2d298" alt="Aleph Alpha" width="332" height="80" data-path="images/integration-logos/llm-providers/aleph-alpha.png" />

## Installation

To use Aleph Alpha with Netra SDK, install both packages:

<CodeGroup>
  ```bash Python theme={null}
  pip install netra-sdk aleph-alpha-client
  ```

  ```bash Typescript theme={null}
  npm install netra-sdk aleph-alpha-client
  ```
</CodeGroup>

The Netra SDK automatically instruments Aleph Alpha API calls when initialized, providing comprehensive tracing and observability for your language model interactions.

## Usage

## Basic Setup

Initialize the Netra SDK with your API key to enable automatic instrumentation of Aleph Alpha calls.

<CodeGroup>
  ```python Python theme={null}
  from netra import Netra

  # Initialize Netra with your API key
  Netra.init(
      app_name="my-aleph-alpha-app",
      headers=f"x-api-key={os.environ['NETRA_API_KEY']}",
      trace_content=True
  )

  # Your Aleph Alpha code will be automatically traced
  ```

  ```typescript TypeScript theme={null}
  import { Netra } from "netra-sdk";

  // Initialize Netra with your API key (must await)
  await Netra.init({
    appName: "my-aleph-alpha-app",
    headers: `x-api-key=${process.env.NETRA_API_KEY}`,
    traceContent: true
  });

  // Your Aleph Alpha code will be automatically traced
  ```
</CodeGroup>

## Working with Aleph Alpha Completions

Once initialized, all Aleph Alpha API calls are automatically traced with detailed telemetry including prompts, completions, token usage, and timing information.

<CodeGroup>
  ```python Python theme={null}
  from netra import Netra
  from aleph_alpha_client import Client, CompletionRequest, Prompt
  import os

  # Initialize Netra
  Netra.init(
      app_name="my-aleph-alpha-app",
      headers=f"x-api-key={os.environ['NETRA_API_KEY']}",
      trace_content=True
  )

  # Use Aleph Alpha normally - automatically traced
  client = Client(token=os.environ["ALEPH_ALPHA_API_KEY"])

  request = CompletionRequest(
      prompt=Prompt.from_text("What is AI?"),
      maximum_tokens=100
  )

  response = client.complete(request, model="luminous-base")
  print(response.completions[0].completion)
  ```

  ```typescript TypeScript theme={null}
  import { Netra } from "netra-sdk";
  import { AlephAlphaClient } from "aleph-alpha-client";

  // Initialize Netra
  await Netra.init({
    headers: `x-api-key=${process.env.NETRA_API_KEY}`,
    traceContent: true
  });

  // Use Aleph Alpha normally - automatically traced
  const client = new AlephAlphaClient({
    apiKey: process.env.ALEPH_ALPHA_API_KEY
  });

  const response = await client.complete({
    model: "luminous-base",
    prompt: "Explain quantum computing in simple terms.",
    maximum_tokens: 100
  });

  console.log(response.completions[0].completion);
  ```
</CodeGroup>

## Using Decorators for Custom Workflows

Enhance tracing with Netra decorators to track custom workflows, agents, and tasks alongside Aleph Alpha calls.

<CodeGroup>
  ```python Python theme={null}
  from netra.decorators import workflow, task
  from netra import Netra
  from aleph_alpha_client import Client, CompletionRequest, Prompt

  Netra.init(
      headers=f"x-api-key={os.environ['NETRA_API_KEY']}"
  )

  client = Client(token=os.environ["ALEPH_ALPHA_API_KEY"])

  @workflow()
  def process_document(text: str):
      summary = summarize_text(text)
      keywords = extract_keywords(summary)
      return {"summary": summary, "keywords": keywords}

  @task()
  def summarize_text(text: str):
      request = CompletionRequest(
          prompt=Prompt.from_text(f"Summarize: {text}"),
          maximum_tokens=150
      )
      response = client.complete(request, model="luminous-extended")
      return response.completions[0].completion

  @task()
  def extract_keywords(text: str):
      request = CompletionRequest(
          prompt=Prompt.from_text(f"Extract keywords: {text}"),
          maximum_tokens=50
      )
      response = client.complete(request, model="luminous-base")
      return response.completions[0].completion
  ```

  ```typescript TypeScript theme={null}
  import { Netra, workflow, task } from "netra-sdk";
  import { AlephAlphaClient } from "aleph-alpha-client";

  await Netra.init({
    headers: `x-api-key=${process.env.NETRA_API_KEY}`
  });

  const client = new AlephAlphaClient({
    apiKey: process.env.ALEPH_ALPHA_API_KEY
  });

  @workflow()
  async function processDocument(text: string) {
    const summary = await summarizeText(text);
    const keywords = await extractKeywords(summary);
    return { summary, keywords };
  }

  @task()
  async function summarizeText(text: string) {
    const response = await client.complete({
      model: "luminous-extended",
      prompt: `Summarize the following text:\n\n${text}`,
      maximum_tokens: 150
    });
    return response.completions[0].completion;
  }

  @task()
  async function extractKeywords(text: string) {
    const response = await client.complete({
      model: "luminous-base",
      prompt: `Extract key topics from:\n\n${text}`,
      maximum_tokens: 50
    });
    return response.completions[0].completion;
  }
  ```
</CodeGroup>

## Session Tracking

Track user sessions and conversations when using Aleph Alpha for conversational applications.

<CodeGroup>
  ```python Python theme={null}
  from netra import Netra, ConversationType

  # Start a user session
  Netra.start_session(
      session_id="user-session-123",
      user_id="user-456",
      metadata={"app": "chatbot"}
  )

  # Start a conversation
  Netra.start_conversation(
      conversation_type=ConversationType.CHAT,
      metadata={"topic": "AI"}
  )

  # Add messages to the conversation
  Netra.add_message(role="user", content="Tell me about Aleph Alpha")

  # Your Aleph Alpha call here...

  # End conversation when done
  Netra.end_conversation()
  ```

  ```typescript TypeScript theme={null}
  import { Netra, ConversationType } from "netra-sdk";

  // Start a user session
  Netra.startSession({
    sessionId: "user-session-123",
    userId: "user-456",
    metadata: { channel: "web" }
  });

  // Start a conversation
  Netra.startConversation({
    conversationId: "conv-789",
    sessionId: "user-session-123",
    conversationType: ConversationType.CHAT
  });

  // Add messages to the conversation
  Netra.addMessageToConversation({
    conversationId: "conv-789",
    role: "user",
    content: "What is Aleph Alpha?"
  });

  // Your Aleph Alpha call here...

  Netra.addMessageToConversation({
    conversationId: "conv-789",
    role: "assistant",
    content: "Aleph Alpha is a European AI company..."
  });

  // End conversation when done
  Netra.endConversation("conv-789");
  Netra.endSession("user-session-123");
  ```
</CodeGroup>

# Next Steps

Explore additional Netra SDK capabilities to enhance your Aleph Alpha integration:

* [Quick Start Guide](https://docs.getnetra.ai/quick-start/python) - Get started with Netra SDK
* [Decorators](https://docs.getnetra.ai/tracing/decorators) - Learn about workflow, agent, and task decorators
* [Session Tracking](https://docs.getnetra.ai/tracing/session) - Comprehensive session and conversation management
* [Advanced Configuration](https://docs.getnetra.ai/tracing/advanced-config/programatic-config) - Configure Netra SDK programmatically
* [Aleph Alpha Learning Center](https://learning.aleph-alpha.com/learn) - Official Aleph Alpha documentation
