Skip to content

Guided tour

FabrCore 2.0 · Release and package availability

These guides track the current 2.0 source. Stable 2.0.0 publication is pending; package commands show the release target. Until it is published, follow the source quick start or use a matching available prerelease set. Release migration · Runtime modes

MODULE 11 · LESSON 11.1

Offer OpenAI-compatible chat completions

Expose agents through an OpenAI-compatible chat-completions interface.

Lesson 65 of 86 · FabrCore 2.0

Overview

A compatible API lets existing clients call an agent without adopting its internal runtime. The exposed agent endpoint is not the same thing as the named provider model it uses. Authentication and principal ownership still belong at ingress.

The public API hides the agent implementation

An OpenAI-compatible client sends a familiar chat request, while the Host routes it to the exposed FabrCore behavior. The endpoint's external selection is distinct from the internal model alias that the agent resolves. Your application still owns authentication, caller mapping and which agents this interface exposes.

Compatibility is a contract to test

Clients differ in their assumptions about messages, response envelopes, streaming and errors. Start with the documented non-streaming request shape and verify the consumer you intend to support. Do not advertise every provider-specific option merely because the endpoint resembles another API. The underlying agent can still use tools and runtime state through its ordinary implementation.

Call the compatibility endpoint

  1. Configure the Host ChatCompletion endpoint and authorized target agent using the reference contract.
  2. Send a supported request from a C# HTTP/OpenAI-compatible client. Compare buffered and streamed behavior against the fields the Host actually supports.
  3. Test invalid agent selection, authentication failure and cancellation. Document compatibility limits rather than promising every provider extension.
ChatCompletion API (`/fabrcoreapi/ChatCompletion`) · reference snippet
{
  "Messages": [
    { "Role": "user", "Content": "Extract entities from this text..." }
  ],
  "Options": {
    "Model": "gpt-4o-mini",
    "MaxOutputTokens": 2048,
    "Temperature": 0.2
  }
}
ChatCompletion API (`/fabrcoreapi/ChatCompletion`) · reference snippet
{
  "Text": "The extracted response text...",
  "Model": "gpt-4o-mini",
  "Usage": { "InputTokens": 150, "OutputTokens": 80 }
}

Use a real compatible client

  1. Send the illustrated request to the documented ChatCompletion route using the intended authenticated caller. Inspect the HTTP status and compatible response envelope.
  2. Read that response with your chosen client library and verify the answer corresponds to the target agent. A successful raw JSON response does not establish that the client can parse it.
  3. Test an unknown target and missing authentication. Confirm the consumer receives a useful error instead of an unrelated model response or shared-principal fallback.

This verifies compatibility for the exercised request shape and caller. Test streaming separately if the deployed endpoint and client support it.

If the result is different

Do not substitute an LLM credential alias for an agent handle. Check the exact endpoint/request model before assuming provider-specific options are forwarded.

Go deeper

Explore the related documentation.