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

# Make your first request

> Point your existing OpenAI or Anthropic code at the gateway and send a request

This guide is for **developers** sending traffic. If you already call OpenAI or Anthropic, you keep
your code and change two things: the base URL and the API key.

> [!NOTE]
>
> You'll need the **gateway base URL** (such as
> `https://your-gateway.example.com/v1`) and an **API key** (it starts with
> `sk-olga-`). Your operator creates these in [Set up the
> gateway](https://docs.openlayer.com/gateway/set-up-the-gateway.md).

## Send a request

Point your client at the gateway and use your gateway key. Everything else about your code stays the
same.

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

client = OpenAI(
  base_url="https://your-gateway.example.com/v1", # the gateway
  api_key="sk-olga-...", # your gateway key
)

response = client.responses.create(model="gpt-4o-mini", input="Hello!")
print(response.output_text)

```

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

client = OpenAI(
  base_url="https://your-gateway.example.com/v1", # the gateway
  api_key="sk-olga-...", # your gateway key
)

response = client.embeddings.create(
  model="text-embedding-3-small",
  input=["First document", "Second document"],
)
print(len(response.data))
```

```python Python (Anthropic) theme={null}
from anthropic import Anthropic

client = Anthropic(
  base_url="https://your-gateway.example.com",  # the gateway
  api_key="sk-olga-...", # your gateway key
)

message = client.messages.create(
  model="claude-sonnet-4-7",
  max_tokens=1024,
  messages=[{"role": "user", "content": "Hello!"}],
)
print(message.content[0].text)
```

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

const client = new OpenAI({
  baseURL: "https://your-gateway.example.com/v1", // the gateway
  apiKey: "sk-olga-...", // your gateway key
});

const response = await client.responses.create({
  model: "gpt-4o-mini",
  input: "Hello!",
});
console.log(response.output_text);
```

```bash cURL theme={null}
curl https://your-gateway.example.com/v1/responses \
  -H "Authorization: Bearer sk-olga-..." \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-4o-mini", "input": "Hello!"}'
```

> [!NOTE]
>
> The gateway speaks the **OpenAI Responses API** at `/v1/responses` and the
> **OpenAI Embeddings API** at `/v1/embeddings`, plus the **Anthropic Messages
> API** at `/v1/messages`. Use whichever your SDK targets. Streaming on the
> text-generation endpoints behaves exactly as it does against the provider
> directly: set `stream=True` (or `stream: true`) and read the events as usual.

## What you just got

On its way to the provider and back, your request was also:

* **Checked against your usage limits**, and refused if it would exceed one.
* **Screened by guardrails** for PII and prompt injection, on supported content endpoints.
* **Traced** to your Openlayer project, with model, tokens, latency, and cost.

None of that needed a line of code in your app.

Embedding requests skip content guardrails so redaction can't change the vectors. Their traces show
an embedding step and its count and dimensions, without dumping the vector values.

![Every gateway request becomes a trace in Openlayer](https://mintcdn.com/openlayer-44/2eGfXTpwMAOWCnGg/images/gateway/gateway_trace.png?fit=max\&auto=format\&n=2eGfXTpwMAOWCnGg\&q=85\&s=9bdc0c30431f87899e5c79d81a7318df)

## If something goes wrong

The most common errors are below. [Errors](https://docs.openlayer.com/gateway/errors.md) covers every status code, the exact
messages, and which ones are worth retrying.

> [accordion] 401 Unauthorized
>
> The key is missing, mistyped, or has been disabled or deleted. Confirm you're sending the
> `sk-olga-` key your operator gave you, as `Authorization: Bearer <key>`.

> [accordion] 429 Too Many Requests
>
> A usage limit on your key or group has been reached. Ask your operator to review your
> [usage limits](https://docs.openlayer.com/gateway/budgets-and-limits.md).

> [accordion] 422 Unprocessable Entity
>
> A guardrail blocked the request or the response. The message is the guardrail's reason, such as
> "Detected high-risk PII entities: US\_SSN". See [Guardrails](https://docs.openlayer.com/gateway/guardrails.md).

> [accordion] 503 Service Unavailable
>
> The message tells you which of these causes you hit:
>
> * **A guardrail is still loading**, for example "The pii guardrail is still loading on this
>   replica". This is temporary and happens shortly after a guardrail is added or changed, or
>   after the gateway starts. The response carries a `Retry-After` header; retry after a few
>   seconds. Most SDKs' built-in retries handle this for you.
> * **The provider isn't connected**, or its API key isn't set on the gateway host. Retrying
>   won't help. Your operator can fix this in [Connect providers](https://docs.openlayer.com/gateway/connect-providers.md).
> * **The endpoint can't be routed** to the selected provider or rule. Embeddings and image
>   generation require an OpenAI-format provider, and embeddings can't use a model-based routing
>   rule. Your operator can fix this in [Route requests](https://docs.openlayer.com/gateway/route-requests.md).


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