Skip to main content
Glama

Core: Create chat completion

metrecept_create_chat_completion

Send a user prompt to an OpenAI-compatible model and return the reply text, optionally grounded in fetched public pages. Each call is metered and receipted for verification.

Instructions

Send one user message to a model through the Metrecept gateway (OpenAI-compatible) and return the reply text; an exact repeat of a request is served from the tenant's cache. Use it for model answers, optionally grounded in public pages via fetch_urls. Not for the page content itself: use metrecept_fetch_web_pages. Start with model "mock" to test without an upstream key; pick real ids from metrecept_list_models. purpose only applies when fetch_urls is set; check allowed values with metrecept_get_fetch_policy. Pass one session_id across a run's chat, fetch and API calls, then read metrecept_get_session_receipt. Metered and receipted per call. Failures (bad model, missing BYOK key, refused fetch, rate limit) return JSON {"error", "status"}. Requires a Metrecept API key (METRECEPT_API_KEY env on stdio, or Authorization: Bearer on remote HTTP); results are scoped to that key's tenant only.

Input Schema

NameRequiredDescriptionDefault
modelNoModel id from metrecept_list_models; "mock" (default) needs no upstream key, others need BYOK.mock
promptYesThe user message text.
purposeNoFetch purpose used only when fetch_urls is set (default public_web_retrieval).public_web_retrieval
fetch_urlsNoOptional public URLs whose compliant, redacted content is attached as context before the model answers (Terms/DPA must be accepted).
session_idNoOptional session tag; read the signed aggregate later with metrecept_get_session_receipt.
upstream_api_keyNoOptional vendor key for this call (else METRECEPT_UPSTREAM_KEY env); forwarded, never stored.

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changedv0.3.1
    • addedInput schema / properties / fetch_urls / description
      Added value: +"Optional public URLs whose compliant, redacted content is attached as context before the model answers (Terms/DPA must be accepted)."
    • addedInput schema / properties / model / description
      Added value: +"Model id from metrecept_list_models; \"mock\" (default) needs no upstream key, others need BYOK."
    • addedInput schema / properties / prompt / description
      Added value: +"The user message text."
    • addedInput schema / properties / purpose / description
      Added value: +"Fetch purpose used only when fetch_urls is set (default public_web_retrieval)."
    • addedInput schema / properties / session_id / description
      Added value: +"Optional session tag; read the signed aggregate later with metrecept_get_session_receipt."
    • addedInput schema / properties / upstream_api_key / description
      Added value: +"Optional vendor key for this call (else METRECEPT_UPSTREAM_KEY env); forwarded, never stored."
  2. Addedv0.1.4

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so well: it discloses exact-repeat caching, metering and receipting, failure JSON shape, API-key requirements for stdio and HTTP, tenant scoping, and that errors include bad model, missing BYOK key, refused fetch, and rate limit.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The purpose is front-loaded, and most sentences carry actionable information. It is somewhat dense and has minor repetition around purpose/fetch_urls and session/receipt behavior, but it remains readable and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with auth, caching, fetch grounding, metering, and session receipts, the description covers the operational prerequisites and error surfaces. An output schema exists, so return-field detail need not be repeated in the description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3; the description adds workflow meaning by saying "mock" is for testing, real model ids come from metrecept_list_models, purpose matters only with fetch_urls, and session_id should be reused across related calls. It adds useful cross-parameter context beyond the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb and resource: sending one user message to a model through the Metrecept gateway and returning reply text. It also distinguishes the tool from metrecept_fetch_web_pages for page content, so an agent can tell what this tool is and is not for.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly says when to use the tool, how to start with model "mock", where to get real model ids, when purpose applies, when to use fetch_urls, and how session_id should span a run. It also names the alternative for page content and points to metrecept_get_fetch_policy for allowed purpose values.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.