# API keys and secrets in AI prompts — a Grodmir guide

> API keys, tokens and passwords reach AI models when developers paste logs or configuration, or when coding assistants read files that contain them. A gateway can remove detected secrets before forwarding.

Grodmir is an AI gateway for data protection and AI usage governance in organisations.

## How do secrets end up in AI prompts?

Developers paste stack traces, configuration files or environment output into a chat. Coding assistants such as Claude Code, Codex or Cursor read repository files and command output as context, including files with credentials.

[Answer source](https://grodmir.com/en/secrets-in-ai-prompts#how-secrets-leak)

## Why is a secret in a prompt a problem?

A credential sent to an external provider has left your control: it may be retained, logged or shown back in later output. The safe response is to rotate it, which costs time and may affect production systems.

[Answer source](https://grodmir.com/en/secrets-in-ai-prompts#why-it-matters)

## What does Grodmir do with secrets?

Grodmir detects secrets with rules and removes them irreversibly before forwarding. Secrets never enter the pseudonym map and are never restored in responses, and policy exceptions never cover secrets.

[Answer source](https://grodmir.com/en/secrets-in-ai-prompts#what-grodmir-does)

## How does it work with coding assistants?

Point the assistant's base URL and key at the Grodmir gateway. Requests, including file content the tool sends as context, are inspected locally. Repository rules in an .aiguard.yaml file can add project-specific settings.

[Answer source](https://grodmir.com/en/secrets-in-ai-prompts#coding-assistants)

## What are the limits?

Only routed traffic is inspected; a personal key used directly bypasses the gateway. Deliberately obfuscated values, such as base64 or a key split over several fields, are not reliably caught. Detection reduces accidental leaks, not deliberate exfiltration.

[Answer source](https://grodmir.com/en/secrets-in-ai-prompts#limits)

- [Grodmir — Prompt DLP for sensitive AI data](https://grodmir.com/en/prompt-dlp)
- [Grodmir — Claude Code gateway and prompt data protection](https://grodmir.com/en/integrations/claude-code)
- [Grodmir — Codex CLI gateway for the Responses API](https://grodmir.com/en/integrations/codex)
- [Grodmir — Cursor AI gateway setup and coverage limits](https://grodmir.com/en/integrations/cursor)
- [What do the Grodmir categories mean?](https://grodmir.com/en/glossary)
- [Grodmir — AI gateway selection criteria](https://grodmir.com/en/how-to-choose-an-ai-gateway)

## How can you verify this behaviour?

- [claude-code (EN)](https://grodmir.com/dokumentacja/zrodla/claude-code.md)
- [codex (EN)](https://grodmir.com/dokumentacja/zrodla/codex.md)
- [repo-rules (EN)](https://grodmir.com/dokumentacja/zrodla/repo-rules.md)

Content updated: 2026-11-29

Protection covers connected-channel traffic only; detection can miss data and raise false alarms. [Grodmir — AI gateway protection limits](https://grodmir.com/en/limitations)

Source: https://grodmir.com/en/secrets-in-ai-prompts
