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

# Integrating with the Gateway

> Connect an application to Phaseo Gateway, choose an endpoint, and prepare the integration for production.

Use this how-to guide after the quickstart, when you are ready to put Phaseo behind a real application feature.

By the end, you should have:

* a safely stored API key
* a clear endpoint choice
* one working request in your app
* links to the right production guides for routing, SDKs, and operations

***

## Before you begin

Make sure you have the following in place:

* A Phaseo account with Gateway access.
* An API key from the [dashboard](https://phaseo.app/gateway/keys).
* An HTTP client, OpenAI-compatible SDK, or Phaseo SDK.
* A supported model ID, such as `google/gemma-3-27b:free` for a zero-credit start.

***

## 1. Store the API key

1. Open **Gateway -> API Keys** in the Phaseo dashboard.
2. Create a key with a name that identifies the app and environment.
3. Store the value in a secret manager or local environment file:

```bash theme={null}
# .env
PHASEO_API_KEY="phaseo_v1_sk_<kid>_<secret>"
```

<Tip>
  Use separate keys for local development, preview deployments, and production. It makes rotation and usage review much easier.
</Tip>

***

## 2. Choose the endpoint

Choose the endpoint that best matches the job you are doing:

| Endpoint                 | When to use it                                                 |
| ------------------------ | -------------------------------------------------------------- |
| `/v1/responses`          | New text builds, structured outputs, and multi-step workflows. |
| `/v1/chat/completions`   | Chat interfaces, assistants, and OpenAI-style integrations.    |
| `/v1/messages`           | Anthropic-compatible integrations.                             |
| `/v1/moderations`        | Safety and content policy checks.                              |
| `/v1/images/generations` | Image generation from text prompts.                            |

Refer to the [API Reference](../api-reference/introduction) for the complete list of supported parameters and responses.

<Note>
  Free-model IDs end with `:free` and can be called without depositing credits. Paid-model calls require available wallet balance.
</Note>

***

## 3. Send the app request

Start with the request shape your app is most likely to keep. This example uses Chat Completions because it works well for OpenAI-compatible clients.

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.phaseo.ai/v1/chat/completions \
    -H "Authorization: Bearer $PHASEO_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "google/gemma-3-27b:free",
      "messages": [
        { "role": "system", "content": "You are a helpful assistant." },
        { "role": "user", "content": "Explain the benefits of AI." }
      ]
    }'
  ```

  ```typescript TypeScript theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.PHASEO_API_KEY,
    baseURL: "https://api.phaseo.ai/v1",
  });

  const response = await client.chat.completions.create({
    model: "google/gemma-3-27b:free",
    messages: [
      { role: "system", content: "You are a helpful assistant." },
      { role: "user", content: "Explain the benefits of AI." },
    ],
  });

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

  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_API_KEY",
      base_url="https://api.phaseo.ai/v1",
  )

  response = client.chat.completions.create(
      model="google/gemma-3-27b:free",
      messages=[
          {"role": "system", "content": "You are a helpful assistant."},
          {"role": "user", "content": "Explain the benefits of AI."},
      ],
  )

  print(response.choices[0].message.content)
  ```

  ```go Go theme={null}
  package main

  import (
    "context"
    "fmt"

    phaseo "github.com/phaseoteam/Phaseo/packages/sdk/sdk-go"
  )

  func main() {
    client := phaseo.New("YOUR_API_KEY", "https://api.phaseo.ai/v1")

    response, err := client.ChatCompletions(context.Background(), map[string]interface{}{
      "model": "google/gemma-3-27b:free",
      "messages": []map[string]string{
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain the benefits of AI."},
      },
    })
    if err != nil {
      panic(err)
    }

    fmt.Println(response)
  }
  ```

  ```csharp C# theme={null}
  using PhaseoSdk;
  using System.Collections.Generic;

  var client = new Phaseo("YOUR_API_KEY");

  var response = await client.ChatCompletions(new Dictionary<string, object>
  {
      ["model"] = "google/gemma-3-27b:free",
      ["messages"] = new object[]
      {
          new Dictionary<string, object> { ["role"] = "system", ["content"] = "You are a helpful assistant." },
          new Dictionary<string, object> { ["role"] = "user", ["content"] = "Explain the benefits of AI." }
      }
  });

  Console.WriteLine(response);
  ```

  ```php PHP theme={null}
  <?php
  require 'vendor/autoload.php';

  use Phaseo\Sdk\Phaseo;

  $client = new Phaseo(getenv('PHASEO_API_KEY') ?: 'YOUR_API_KEY');

  $response = $client->chatCompletions([
      'model' => 'google/gemma-3-27b:free',
      'messages' => [
          ['role' => 'system', 'content' => 'You are a helpful assistant.'],
          ['role' => 'user', 'content' => 'Explain the benefits of AI.'],
      ],
  ]);

  print_r($response);
  ```

  ```ruby Ruby theme={null}
  require 'phaseo_sdk'

  client = PhaseoSdk::Phaseo.new(api_key: ENV.fetch('PHASEO_API_KEY', 'YOUR_API_KEY'))

  response = client.chat_completions(
    model: 'google/gemma-3-27b:free',
    messages: [
      { role: 'system', content: 'You are a helpful assistant.' },
      { role: 'user', content: 'Explain the benefits of AI.' }
    ]
  )

  puts response
  ```
</CodeGroup>

***

## 4. Configure environments

Store your API key in environment variables for different environments:

```bash theme={null}
# .env.local
PHASEO_API_KEY="phaseo_v1_sk_<kid>_<secret>"
PHASEO_BASE_URL="https://api.phaseo.ai/v1"
```

When making requests, send the key in the `Authorization` header:

```http theme={null}
Authorization: Bearer $PHASEO_API_KEY
```

***

## 5. Production next steps

* Review [Authentication](./authentication) for key handling and common auth failures.
* Learn [Routing and fallbacks](../guides/routing-and-fallbacks) before sending meaningful traffic.
* Browse [Examples](../guides/examples) for complete app and script patterns.
* Explore the [SDK Reference](../sdk-reference/typescript/overview) for language-specific clients.
