# Claude Code and Codex

Connect Claude Code and Codex CLI to the Gateway so the files the agent reads and the command output it sees are masked before they reach the model.

A coding agent sends the model more than what you type. The files it reads, the output of the commands it runs and every earlier turn go to the model on every request. When you connect the agent to the Gateway, all of it is masked before it is forwarded to the provider. The agent works as usual; what changes is the text the model sees.

You need two values:

- Gateway address: `https://gw-tr.gurubase.io`
- The API key you generate in the [panel](https://gateway-tr.gurubase.io)

Claude Code needs an Anthropic-compatible provider in your organization and Codex an OpenAI-compatible one, and the model you use must be enabled for your key. The organization admin manages providers and models in the panel ([Panel](/docs/en/panel/)).

Check in the **Maskeleme** column of the **API anahtarları** page that masking is on for the key you use. Requests sent with a key that has masking off reach the provider unmasked.

## Claude Code

Two environment variables are enough:

```bash
export ANTHROPIC_BASE_URL="https://gw-tr.gurubase.io/anthropic"
export ANTHROPIC_AUTH_TOKEN="API_KEY"
export ANTHROPIC_MODEL="MODEL_NAME"
claude
```

Replace `MODEL_NAME` with a Claude model enabled for your key. If Claude Code’s default model is not enabled for your key, the request is rejected.

To keep the setting, put the same values in the `env` section of the Claude Code settings file:

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://gw-tr.gurubase.io/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "API_KEY",
    "ANTHROPIC_MODEL": "MODEL_NAME"
  }
}
```

Thinking blocks and tool calls are carried across turns unchanged. Within a conversation a value gets the same placeholder on every turn, so the provider’s prompt cache keeps working for the whole conversation.

## Codex

Register the Gateway as a model provider for Codex:

```toml
model = "MODEL_NAME"
model_provider = "siper"

[model_providers.siper]
name = "Gurubase Siper Gateway"
base_url = "https://gw-tr.gurubase.io/v1"
wire_api = "responses"
env_key = "SIPER_GATEWAY_KEY"
```

Replace `MODEL_NAME` with a model enabled for your key. Pass the key through the environment:

```bash
export SIPER_GATEWAY_KEY="API_KEY"
codex
```

Codex’s encrypted reasoning content is never decrypted or modified; it goes back to the provider as it is.

## What the agent writes to files

By default the agent works with placeholders. When you say “write customer Ayşe Yılmaz’s record to `kayit.md`”, the file gets `<KİŞİ_1>`. A masked value reaches neither the model nor the files the agent writes. The placeholder format is described in [Concepts](/docs/en/concepts/).

This is the right behavior for most work: the agent builds the code, the structure and the logic, and the real data stays on your machine, in your files.

## Restoring real values

If the agent has to write files with real data, turn restore on for that API key. The model still sees only placeholders; on the way back to the client the Gateway replaces the placeholders in the model’s response with the original values.

The organization admin does this in the panel:

1. On the **API anahtarları** page, choose **Geri yükleme** from the key’s row menu.
2. Turn the **Geri yükleme** switch on.
3. Under **Gerçek veri alan araçlar**, tick your agent’s profile.
4. Tick the responsibility acknowledgement and save.

Ready-made profiles:

| Profile | Tools | What it opens |
| --- | --- | --- |
| Claude Code | `Write`, `Edit` | Writing and editing files |
| Codex | `exec` | Every local action of Codex: shell commands and file writes |

A tool that is not in the list gets masked values. With an empty list only the response text is restored. You can add another tool in **Diğer araçlar** by name (`Read`) or by a single parameter (`lookup.tckn`).

With `exec` on, every command Codex runs sees the real data. The panel warns about this separately.

On a key with restore on, the original data goes back to the client and your organization is responsible for that traffic under KVKK. The change is written to the audit log. Restore and response masking cannot both be on for the same key.

## Troubleshooting

**The agent cannot find a file.** If your working directory path contains your name (`/Users/ayse.yilmaz/project`), the path is masked as a person’s name in tool output. The model then tries to read the file with the placeholder path and the file is not found. Either open the project in a directory without your name, or add `Read` under **Diğer araçlar** on a key with restore on. The `Read` input goes to a file read on your own machine.

**The request returns 413.** A single piece of text is over 20,000 characters, usually a very large file the agent read. Limits are on the [Limits](/docs/en/limits/) page.

**The request returns 502.** When masking cannot be completed the request is not sent to the provider at all and 502 is returned. This is the safe default; retry after a short while, and if it persists, [contact us](https://siper.gurubase.ai/iletisim).

**The model refuses the same prompt every time.** Within a conversation the same text turns into the same masked text, so retrying gives the same result. Rephrase the prompt.
