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

# Use an SDK

> Connect common LLM SDKs to airmux with an inference key and gateway model ID.

Point an SDK at your `airmux` inference endpoint, use a workspace inference key, and choose a model ID from the gateway catalog. OpenAI-compatible SDKs use `/inf/v1`; the Anthropic SDK uses `/inf`. `airmux` routes each request to the selected provider.

Set these values for the examples:

```bash theme={null}
export AIRMUX_URL='http://localhost:8080'
export AIRMUX_INFERENCE_KEY='sk-inf-your-key'
export AIRMUX_MODEL='openai/gpt-4o-mini'
```

<Tabs>
  <Tab title="OpenAI Python">
    ```python theme={null}
    import os
    from openai import OpenAI

    client = OpenAI(
        base_url=f"{os.environ['AIRMUX_URL'].rstrip('/')}/inf/v1",
        api_key=os.environ['AIRMUX_INFERENCE_KEY'],
    )

    response = client.responses.create(
        model=os.environ['AIRMUX_MODEL'],
        input="Explain request routing in one sentence.",
    )
    print(response.output_text)
    ```
  </Tab>

  <Tab title="Anthropic Python">
    The Messages endpoint uses a base URL ending in `/inf`; the SDK appends `/v1/messages`.

    ```python theme={null}
    import os
    from anthropic import Anthropic

    client = Anthropic(
        base_url=f"{os.environ['AIRMUX_URL'].rstrip('/')}/inf",
        api_key=os.environ['AIRMUX_INFERENCE_KEY'],
    )

    message = client.messages.create(
        model="anthropic/claude-haiku-4-5-20251001",
        max_tokens=256,
        messages=[{"role": "user", "content": "Explain request routing in one sentence."}],
    )
    print(message.content[0].text)
    ```
  </Tab>

  <Tab title="OpenAI JavaScript">
    ```javascript theme={null}
    import OpenAI from "openai";

    const client = new OpenAI({
      baseURL: `${process.env.AIRMUX_URL}/inf/v1`,
      apiKey: process.env.AIRMUX_INFERENCE_KEY,
    });

    const response = await client.responses.create({
      model: process.env.AIRMUX_MODEL,
      input: "Explain request routing in one sentence.",
    });
    console.log(response.output_text);
    ```
  </Tab>

  <Tab title="OpenAI Go">
    ```go theme={null}
    package main

    import (
    	"context"
    	"fmt"
    	"os"

    	"github.com/openai/openai-go/v3"
    	"github.com/openai/openai-go/v3/option"
    	"github.com/openai/openai-go/v3/responses"
    )

    func main() {
    	client := openai.NewClient(
    		option.WithBaseURL(os.Getenv("AIRMUX_URL") + "/inf/v1"),
    		option.WithAPIKey(os.Getenv("AIRMUX_INFERENCE_KEY")),
    	)
    	response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
    		Model: openai.ChatModel(os.Getenv("AIRMUX_MODEL")),
    		Input: responses.ResponseNewParamsInputUnion{
    			OfString: openai.String("Explain request routing in one sentence."),
    		},
    	})
    	if err != nil {
    		panic(err)
    	}
    	fmt.Println(response.OutputText())
    }
    ```

    Add the SDK to your Go module with `go get github.com/openai/openai-go/v3`.
  </Tab>

  <Tab title="Vercel AI SDK">
    Install `ai` and `@ai-sdk/openai-compatible` in your Node project:

    ```bash theme={null}
    npm install ai @ai-sdk/openai-compatible
    ```

    ```typescript theme={null}
    import { generateText } from "ai";
    import { createOpenAICompatible } from "@ai-sdk/openai-compatible";

    const airmux = createOpenAICompatible({
      name: "airmux",
      baseURL: `${process.env.AIRMUX_URL}/inf/v1`,
      apiKey: process.env.AIRMUX_INFERENCE_KEY,
    });

    const { text } = await generateText({
      model: airmux(process.env.AIRMUX_MODEL!),
      prompt: "Explain request routing in one sentence.",
    });

    console.log(text);
    ```
  </Tab>

  <Tab title="LangChain Python">
    Install the OpenAI integration with `uv add langchain-openai`, then invoke it with the `airmux` endpoint:

    ```python theme={null}
    import os

    from langchain_openai import ChatOpenAI

    model = ChatOpenAI(
        model=os.environ["AIRMUX_MODEL"],
        base_url=f"{os.environ['AIRMUX_URL'].rstrip('/')}/inf/v1",
        api_key=os.environ["AIRMUX_INFERENCE_KEY"],
    )

    response = model.invoke("Explain request routing in one sentence.")
    print(response.content)
    ```
  </Tab>
</Tabs>

Vercel AI SDK uses its [OpenAI-compatible provider](https://ai-sdk.dev/providers/openai-compatible-providers). LangChain uses the [OpenAI integration](https://docs.langchain.com/oss/python/integrations/chat/openai) with `airmux`'s Chat Completions endpoint.

List models with the OpenAI SDK using `client.models.list()`. Results reflect the models visible to the key's workspace policies and configured credential scopes. See the [model discovery reference](/docs/reference/models-and-providers#inference-model-discovery).

Inference keys begin with `sk-inf-`. Management keys (`sk-cp-`) cannot be used for inference. The [Messages reference](/docs/reference/messages), [Chat Completions reference](/docs/reference/chat-completions), and [Responses reference](/docs/reference/responses) describe supported request fields.
