---
title: Connecting clients to AI Runtime Control
summary: null
url: >-
  https://www.fastly.com/documentation/guides/platform/ai-runtime-control/connecting-clients-to-arc
---

This guide shows how to send requests through AI Runtime Control (ARC) from curl, the Anthropic SDK, the OpenAI SDK, and the Vercel AI SDK. In each case, the only changes from calling the provider directly are the base URL, which points at ARC, and the API key, which is an ARC virtual key.

## Before you begin

You'll need the following:

- The [superuser role](https://www.fastly.com/documentation/guides/organizations-and-accounts/account-members-and-permissions/about-user-roles-and-permissions/). Other account roles can't access ARC.
- A provider configured in ARC that serves the model you want to call. Refer to our documentation on [Managing providers](https://www.fastly.com/documentation/guides/platform/ai-runtime-control/managing-providers/).
- A [virtual key](https://www.fastly.com/documentation/guides/platform/ai-runtime-control/managing-virtual-keys/) that permits the model you want to call. Create one key for the Anthropic API shape and one for the OpenAI API shape if you plan to use both.
- [Node.js](https://nodejs.org/) 20 or later, if you want to run the SDK examples.

The examples use Claude Opus 5.5 (`claude-opus-5-5`) for the Anthropic API shape and GPT 5.6 Sol (`gpt-5.6-sol`) for the OpenAI API shape. Every request must include a `model`, so substitute a model that your virtual key permits if you've chosen different ones.

## How requests change when you use ARC

ARC accepts requests in the Anthropic and OpenAI API shapes. Whichever client you use, you make the same two changes:

- **Base URL:** use `https://arc.fastly.app` instead of the provider's URL.
- **API key:** use your ARC virtual key instead of a raw provider key.

Everything else about the request, including the body, stays the same. Some clients add `/v1` to the base URL themselves and some don't, so each example below shows the correct form for its client.

## Storing your endpoint and virtual key

The examples read your ARC endpoint and virtual keys from environment variables. This keeps them out of your source code.

```term copy nolinenums
export ARC_ENDPOINT="https://arc.fastly.app"
export ARC_CLAUDE_KEY="your-claude-virtual-key"
export ARC_GPT_KEY="your-gpt-virtual-key"
```

Replace the key placeholders with the virtual key values you copied when you created the keys. You only need the key for the API shape you plan to use: `ARC_CLAUDE_KEY` for the Anthropic API shape and `ARC_GPT_KEY` for the OpenAI API shape.

> **IMPORTANT:** Treat a virtual key like any other credential. Don't commit it to source control or log it. If a key may have been exposed, [refresh it](https://www.fastly.com/documentation/guides/platform/ai-runtime-control/managing-virtual-keys/#refreshing-a-virtual-key) to issue a new value.

## Sending a request in the Anthropic API shape

To send a request in the Anthropic API shape, follow the steps for the client you want to use.

### curl

When sending a request in curl, the virtual key goes in the `x-api-key` header in place of a raw Anthropic key.

```term copy nolinenums
curl "$ARC_ENDPOINT/v1/messages" \
  --header "x-api-key: $ARC_CLAUDE_KEY" \
  --header "anthropic-version: 2023-06-01" \
  --header "content-type: application/json" \
  --data '{
    "model": "claude-opus-5-5",
    "max_tokens": 1024,
    "messages": [
      { "role": "user", "content": "Say hello and tell me which model you are." }
    ]
  }'
```

### Anthropic SDK

Install the Anthropic SDK.

```term copy nolinenums
npm install @anthropic-ai/sdk
```

Create a client with ARC as its `baseURL` and your virtual key as its `apiKey`, then send a message. The Anthropic SDK adds `/v1` to the base URL itself, so don't include it.

```javascript copy

const client = new Anthropic({
  baseURL: process.env.ARC_ENDPOINT,
  apiKey: process.env.ARC_CLAUDE_KEY,
});

const message = await client.messages.create({
  model: "claude-opus-5-5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Say hello and tell me which model you are." }],
});

console.log(message.content);
```

Save the file as `anthropic.mjs` and run it with `node anthropic.mjs`.

### Vercel AI SDK

The Vercel AI SDK uses a separate provider package for each API shape. Install the AI SDK and the Anthropic provider package.

```term copy nolinenums
npm install ai @ai-sdk/anthropic
```

Create a provider with `createAnthropic`, using ARC as its `baseURL` and your virtual key as its `apiKey`. Unlike the Anthropic SDK, this provider expects the base URL to end in `/v1`.

```javascript copy

const anthropic = createAnthropic({
  baseURL: `${process.env.ARC_ENDPOINT}/v1`,
  apiKey: process.env.ARC_CLAUDE_KEY,
});

const { text } = await generateText({
  model: anthropic("claude-opus-5-5"),
  prompt: "Say hello and tell me which model you are.",
});

console.log(text);
```

Save the file as `vercel-anthropic.mjs` and run it with `node vercel-anthropic.mjs`.

## Sending a request in the OpenAI API shape

To send a request in the OpenAI API shape, follow the steps for the client you want to use. The OpenAI shape supports both the [Chat Completions](https://developers.openai.com/api/reference/chat-completions/overview) and [Responses](https://developers.openai.com/api/reference/responses/overview) APIs.

### curl

The virtual key goes in the `Authorization` header in place of a raw OpenAI key.

To use the Chat Completions API, send a request to `/v1/chat/completions`.

```term copy nolinenums
curl "$ARC_ENDPOINT/v1/chat/completions" \
  --header "Authorization: Bearer $ARC_GPT_KEY" \
  --header "content-type: application/json" \
  --data '{
    "model": "gpt-5.6-sol",
    "messages": [
      { "role": "user", "content": "Say hello and tell me which model you are." }
    ]
  }'
```

To use the Responses API, send a request to `/v1/responses`.

```term copy nolinenums
curl "$ARC_ENDPOINT/v1/responses" \
  --header "Authorization: Bearer $ARC_GPT_KEY" \
  --header "content-type: application/json" \
  --data '{
    "model": "gpt-5.6-sol",
    "input": "Say hello and tell me which model you are."
  }'
```

### OpenAI SDK

Install the OpenAI SDK.

```term copy nolinenums
npm install openai
```

Create a client with ARC as its `baseURL` and your virtual key as its `apiKey`. The OpenAI SDK expects the base URL to end in `/v1`. The same client supports both of OpenAI's text generation APIs.

```javascript copy

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

To use the Chat Completions API, call `chat.completions.create`.

```javascript copy
const completion = await client.chat.completions.create({
  model: "gpt-5.6-sol",
  messages: [{ role: "user", content: "Say hello and tell me which model you are." }],
});

console.log(completion.choices[0].message.content);
```

To use the Responses API, call `responses.create`.

```javascript copy
const response = await client.responses.create({
  model: "gpt-5.6-sol",
  input: "Say hello and tell me which model you are.",
});

console.log(response.output_text);
```

Save the file as `openai.mjs`, with both calls below the client setup, and run it with `node openai.mjs`.

### Vercel AI SDK

The Vercel AI SDK uses a separate provider package for each API shape. Install the AI SDK and the OpenAI provider package.

```term copy nolinenums
npm install ai @ai-sdk/openai
```

Create a provider with `createOpenAI`, using ARC as its `baseURL` and your virtual key as its `apiKey`. This provider expects the base URL to end in `/v1`.

```javascript copy

const openai = createOpenAI({
  baseURL: `${process.env.ARC_ENDPOINT}/v1`,
  apiKey: process.env.ARC_GPT_KEY,
});

const { text } = await generateText({
  model: openai("gpt-5.6-sol"),
  prompt: "Say hello and tell me which model you are.",
});

console.log(text);
```

By default, `openai(...)` uses the Responses API. To use Chat Completions instead, call `openai.chat("gpt-5.6-sol")`.

Save the file as `vercel-openai.mjs` and run it with `node vercel-openai.mjs`.

## Confirming ARC recorded your requests

Each request you send is recorded against the virtual key you used.

1.   Log in to the [Fastly control panel](https://manage.fastly.com).

2. Go to **Tools** > **AI Runtime Control**.
3. Click the **Logging** tab.
4. Search for your virtual key, or set the virtual key filter.
5. Review the requests recorded for that key, including the model, input and output token counts, and timestamp.

To see the request and token totals for the key, click the **Virtual keys** tab and then click the key's name. For more detail, check out [Monitoring AI usage with ARC](https://www.fastly.com/documentation/guides/platform/ai-runtime-control/monitoring-ai-usage-with-arc/).

## Next steps

- Issue a separate virtual key to each application so ARC attributes usage to each one.
- [Track per-engineer AI usage](https://www.fastly.com/documentation/solutions/tutorials/ai-runtime-control/track-per-engineer-ai-usage/) by issuing a virtual key per person.
