# Custom Agents

## Custom Agents

Custom agents are applications and workflows you build directly — using LLM APIs, agent frameworks (LangGraph, CrewAI, AWS Strands), or your own orchestration code. Highflame offers two integration patterns for these, which can be used independently or combined.

### SDK — Inline guardrails

Embed guardrails directly in your application code at the points where sensitive operations happen: before a prompt reaches a model, before a tool executes, before a response is returned. This gives you explicit, per-step control and works with any framework.

Choose this when you want to:

* Guard specific steps in an agent lifecycle rather than proxying all traffic
* Use typed SDK abstractions and decorator-style protection (`@shield.prompt`, `@shield.tool`)
* Integrate with LangGraph, CrewAI, AWS Strands, or a custom agent loop
* Keep enforcement decisions close to the code path where actions happen

```python
from highflame import Highflame, Shield, BlockedError

client = Highflame(api_key="hf_sk_...")
shield = Shield(client)

@shield.prompt(mode="enforce")
def chat(message: str) -> str:
    return openai.chat.completions.create(
        model="openai/gpt-4o-mini",
        messages=[{"role": "user", "content": message}],
    ).choices[0].message.content
```

See [Integration Examples](/getting-started/securing-agents/custom-agents/gateway-integration-examples.md#sdk-integration-direct-guardrails) for SDK patterns in Python and TypeScript, including tool call guards, response evaluation, and framework integrations.

***

### Agent Gateway — Centralized proxy

Route your LLM and MCP traffic through the Highflame Agent Gateway. Point your existing OpenAI-compatible client at Highflame instead of the upstream provider. Guardrails, observability, and governance apply automatically to every request — no changes to individual call sites required.

Choose this when you want to:

* Secure multiple agents or applications through a shared control point
* Apply consistent policy across teams and environments without rewriting clients
* Govern MCP tool and server access centrally
* Route traffic across multiple providers (`openai/gpt-4o`, `anthropic/claude-sonnet-4-6`, `azure/...`) through a single endpoint

```python
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["OPENAI_API_KEY"],
    base_url=f"{os.environ['HIGHFLAME_BASE_URL']}/v1",
    default_headers={"x-highflame-api-key": os.environ["HIGHFLAME_API_KEY"]},
)
```

See [Integration Examples](/getting-started/securing-agents/custom-agents/gateway-integration-examples.md#gateway-integration-centralized-protection) for Gateway examples across OpenAI, TypeScript, Azure, Bedrock, and the Responses API.

For full Gateway documentation: [Multi-Protocol Gateway](/agent-gateway/ai-gateway.md), [Securing Model Calls](/agent-gateway/securing-model-calls.md), [Securing MCPs](/agent-gateway/securing-mcps.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.highflame.ai/getting-started/securing-agents/custom-agents.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
