Integration Examples

This page shows common ways to integrate Highflame into your application: Gateway integration for centralized model traffic control, and SDK integration for direct, in-code guardrails. Choose the pattern that fits your architecture — or combine both.


SDK Integration — Direct Guardrails

Guard prompts, tool calls, and model responses directly from your application code. The SDK calls Shield's API and enforces Cedar policies inline.

Guard a Prompt (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="gpt-4o-mini",
        messages=[{"role": "user", "content": message}],
    ).choices[0].message.content

try:
    reply = chat("Summarize the quarterly report")
except BlockedError as e:
    print(f"Blocked: {e.response.policy_reason}")

Guard a Prompt (TypeScript)

Guard a Tool Call

Guard a Model Response (Hallucination Detection)

Framework Integrations (Python)

For full SDK documentation, see Python SDK and TypeScript SDK.


Gateway Integration — Centralized Protection

Route LLM traffic through the Highflame Agent Gateway to apply guardrails, observability, and governance without changing application code.

You will need:

  • a Highflame API key

  • a route or gateway configuration in Highflame

  • the upstream provider credential your application already uses

Example 1: Keep Your OpenAI-Compatible Client

This is the fastest path when your application already speaks the OpenAI Chat Completions API. Point your client at Highflame and add the x-highflame-api-key header.

What changes:

  • base_url points to Highflame instead of the upstream provider

  • model uses the provider/model format

  • x-highflame-api-key identifies your Highflame project and policies

Example 2: Use TypeScript With the OpenAI SDK

Example 3: Route Different Providers Through One API

Highflame accepts OpenAI-style requests and uses the provider/model value to route traffic to the correct upstream provider.

Examples: openai/gpt-4o, anthropic/claude-sonnet-4-20250514, azure/my-gpt-4o-deployment, gemini/gemini-2.0-flash, groq/llama-3.3-70b-versatile

Example 4: Responses API Through Highflame

Example 5: Azure OpenAI

Example 6: AWS Bedrock

Endpoint
Method
Description

/model/{model-id}/{apivariation}

POST

Route requests to a specific AWS Bedrock model and API variation

Path Parameters:

  • model-id: The Bedrock model identifier

  • apivariation: invoke, invoke-stream, converse, converse-stream


Combining Both Patterns

Use Gateway integration for centralized model traffic protection and SDK integration for guarding tool calls and agentic workflows:

How To Choose

Use the gateway examples on this page when you want the least disruptive integration path with centralized routing, observability, and governance.

Use the Shield SDK when you want per-step enforcement inside agent workflows — guarding prompts, tool calls, model responses, or file operations directly in code.

Next Steps

Last updated