Skip to main content

Custom Adapter

An adapter is an HTTP server that sits between the relay client and your AI system. It receives OpenAI-compatible chat completion requests and translates them into whatever your target understands, then returns the response in a standard format.

Write a custom adapter when your AI system doesn't expose an OpenAI-compatible endpoint — for example, a proprietary HTTP API, a browser-based interface, or a system that requires session management.

Contract

Your adapter must serve a single HTTP endpoint. The contract is language-agnostic: anything that responds correctly to the request below qualifies.

Example
POST /v1/chat/completions HTTP/1.1
Content-Type: application/json
{
"messages": [
{ "role": "user", "content": "What is the capital of France?" },
{ "role": "assistant", "content": "The capital of France is Paris." },
{ "role": "user", "content": "And of Germany?" }
]
}

messages is an ordered conversation history ending with the current user turn. Use the full history if your target is stateless, or only the last message if it maintains session state.

Example

The pass-through adapter source is a minimal working implementation of the contract above in few lines of Python.