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>"
}
}
'import requests
url = "https://api.example.com/v1/lexi/chat"
payload = {
"message": "<string>",
"context": {
"list_id": "<string>",
"campaign_id": "<string>",
"conversation_id": "<string>"
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
message: '<string>',
context: {list_id: '<string>', campaign_id: '<string>', conversation_id: '<string>'}
})
};
fetch('https://api.example.com/v1/lexi/chat', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/lexi/chat",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'message' => '<string>',
'context' => [
'list_id' => '<string>',
'campaign_id' => '<string>',
'conversation_id' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/lexi/chat"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"context\": {\n \"list_id\": \"<string>\",\n \"campaign_id\": \"<string>\",\n \"conversation_id\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/lexi/chat")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"context\": {\n \"list_id\": \"<string>\",\n \"campaign_id\": \"<string>\",\n \"conversation_id\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lexi/chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": \"<string>\",\n \"context\": {\n \"list_id\": \"<string>\",\n \"campaign_id\": \"<string>\",\n \"conversation_id\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"response": "<string>",
"task_id": "<string>",
"requires_approval": true,
"conversation_id": "<string>"
}
}Lexi AI
Chat with Lexi
Send a message to Lexi AI and get a response
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>"
}
}
'import requests
url = "https://api.example.com/v1/lexi/chat"
payload = {
"message": "<string>",
"context": {
"list_id": "<string>",
"campaign_id": "<string>",
"conversation_id": "<string>"
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
message: '<string>',
context: {list_id: '<string>', campaign_id: '<string>', conversation_id: '<string>'}
})
};
fetch('https://api.example.com/v1/lexi/chat', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/lexi/chat",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'message' => '<string>',
'context' => [
'list_id' => '<string>',
'campaign_id' => '<string>',
'conversation_id' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/lexi/chat"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"context\": {\n \"list_id\": \"<string>\",\n \"campaign_id\": \"<string>\",\n \"conversation_id\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/lexi/chat")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"context\": {\n \"list_id\": \"<string>\",\n \"campaign_id\": \"<string>\",\n \"conversation_id\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/lexi/chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": \"<string>\",\n \"context\": {\n \"list_id\": \"<string>\",\n \"campaign_id\": \"<string>\",\n \"conversation_id\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"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
string
required
Your message to Lexi
object
Response
object
curl -X POST \
https://data.leadlex.com/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"
}
}'
import requests
API_KEY = "wbk_your_api_key_here"
BASE_URL = "https://data.leadlex.com/functions/v1/api-gateway"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
data = {
"message": "Find me 20 CEOs at law firms in New York",
"context": {
"list_id": "list-uuid"
}
}
response = requests.post(f"{BASE_URL}/v1/lexi/chat", headers=headers, json=data)
result = response.json()["data"]
print(f"Lexi: {result['response']}")
if result.get("requires_approval"):
print(f"Task created: {result['task_id']}")
const response = await fetch(
'https://data.leadlex.com/functions/v1/api-gateway/v1/lexi/chat',
{
method: 'POST',
headers: {
'Authorization': 'Bearer wbk_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: 'Find me 20 CEOs at law firms in New York',
context: {
list_id: 'list-uuid'
}
})
}
);
const { data } = await response.json();
console.log(`Lexi: ${data.response}`);
if (data.requires_approval) {
console.log(`Task created: ${data.task_id}`);
}
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
Prospect Search
{
"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
402 Payment Required error.
Errors
| Status | Code | Description |
|---|---|---|
| 400 | validation_error | Missing message parameter |
| 401 | invalid_key | Invalid API key |
| 402 | insufficient_credits | No Lexi credits remaining |
| 403 | insufficient_permissions | Missing lexi permission |
| 429 | rate_limited | Rate limit exceeded |
Example Credit Error
{
"error": {
"code": "insufficient_credits",
"message": "Your workspace has no Lexi credits remaining"
}
}