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

# Anthropic SDK

> The Anthropic SDK provides an interface for interacting with Claude models from Python and JavaScript applications. Follow the directions below to route requests through the Connect AI LLM Gateway.

## Prerequisites

Before you can configure the Anthropic SDK to use the Connect AI LLM Gateway, you must register a provider, create a routing rule, create a project, and issue a virtual key. See [LLM Gateway](/en/LLM-Gateway/LLM-Gateway) for details.

<Note>A Connect AI Personal Access Token (PAT) is not accepted by the LLM Gateway. Only a virtual key authenticates requests.</Note>

## Install the SDK

<Tabs>
  <Tab title="Python">
    ```bash theme={null}
    pip install anthropic
    ```
  </Tab>

  <Tab title="JavaScript">
    ```bash theme={null}
    npm install @anthropic-ai/sdk
    ```
  </Tab>
</Tabs>

## Send a Request

Set `base_url` (Python) or `baseURL` (JavaScript) to the Connect AI LLM Gateway endpoint and pass your virtual key as `api_key` or `apiKey`. The gateway selects the provider and model based on your project's routing rule.

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    import anthropic

    client = anthropic.Anthropic(
        base_url="https://cloud.cdata.com/gateway/v1",
        api_key="<your-virtual-key>",
    )

    message = client.messages.create(
        max_tokens=1024,
        messages=[{"role": "user", "content": "Hello"}],
    )
    print(message.content)
    ```
  </Tab>

  <Tab title="JavaScript">
    ```typescript theme={null}
    import Anthropic from "@anthropic-ai/sdk";

    const client = new Anthropic({
      baseURL: "https://cloud.cdata.com/gateway/v1",
      apiKey: "<your-virtual-key>",
    });

    const message = await client.messages.create({
      max_tokens: 1024,
      messages: [{ role: "user", content: "Hello" }],
    });

    console.log(message.content);
    ```
  </Tab>
</Tabs>

## Configure with Environment Variables

As an alternative to passing connection details in code, you can set environment variables. The Anthropic SDK reads these automatically.

<Tabs>
  <Tab title="macOS / Linux">
    ```bash theme={null}
    export ANTHROPIC_BASE_URL="https://cloud.cdata.com/gateway/v1"
    export ANTHROPIC_API_KEY="<your-virtual-key>"
    ```
  </Tab>

  <Tab title="Windows (PowerShell)">
    ```powershell theme={null}
    $env:ANTHROPIC_BASE_URL = "https://cloud.cdata.com/gateway/v1"
    $env:ANTHROPIC_API_KEY = "<your-virtual-key>"
    ```
  </Tab>
</Tabs>

With environment variables set, you can instantiate the client without explicit arguments:

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    import anthropic

    client = anthropic.Anthropic()  # reads ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY from env

    message = client.messages.create(
        max_tokens=1024,
        messages=[{"role": "user", "content": "Hello"}],
    )
    print(message.content)
    ```
  </Tab>

  <Tab title="JavaScript">
    ```typescript theme={null}
    import Anthropic from "@anthropic-ai/sdk";

    const client = new Anthropic(); // reads ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY from env

    const message = await client.messages.create({
      max_tokens: 1024,
      messages: [{ role: "user", content: "Hello" }],
    });

    console.log(message.content);
    ```
  </Tab>
</Tabs>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.