LexeyLexey
HomePricingDocs
Sign in
Customer Chat API
Basics
  • Getting started
Features
  • Manage tab
  • Knowledge base
  • Conversations
  • Customer chat
  • Skills & automations
  • Quality assurance
  • AI safety
  • Billing & usage
Deployment
  • Embedding your chat
API
  • Customer Chat API
  • Management Chat API
  • Webhook events
  • API key management
Help
  • FAQ

Customer Chat API

The Customer Chat API lets your backend create conversations and exchange messages with the support agent on behalf of your users.

Authentication

All requests require a customer API key (lxc_ prefix) in the Authorization header:

Authorization: Bearer lxc_...

Customer API keys are server-side secrets. Do NOT embed them in client-side JavaScript or mobile app bundles. We recommend proxying requests through your application backend.

Base URL

https://lexey.ai/api/v1/customer

Quick start

1. Create a conversation:

curl -X POST https://lexey.ai/api/v1/customer/conversations \
  -H "Authorization: Bearer $LEXEY_CUSTOMER_KEY" \
  -H "Content-Type: application/json"

Response: { "conversationId": "550e8400-..." }

2. Send a message (streamed response):

curl -N -X POST https://lexey.ai/api/v1/customer/conversations/CONVERSATION_ID/messages \
  -H "Authorization: Bearer $LEXEY_CUSTOMER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message": "What are your business hours?"}'

3. Retrieve message history:

curl https://lexey.ai/api/v1/customer/conversations/CONVERSATION_ID/messages \
  -H "Authorization: Bearer $LEXEY_CUSTOMER_KEY"

SSE stream format

The send message endpoint returns text/event-stream:

  • data: {"type":"delta","text":"chunk"} — incremental text, append to the response
  • data: {"type":"status","status":"escalated"} — conversation state change
  • data: [DONE] — stream complete

Node.js example

async function sendMessage(conversationId: string, message: string) {
  const res = await fetch(
    `${BASE_URL}/conversations/${conversationId}/messages`,
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ message }),
    },
  );

  const reader = res.body!.getReader();
  const decoder = new TextDecoder();
  let fullText = "";

  while (true) {
    const { done, value } = await reader.read();
    if (done) break;

    const chunk = decoder.decode(value, { stream: true });
    for (const line of chunk.split("\n")) {
      if (!line.startsWith("data: ")) continue;
      const data = line.slice(6);
      if (data === "[DONE]") break;

      const event = JSON.parse(data);
      if (event.type === "delta") {
        fullText += event.text;
      }
    }
  }

  return fullText;
}

Error codes

StatusMeaning
400Invalid request (e.g. message too long)
401Missing or invalid API key
402No active subscription or credits exhausted
403Wrong key type (use lxc_ key)
404Conversation not found
429Conversation message limit reached
500

Product

  • Features
  • Pricing
  • Use Cases

Documentation

  • Getting Started
  • Customer API
  • Management API

Company

  • Sign Up
  • Sign In
  • Terms of Service
  • Privacy Policy
© 2026 Re-X. All rights reserved.