Skip to content
AnytimeReply

OpenAI & MCP

OpenAI-compatible API

Use your agent anywhere that accepts an OpenAI base URL — n8n, Typebot, AnyChat, the OpenAI SDKs.

Any tool that lets you set a custom OpenAI base URL can talk to your agent. It answers with its knowledge, Q&A, instructions, guardrails and actions.

SettingValue
Base URLhttps://anytimereply.com/api/openai/v1
API keyYour af_live_… key (create one)
ModelYour agent's ID (or its public key)

List models

GET/api/openai/v1/models

Your agents, in OpenAI's format:

200 OK
{
  "object": "list",
  "data": [
    { "id": "3f2c9a8e-…", "object": "model", "created": 1746173662, "owned_by": "anytimereply", "name": "Support" }
  ]
}

Chat completions

POST/api/openai/v1/chat/completions
curl https://anytimereply.com/api/openai/v1/chat/completions \
  -H "Authorization: Bearer af_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "AGENT_ID", "user": "customer-42", "messages": [{"role": "user", "content": "Opening hours?"}]}'
200 OK
{
  "id": "chatcmpl-5f1c…",
  "object": "chat.completion",
  "created": 1760865600,
  "model": "AGENT_ID",
  "choices": [
    { "index": 0, "message": { "role": "assistant", "content": "We're open every day from 10 am to 8 pm." }, "finish_reason": "stop" }
  ],
  "usage": { "prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0 }
}

How the request is used

Body

modelstringrequired
The agent's ID or public key.
messagesarrayrequired
The conversation. The last user message is the question; earlier user/assistant turns are the history. system / developer messages are added to the agent's instructions as extra context (up to 3,000 characters). Text content parts are supported; images aren't.
userstring
Keeps one conversation per person in the Inbox. Phone numbers are saved as the contact's phone. Without it, the transcript itself identifies the thread.
streamboolean
Stream the answer as chat.completion.chunk events, ending with data: [DONE].
toolsarray
Your functions (up to 20; legacy functions work too). See below. tool_choice: "none" disables them.

Other OpenAI parameters (temperature, max_tokens…) are accepted but ignored — the agent's own settings apply. usage is always zero; credits are counted in your dashboard.

Your tools (handoff to your platform)

Tools you pass are offered to the agent. When it decides to use one — for example a transfer to human tool — the response has finish_reason: "tool_calls" and message.tool_calls for your app to run. Send the result back as usual (assistant message with the tool_calls, then a tool message) and the agent tells the customer what happened.

Through this API the agent never runs its own human handoff: the calling platform owns handoff. If you pass a tool whose name or description mentions a human/agent transfer, the agent is told to call it when a customer asks for a person or is upset.

Errors

Errors use OpenAI's format so SDKs handle them:

JSON
{ "error": { "message": "The model \"abc\" does not exist. Use one of your agent IDs as the model (GET /models lists them).", "type": "not_found_error", "code": null } }

type is authentication_error (401), rate_limit_error (429), not_found_error (404), invalid_request_error (400) or server_error (500).

Settings → API keys → Connect to AnyChat & other AI tools shows the base URL and your agent IDs ready to copy.

Was this page helpful?
Still stuck? Contact us
OpenAI-compatible API – API reference · AnytimeReply