Skip to main content
POST
/
v1
/
lexi
/
chat
Chat with Lexi
curl --request POST \
  --url https://api.example.com/v1/lexi/chat \
  --header 'Content-Type: application/json' \
  --data '
{
  "message": "<string>",
  "context": {
    "list_id": "<string>",
    "campaign_id": "<string>",
    "conversation_id": "<string>"
  }
}
'
{
  "data": {
    "response": "<string>",
    "task_id": "<string>",
    "requires_approval": true,
    "conversation_id": "<string>"
  }
}

Request

Headers

Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json

Body Parameters

message
string
required
Your message to Lexi
context
object
Optional context to help Lexi understand the request

Response

data
object
curl -X POST \
  https://nbkxaqxwvkgbddekwsma.supabase.co/functions/v1/api-gateway/v1/lexi/chat \
  -H "Authorization: Bearer wbk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Find me 20 CEOs at law firms in New York",
    "context": {
      "list_id": "list-uuid"
    }
  }'

Example Response (No Approval Required)

{
  "data": {
    "response": "I found 20 CEOs at law firms in New York. I've added them to your list.",
    "task_id": null,
    "requires_approval": false,
    "conversation_id": "conv-uuid"
  }
}

Example Response (Approval Required)

{
  "data": {
    "response": "I'll search for 20 CEOs at law firms in New York and add them to your list. Please approve this task to proceed.",
    "task_id": "task-uuid",
    "requires_approval": true,
    "conversation_id": "conv-uuid"
  }
}

Example Prompts

{
  "message": "Find CTOs at SaaS companies with 50-200 employees in California"
}

Campaign Creation

{
  "message": "Create an outreach campaign for my 'Q1 Leads' list about legal automation",
  "context": {
    "list_id": "list-uuid"
  }
}

Follow-up Question

{
  "message": "Can you make the email more casual?",
  "context": {
    "conversation_id": "conv-uuid"
  }
}

Conversation Threading

Use conversation_id to continue a conversation. Lexi will remember the context from previous messages.
# First message
response1 = client.chat_with_lexi("Find CEOs at law firms")
conv_id = response1["conversation_id"]

# Follow-up (Lexi remembers we're talking about CEOs at law firms)
response2 = client.chat_with_lexi(
    "Filter to only New York",
    context={"conversation_id": conv_id}
)

Rate Limiting & Credits

Lexi chat calls deduct from your workspace’s AI credit balance in addition to counting toward API rate limits.
  • 1 credit per message
  • 5 credits for prospect search tasks
If credits run out, you’ll receive a 402 Payment Required error.

Errors

StatusCodeDescription
400validation_errorMissing message parameter
401invalid_keyInvalid API key
402insufficient_creditsNo Lexi credits remaining
403insufficient_permissionsMissing lexi permission
429rate_limitedRate limit exceeded

Example Credit Error

{
  "error": {
    "code": "insufficient_credits",
    "message": "Your workspace has no Lexi credits remaining"
  }
}