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

# Connect to the AI gateway

> Create a project key, discover an available model, and connect a coding client or application SDK.

Connect a coding tool or server-side application to a Veryfront project. The project's AI policy, key limits, and credits apply to requests made with its key.

## 1. Create or open a project

At [Projects](https://veryfront.com/projects), open the project you want to use. To create one, select **New project**, then **Start from scratch**, enter a name, and select **Create Project**. Studio opens the project workspace.

## 2. Create and save a project key

1. In the workspace's panel picker, open **API Keys**.
2. Select **Create API key** and give the key a name identifying its client or owner.
3. Keep **Read** enabled for model discovery and enable **Write** for inference. The form defaults to Read only. Leave **Delete** off unless the client needs it.
4. Select **Create API Key**. Copy the secret from **API key created** and save it. The secret is shown once.
5. Select **Connect to the AI gateway** to open this guide in a new tab, then select **Done** in the key dialog.

Store the key in a secret manager or a local environment file excluded from source control. Use a separate key for each developer or application so it can be revoked independently. Keep keys out of browser bundles and published configuration.

The examples use placeholders. In your local terminal, export the saved key:

```bash title="Terminal" theme={null}
export VERYFRONT_API_KEY='<your-project-key>'
```

Project keys identify their project automatically. These examples require no project-selector header. An account-level key follows the separate [authentication guide](/docs/cloud/authentication).

## 3. Discover a model

List the models your project key can access:

```bash title="list-models.sh" theme={null}
curl --fail-with-body 'https://api.veryfront.com/ai/v1/models' \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" > models.json
jq -r '.data[].id' models.json
```

Use a returned ID rather than guessing a model name. Choose a model supporting the client's request format. For the examples below, replace `<openai-model-id>` with a Responses-capable OpenAI model and `<claude-model-id>` with an available Claude model. Clients using Chat Completions need a model supporting that format. A model listed for a project is not a guarantee that every client protocol or hosted tool works with it.

An empty list means no suitable model is available under the current project policy and key limits. Resolve that before configuring the client.

## 4. Configure your client

Use the tab for your installed client. Replace the model placeholders with the IDs selected above and the key placeholder with your saved project key.

<Tabs>
  <Tab title="Claude Code">
    Run these variables in the terminal that starts Claude Code. The `/model` picker uses gateway discovery. Claude Code uses Claude models through the Anthropic Messages format. Its base URL is `/ai` because the client appends `/v1/messages`.

    ```bash title="Terminal" theme={null}
    export ANTHROPIC_BASE_URL='https://api.veryfront.com/ai'
    export ANTHROPIC_AUTH_TOKEN='<your-project-key>'
    export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
    claude --model '<claude-model-id>'
    ```
  </Tab>

  <Tab title="Codex CLI">
    Add the TOML to `~/.codex/config.toml`, then start Codex from the terminal containing your key. This configuration uses the Responses API. Hosted web search is disabled in this example; enable hosted tools only when the model and project policy support them.

    ```toml title="~/.codex/config.toml" theme={null}
    model = "<openai-model-id>"
    model_provider = "veryfront"
    web_search = "disabled"

    [model_providers.veryfront]
    name = "Veryfront"
    base_url = "https://api.veryfront.com/ai/v1"
    env_key = "VERYFRONT_API_KEY"
    wire_api = "responses"
    ```

    ```bash title="Terminal" theme={null}
    export VERYFRONT_API_KEY='<your-project-key>'
    codex
    ```
  </Tab>

  <Tab title="Cursor">
    In **Cursor Settings > Models**, paste each value into its field and enable **Override OpenAI Base URL**. Add the returned model name. This applies to chat and agent; Tab completion uses Cursor's own models. Cursor relays requests through its servers before Veryfront, so the residency guarantee does not cover that hop.

    ```text title="OpenAI API Key" theme={null}
    <your-project-key>
    ```

    ```text title="Override OpenAI Base URL" theme={null}
    https://api.veryfront.com/ai/v1
    ```

    ```text title="Model name" theme={null}
    <openai-model-id>
    ```
  </Tab>

  <Tab title="OpenCode">
    Save `~/.config/opencode/opencode.json`, then export the key and start OpenCode. The OpenAI adapter uses Responses. The Anthropic adapter appends `/messages` to `/ai/v1`. Keep only providers for which your project has a suitable model.

    ```json title="~/.config/opencode/opencode.json" theme={null}
    {
      "$schema": "https://opencode.ai/config.json",
      "model": "veryfront-anthropic/<claude-model-id>",
      "provider": {
        "veryfront": {
          "npm": "@ai-sdk/openai",
          "name": "Veryfront",
          "options": {
            "baseURL": "https://api.veryfront.com/ai/v1",
            "apiKey": "{env:VERYFRONT_API_KEY}"
          },
          "models": {
            "<openai-model-id>": {}
          }
        },
        "veryfront-anthropic": {
          "npm": "@ai-sdk/anthropic",
          "name": "Veryfront (Claude)",
          "options": {
            "baseURL": "https://api.veryfront.com/ai/v1",
            "apiKey": "{env:VERYFRONT_API_KEY}"
          },
          "models": {
            "<claude-model-id>": {}
          }
        }
      }
    }
    ```

    ```bash title="Terminal" theme={null}
    export VERYFRONT_API_KEY='<your-project-key>'
    opencode
    ```
  </Tab>

  <Tab title="Pi">
    Save `~/.pi/agent/models.json`, then export the key and start Pi. Keep only providers with an available model. The Anthropic adapter uses `/ai`; the OpenAI-compatible Chat Completions adapter uses `/ai/v1`.

    ```json title="~/.pi/agent/models.json" theme={null}
    {
      "providers": {
        "veryfront": {
          "baseUrl": "https://api.veryfront.com/ai/v1",
          "api": "openai-completions",
          "apiKey": "$VERYFRONT_API_KEY",
          "models": [
            {
              "id": "<openai-model-id>"
            }
          ]
        },
        "veryfront-anthropic": {
          "baseUrl": "https://api.veryfront.com/ai",
          "api": "anthropic-messages",
          "apiKey": "$VERYFRONT_API_KEY",
          "models": [
            {
              "id": "<claude-model-id>"
            }
          ]
        }
      }
    }
    ```

    ```bash title="Terminal" theme={null}
    export VERYFRONT_API_KEY='<your-project-key>'
    pi --provider veryfront-anthropic --model '<claude-model-id>'
    ```
  </Tab>

  <Tab title="OpenClaw">
    Save both files, then run `openclaw gateway restart`. OpenClaw runs as a service, so its key belongs in `~/.openclaw/.env`, not only in your terminal environment. Keep only providers with an available model.

    ```bash title="~/.openclaw/.env" theme={null}
    VERYFRONT_API_KEY='<your-project-key>'
    ```

    ```json title="~/.openclaw/openclaw.json" theme={null}
    {
      "agents": {
        "defaults": {
          "model": {
            "primary": "veryfront-anthropic/<claude-model-id>"
          }
        }
      },
      "models": {
        "mode": "merge",
        "providers": {
          "veryfront": {
            "baseUrl": "https://api.veryfront.com/ai/v1",
            "api": "openai-completions",
            "apiKey": "${VERYFRONT_API_KEY}",
            "models": [
              {
                "id": "<openai-model-id>",
                "name": "<openai-model-id>"
              }
            ]
          },
          "veryfront-anthropic": {
            "baseUrl": "https://api.veryfront.com/ai",
            "api": "anthropic-messages",
            "apiKey": "${VERYFRONT_API_KEY}",
            "models": [
              {
                "id": "<claude-model-id>",
                "name": "<claude-model-id>"
              }
            ]
          }
        }
      }
    }
    ```
  </Tab>

  <Tab title="Any client">
    Use `/ai/v1` as the OpenAI-compatible base URL and `/ai` as the base for the official Anthropic SDK. Send the project key as a Bearer token or the supported API-key header. List models with the command below before choosing a request format.

    ```bash title="List the models this key can use" theme={null}
    curl 'https://api.veryfront.com/ai/v1/models' \
      -H 'Authorization: Bearer <your-project-key>'
    ```
  </Tab>
</Tabs>

### Application SDKs

For server-side application code, use the same project key and returned model ID. Install the SDK shown in the selected tab, save its `.mts` TypeScript example, and run it with `npx tsx <filename>`. The `.mts` extension supports top-level `await` in existing CommonJS projects as well as ESM projects.

The endpoint prefix depends on the SDK: OpenAI clients use `/ai/v1`, the official Anthropic SDK uses `/ai`, and the Vercel Anthropic provider uses `/ai/v1`. Native Google clients use `/ai` with API version `v1beta`, which produces requests under `/ai/v1beta`. Do not substitute one prefix for every SDK.

```bash title="Terminal" theme={null}
export OPENAI_MODEL_ID='<openai-model-id>'
export ANTHROPIC_MODEL_ID='<claude-model-id>'
```

<Tabs>
  <Tab title="OpenAI SDK">
    ```bash title="Terminal" theme={null}
    npm install openai
    ```

    ```ts title="openai-gateway.mts" theme={null}
    import OpenAI from 'openai';

    const apiKey = process.env.VERYFRONT_API_KEY;
    const model = process.env.OPENAI_MODEL_ID;
    if (!apiKey || !model) throw new Error('Set VERYFRONT_API_KEY and OPENAI_MODEL_ID');

    const client = new OpenAI({ apiKey, baseURL: 'https://api.veryfront.com/ai/v1' });
    const response = await client.responses.create({
      model,
      input: 'Reply with gateway connected.',
    });
    console.log(response.output_text);
    ```

    See the [official OpenAI SDK documentation](https://developers.openai.com/api/docs/libraries) for SDK installation and response handling. The credential and endpoint here belong to Veryfront.
  </Tab>

  <Tab title="Vercel AI SDK">
    ```bash title="Terminal" theme={null}
    npm install ai @ai-sdk/openai
    ```

    ```ts title="ai-sdk-gateway.mts" theme={null}
    import { createOpenAI } from '@ai-sdk/openai';
    import { generateText } from 'ai';

    const apiKey = process.env.VERYFRONT_API_KEY;
    const modelId = process.env.OPENAI_MODEL_ID;
    if (!apiKey || !modelId) throw new Error('Set VERYFRONT_API_KEY and OPENAI_MODEL_ID');

    const gateway = createOpenAI({ apiKey, baseURL: 'https://api.veryfront.com/ai/v1' });
    const result = await generateText({
      model: gateway.responses(modelId),
      prompt: 'Reply with gateway connected.',
    });
    console.log(result.text);
    ```

    For Claude models, use [`createAnthropic`](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic) from `@ai-sdk/anthropic` with `baseURL: 'https://api.veryfront.com/ai/v1'` and the Veryfront key. That adapter appends `/messages`, so `/ai` is not its complete prefix. Consult the [OpenAI provider reference](https://ai-sdk.dev/providers/ai-sdk-providers/openai) when choosing Responses or Chat Completions.
  </Tab>

  <Tab title="LangChain">
    ```bash title="Terminal" theme={null}
    npm install @langchain/openai @langchain/core
    ```

    ```ts title="langchain-gateway.mts" theme={null}
    import { ChatOpenAI } from '@langchain/openai';

    const apiKey = process.env.VERYFRONT_API_KEY;
    const model = process.env.OPENAI_MODEL_ID;
    if (!apiKey || !model) throw new Error('Set VERYFRONT_API_KEY and OPENAI_MODEL_ID');

    const client = new ChatOpenAI({
      apiKey,
      model,
      useResponsesApi: true,
      configuration: { baseURL: 'https://api.veryfront.com/ai/v1' },
    });
    const response = await client.invoke('Reply with gateway connected.');
    console.log(response.content);
    ```

    This example selects Responses explicitly. See [ChatOpenAI](https://docs.langchain.com/oss/javascript/integrations/chat/openai) for custom endpoints and request-format options.
  </Tab>

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

    ```ts title="anthropic-gateway.mts" theme={null}
    import Anthropic from '@anthropic-ai/sdk';

    const apiKey = process.env.VERYFRONT_API_KEY;
    const model = process.env.ANTHROPIC_MODEL_ID;
    if (!apiKey || !model) throw new Error('Set VERYFRONT_API_KEY and ANTHROPIC_MODEL_ID');

    const client = new Anthropic({ apiKey, baseURL: 'https://api.veryfront.com/ai' });
    const response = await client.messages.create({
      model,
      max_tokens: 128,
      messages: [{ role: 'user', content: 'Reply with gateway connected.' }],
    });
    console.log(response.content);
    ```

    The official SDK appends `/v1/messages`. It therefore takes `/ai` as its base, unlike Vercel's Anthropic adapter. See the [Anthropic SDK](https://github.com/anthropics/anthropic-sdk-typescript).
  </Tab>

  <Tab title="Google Gemini">
    For a native Google client, configure the gateway's Google-provider route. Use a native Google model name for an allowed Google deployment; an OpenAI or Claude model ID is not a Google model name.

    ```bash title="Terminal" theme={null}
    npm install @google/genai
    export GOOGLE_MODEL_ID='<native-google-model-name>'
    ```

    ```ts title="gemini-gateway.mts" theme={null}
    import { GoogleGenAI } from '@google/genai';

    const apiKey = process.env.VERYFRONT_API_KEY;
    const model = process.env.GOOGLE_MODEL_ID;
    if (!apiKey || !model) throw new Error('Set VERYFRONT_API_KEY and GOOGLE_MODEL_ID');

    const client = new GoogleGenAI({
      apiKey,
      httpOptions: { baseUrl: 'https://api.veryfront.com/ai', apiVersion: 'v1beta' },
    });
    const response = await client.models.generateContent({
      model,
      contents: 'Reply with gateway connected.',
    });
    console.log(response.text);
    ```

    The SDK sends the Veryfront credential in `x-goog-api-key`; the gateway authenticates it before routing upstream. See [GoogleGenAI](https://googleapis.github.io/js-genai/release_docs/classes/client.GoogleGenAI.html) and [HTTP options](https://googleapis.github.io/js-genai/release_docs/interfaces/types.HttpOptions.html). Availability and project policy still apply; this guide does not claim every native Google model is admitted.
  </Tab>
</Tabs>

### Veryfront Code applications

For a Veryfront Code application, follow [Code getting started](/docs/code/getting-started) and its model/provider configuration. The framework CLI's login and linked-project flow remain separate from the direct gateway-key configuration above. A project API key does not replace `veryfront login`.

## 5. Verify one request

In your configured client, send: `Reply with gateway connected.` Confirm that it returns an answer without an authentication, model, or policy error. The request consumes project credits.

For an HTTP-level check of a Responses-capable model, run:

```bash title="first-response.sh" theme={null}
export OPENAI_MODEL_ID='<openai-model-id>'
jq -n --arg model "$OPENAI_MODEL_ID" \
  '{model: $model, input: "Reply with gateway connected."}' | \
  curl --fail-with-body 'https://api.veryfront.com/ai/v1/responses' \
    -H "Authorization: Bearer $VERYFRONT_API_KEY" \
    -H 'Content-Type: application/json' \
    --data-binary @- > response.json
jq -r '.output[]? | select(.type == "message") | .content[]? | select(.type == "output_text") | .text' response.json
```

Expect an assistant answer. If the request fails, read its error body before retrying:

| Result | Check |
| - | - |
| `401` | The key is present, valid, and not expired or revoked. |
| `403` | Write permission, project policy, key model limits, and hosted-tool support. |
| Model or request-format error | The returned model ID supports the API used by this client. |
| `gateway_project_required` | Use a project key, or follow the account-key project selector in the authentication guide. |

A successful discovery request proves Read access, not inference access. Check the project key's usage after the inference test. A successful request is the completion check; saving a configuration alone does not prove it works.

## Next

* [API Keys in Studio](/docs/studio/panels/api-keys): Rotate or revoke the client key and inspect usage.
* [Create an API key](/docs/cloud/getting-started/create-api-key): Manage credentials for other API clients.

## Related

* [Authenticate API requests](/docs/cloud/authentication): Bearer credentials and resource access.
* [AI Gateway API](https://veryfront.com/docs/cloud/apis/ai-gateway): Request formats, model discovery, and project policy.
* [Codex configuration](https://learn.chatgpt.com/docs/config-file/config-basic): Local Codex settings, including hosted web search.


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