Skip to main content
POST
/
v1
/
public
/
chat
curl --request POST \
  --url https://prod.eigi.ai/v1/public/chat \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "agent_id": "68ea2517dbb84c09bae1ba0a",
  "message": "Hello, how can you help me?",
  "streaming": true
}
'
{
  "response": "<string>",
  "session_id": "<string>"
}

Overview

This endpoint enables text-based conversations with your AI agents. It supports both streaming and non-streaming responses, making it ideal for chatbots, customer support widgets, and interactive applications.

Authentication

X-API-Key
string
required
Your eigi.ai API key. Must be prefixed with vk_.

Request Body

agent_id
string
required
The unique identifier of the agent to chat with. Example: 68ea2517dbb84c09bae1ba0a
message
string
required
The user’s message to send to the agent. Must be between 1 and 4000 characters. Example: "Hello, I need help with my account"
session_id
string
Session ID for continuing a conversation. If not provided, a new session will be created. Example: 58a6b549-ef07-4a31-86bc-0eb0e026840a
streaming
boolean
default:"true"
Whether to stream the response in real-time or wait for the complete response.
  • true: Response streams as it’s generated (recommended for chat UIs) - false: Returns complete response as JSON
metadata
object
Additional metadata to attach to the conversation. Useful for tracking user context.Example: {"user_id": "user_123", "source": "website"}

Response

Streaming Response (streaming=true)

Returns a text/plain stream with the agent’s response delivered word-by-word. Response Headers:
HeaderDescription
X-Session-IDThe session ID to use for subsequent messages
Content-Typetext/plain; charset=utf-8
Stream Format: The response body contains the text as it’s being generated, suitable for displaying in real-time.

Non-Streaming Response (streaming=false)

response
string
The complete response from the AI agent.
session_id
string
The session ID to use for subsequent messages in this conversation.

Examples

Streaming Request

curl -X POST "https://prod.eigi.ai/v1/public/chat" \
  -H "X-API-Key: vk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "68ea2517dbb84c09bae1ba0a",
    "message": "Hello, how can you help me?",
    "streaming": true
  }'

Non-Streaming Request

curl -X POST "https://prod.eigi.ai/v1/public/chat" \
  -H "X-API-Key: vk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "68ea2517dbb84c09bae1ba0a",
    "message": "What are your business hours?",
    "streaming": false
  }'

Non-Streaming Response Example

{
  "response": "Hello! I'd be happy to help you. Our business hours are Monday through Friday, 9 AM to 6 PM EST. Is there something specific I can assist you with today?",
  "session_id": "58a6b549-ef07-4a31-86bc-0eb0e026840a"
}

Continuing a Conversation

Use the session_id from previous responses to maintain conversation context:
cURL
curl -X POST "https://prod.eigi.ai/v1/public/chat" \
  -H "X-API-Key: vk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "68ea2517dbb84c09bae1ba0a",
    "session_id": "58a6b549-ef07-4a31-86bc-0eb0e026840a",
    "message": "What about weekends?",
    "streaming": false
  }'

Error Responses

Status CodeDescription
400 Bad RequestAgent has no LLM configuration or message is invalid
401 UnauthorizedMissing, invalid, inactive, or expired API key
403 ForbiddenAPI key owner doesn’t have access to this agent
404 Not FoundAgent not found
Example Error Response
{
  "detail": "Agent does not have LLM configuration"
}

Best Practices

Use Streaming for Chat UIs: Streaming provides a more responsive user experience by showing the response as it’s generated.
Persist Session IDs: Store session IDs to maintain conversation context across multiple messages.
Include Metadata: Use the metadata field to track user context, which can help with personalization and analytics.
Messages are limited to 4000 characters. For longer content, consider breaking it into multiple messages.

Authorizations

X-API-Key
string
header
required

API key for authentication. Get your API key from the eigi.ai Dashboard under Settings → API Keys.

Body

application/json
agent_id
string
required

The ID of the agent to chat with

Example:

"68ea2517dbb84c09bae1ba0a"

message
string
required

User message to send to the agent

Required string length: 1 - 4000
Example:

"Hello, how can you help me?"

session_id
string

Session ID for continuing a conversation (created if not provided)

Example:

"58a6b549-ef07-4a31-86bc-0eb0e026840a"

streaming
boolean
default:true

If true, response streams in real-time. If false, returns complete JSON response.

metadata
object

Additional metadata for the conversation

Example:
{
"user_id": "user_123",
"source": "website"
}

Response

Chat response (JSON for non-streaming, text/plain stream for streaming)

response
string

The AI agent's response

session_id
string

Session ID for subsequent messages