Core: Create chat completion
metrecept_create_chat_completionSend 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
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | Model id from metrecept_list_models; "mock" (default) needs no upstream key, others need BYOK. | mock |
| prompt | Yes | The user message text. | |
| purpose | No | Fetch purpose used only when fetch_urls is set (default public_web_retrieval). | public_web_retrieval |
| fetch_urls | No | Optional public URLs whose compliant, redacted content is attached as context before the model answers (Terms/DPA must be accepted). | |
| session_id | No | Optional session tag; read the signed aggregate later with metrecept_get_session_receipt. | |
| upstream_api_key | No | Optional vendor key for this call (else METRECEPT_UPSTREAM_KEY env); forwarded, never stored. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |