Skip to main content

Connect an agent to the gateway

An agent built on another platform is observed when MeetLoyd finds it: it is in your register, but nothing it does passes through MeetLoyd. It becomes gatewayed when it sends its model calls to the MeetLoyd gateway instead of its model provider. From then on, every call it makes is identified, checked and recorded — and refused when you halt it.

This page explains what the gateway key is, where it goes, and which agents can use it.

What you need​

Base URLhttps://api.meetloyd.com/api/v1/gateway/v1
KeyThe agent's gateway key (mlg_…), minted on the agent's page: Agents → the agent → Gateway credentials → Mint. It is shown once; store it in the platform's secret store, never in code.
AuthenticationAuthorization: Bearer mlg_… on every request.
ProtocolOpenAI-compatible Chat Completions, including streaming and function calling.
A model keyCalls run on your organisation's own key for the model's vendor (Models → Providers & keys). Without one, the call is refused (byok_required).

The key is the agent: whoever holds it acts as that agent. Two settings bound it, both on the same panel:

  • Expiry, chosen when you mint.
  • Allowed source addresses: the addresses or ranges the agent calls from. Calls from anywhere else are refused and recorded. With no list, a leaked key works from anywhere until you revoke it.

Revoking a key takes effect on the next call.

The change in the agent​

For an agent whose code you control, two values change: the base URL and the API key. Nothing else — prompts, framework and memory stay where they are.

Python (OpenAI SDK):

import os
from openai import OpenAI

client = OpenAI(
base_url="https://api.meetloyd.com/api/v1/gateway/v1",
api_key=os.environ["MEETLOYD_GATEWAY_KEY"],
)

reply = client.chat.completions.create(
model="claude-sonnet-4-6", # any model your organisation approves
messages=[{"role": "user", "content": "Summarise invoice INV-1042"}],
)

JavaScript / TypeScript (OpenAI SDK):

import OpenAI from 'openai'

const client = new OpenAI({
baseURL: 'https://api.meetloyd.com/api/v1/gateway/v1',
apiKey: process.env.MEETLOYD_GATEWAY_KEY,
})

const reply = await client.chat.completions.create({
model: 'claude-sonnet-4-6', // any model your organisation approves
messages: [{ role: 'user', content: 'Summarise invoice INV-1042' }],
})

The agent names the model it wants; your model policy approves or refuses it. No model is deployed on MeetLoyd for the agent.

Which agents can be connected​

AgentCan it be connected?How
Your own code (LangGraph, CrewAI, AutoGen, a custom service)YesSet the base URL and key in the code, as above.
AWS Bedrock AgentCore runtimeYesThe runtime runs your container or code package: set the base URL in that code, and pass the key from your secret store.
AWS Bedrock AgentCore harnessYesConfigure the harness model with an OpenAI-compatible endpoint: openAiModelConfig with apiBase set to the base URL above and apiFormat set to chat_completions (or liteLlmModelConfig with apiBase). Store the gateway key in AgentCore Identity as an API-key credential provider and reference it with apiKeyArn; the harness sends it with each call. See AWS's harness model documentation.
Microsoft Copilot StudioNoThe model runs inside Copilot Studio; its calls never leave Microsoft. The agent stays observed.
Microsoft Foundry agentsNoThe model is a deployment inside your Foundry project; its calls never leave Microsoft. The agent stays observed.
Classic Bedrock Agents, Salesforce Agentforce, Vertex AI agents, Prisme.aiOnly if the platform lets you set the model endpointWhere it does not, the agent stays observed.

A key minted for an agent that cannot send us its calls is never used, and governs nothing. The agent's page says so: an agent counts as gatewayed only once its calls actually reach the gateway.

What happens on each call​

In this order, before the model is called:

  1. Key — unknown, revoked or expired: refused.
  2. Source address — outside the allowed list: refused and recorded.
  3. Halt — the agent is paused or its team stopped: refused. This is your kill switch for an agent built elsewhere.
  4. Budget — over its limit: refused or throttled, as your budget rule says.
  5. Content checks — prompt injection, guardrails, moderation, personal data.
  6. Model — your model policy, then the call on your own key.

Then the call is metered against the agent's budget and written to the audit trail.

Tools​

Tool access is deny by default: an agent with no tool grants is offered no tools.

  • Function calling: tools the agent declares in its request reach the model only if granted. Each tool call the model returns is checked against the grants before it reaches the agent; a refused call is withheld.
  • Tools run by MeetLoyd: GET /tools lists the tools the agent is granted; POST /tools/call with {"name": "...", "arguments": {...}} runs one, through the same checks.

Grants are set per agent with PUT /api/v1/governed-agents/{agentId}/tools and the body {"grants": ["tool_name", ...]}. An empty list removes all tool access.

Refusals​

Refusals use the OpenAI error format (error.message, error.type, error.code), so the agent's SDK raises them like any provider error.

StatuscodeMeaning
401not_found, revoked, expired, malformedThe key is not valid.
402budget_blockedThe agent's budget is spent.
402byok_requiredYour organisation has no key for this model's vendor.
403agent_haltedThe agent or its team has been stopped.
403source_not_allowed, source_unknownThe call came from an address outside the allowed list, or its address could not be determined.
403prompt_injection_detected, outside_agent_purpose, policy codesA governance check refused the content.
429budget_throttledThrottled by a budget rule; retry after the Retry-After delay.
502—The model provider failed.