AI Assistants API
Overview
The AI Assistants API enables you to build intelligent conversational interfaces powered by Claude AI models. Create custom AI assistants with specialized knowledge, integrate vector-based semantic search for context-aware responses, and manage persistent conversation threads for engaging user experiences. This API forms the foundation for AI-powered personalization and customer experience features in Stack9.
Resource Description
The AI Assistants ecosystem in Stack9 consists of three interconnected components:
- AI Assistants: Configurable AI agents with customized system prompts, model selection, and tool integration capabilities
- Chat Threads: Persistent conversation histories that maintain context across multiple interactions
- Vector Indexes: Semantic search capabilities for knowledge retrieval and RAG (Retrieval Augmented Generation) implementations
Key Capabilities
- Multi-Model Support: Choose between Claude 3 Opus, Sonnet, and Haiku models based on performance and cost requirements
- Custom System Prompts: Define specialized behaviors and knowledge domains for each assistant
- Tool Integration: Enable function calling for dynamic actions and external system integration
- Conversation Memory: Maintain context across sessions with persistent thread management
- Semantic Search: Build knowledge bases with vector embeddings for accurate information retrieval
- Multimodal Support: Process text and image inputs for richer interactions
Authentication
All endpoints require API key authentication:
X-API-Key: your-api-key-here
AI Assistant Management
Create AI Assistant
Create a new AI assistant with custom configuration including model selection, system prompt, and parameters.
POST /api/ai/assistants
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Short, memorable name for the assistant |
description | string | Yes | Description of the assistant's purpose and capabilities |
llmConfiguration | object | Yes | Language model configuration object |
llmConfiguration.system | string | Yes | System prompt defining the assistant's behavior and context |
llmConfiguration.temperature | number | Yes | Randomness in responses (0.0-1.0). Lower for analytical tasks, higher for creative |
llmConfiguration.model | string | Yes | Claude model to use (see model options below) |
llmConfiguration.max_tokens | number | Yes | Maximum tokens to generate in responses |
llmConfiguration.tools | array | No | Function calling tools available to the assistant |
Model Options
| Model | Description | Use Cases |
|---|---|---|
claude-3-opus-20240229 | Most capable model with superior performance | Complex reasoning, creative writing, detailed analysis |
claude-3-5-sonnet-20240620 | Balanced performance and speed | General purpose, customer support, content generation |
claude-3-sonnet-20240229 | Previous generation Sonnet model | Legacy applications, cost optimization |
claude-3-haiku-20240307 | Fastest and most cost-effective | Simple queries, high-volume processing, real-time responses |
Tool Configuration
Tools enable the assistant to perform actions and retrieve information dynamically:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique identifier for the tool |
description | string | Yes | Detailed description of tool functionality (3-4 sentences recommended) |
input_schema | object | Yes | JSON Schema defining expected parameters |
input_schema.type | string | Yes | Must be "object" |
input_schema.properties | object | Yes | Parameter definitions |
input_schema.required | array | Yes | List of required parameter names |
Example Request
curl -X POST \
https://apis.app.stack9.co/api/ai/assistants \
-H 'X-API-Key: your-api-key-here' \
-H 'Content-Type: application/json' \
-d '{
"name": "Customer Support Assistant",
"description": "AI assistant specialized in handling customer inquiries and support tickets",
"llmConfiguration": {
"system": "You are a helpful customer support assistant for an e-commerce platform. You have access to order information, product details, and can help with returns and exchanges. Always be polite, professional, and aim to resolve customer issues efficiently.",
"temperature": 0.3,
"model": "claude-3-5-sonnet-20240620",
"max_tokens": 2048,
"tools": [
{
"name": "lookup_order",
"description": "Retrieves order details by order ID. Use this when customers ask about their order status, tracking information, or order contents. Returns order date, status, items, and tracking number.",
"input_schema": {
"type": "object",
"properties": {
"order_id": {
"type": "string",
"description": "The unique order identifier"
},
"include_tracking": {
"type": "boolean",
"description": "Whether to include tracking details"
}
},
"required": ["order_id"]
}
}
]
}
}'
Example Response
{
"id": "550e8400-e29b-41d4-a716-446655440000"
}
List AI Assistants
Retrieve all AI assistants with pagination support.
GET /api/ai/assistants
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
page | number | No | Page number for pagination (default: 1) |
limit | number | No | Number of results per page (default: 20) |
Example Request
curl -X GET \
'https://apis.app.stack9.co/api/ai/assistants?page=1&limit=10' \
-H 'X-API-Key: your-api-key-here'
Example Response
{
"results": [
{
"version": 1,
"created_at": "2024-01-15T10:30:00.123Z",
"updated_at": null,
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Customer Support Assistant",
"description": "AI assistant specialized in handling customer inquiries and support tickets"
},
{
"version": 2,
"created_at": "2024-01-14T08:15:00.456Z",
"updated_at": "2024-01-15T09:20:00.789Z",
"id": "660f9500-f39c-52e5-b827-557766550001",
"name": "Product Recommendation Engine",
"description": "Personalized product recommendations based on user preferences and behavior"
}
],
"total": 15,
"totalPages": 2
}
Get AI Assistant
Retrieve detailed information about a specific AI assistant including full configuration.
GET /api/ai/assistants/{id}
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | uuid | Yes | The unique assistant identifier |
Example Request
curl -X GET \
https://apis.app.stack9.co/api/ai/assistants/550e8400-e29b-41d4-a716-446655440000 \
-H 'X-API-Key: your-api-key-here'
Example Response
{
"version": 3,
"created_at": "2024-01-15T10:30:00.123Z",
"updated_at": "2024-01-16T14:45:00.789Z",
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Customer Support Assistant",
"description": "AI assistant specialized in handling customer inquiries and support tickets",
"llmConfiguration": {
"system": "You are a helpful customer support assistant for an e-commerce platform...",
"temperature": 0.3,
"model": "claude-3-5-sonnet-20240620",
"max_tokens": 2048,
"tools": [
{
"name": "lookup_order",
"description": "Retrieves order details by order ID...",
"input_schema": {
"type": "object",
"properties": {
"order_id": {
"type": "string",
"description": "The unique order identifier"
}
},
"required": ["order_id"]
}
}
]
}
}
Update AI Assistant
Update an existing AI assistant's configuration, including system prompt, model, or tools.
PUT /api/ai/assistants/{id}
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | uuid | Yes | The unique assistant identifier |
Request Body
Same as Create AI Assistant parameters.
Example Request
curl -X PUT \
https://apis.app.stack9.co/api/ai/assistants/550e8400-e29b-41d4-a716-446655440000 \
-H 'X-API-Key: your-api-key-here' \
-H 'Content-Type: application/json' \
-d '{
"name": "Enhanced Support Assistant",
"description": "Upgraded customer support assistant with advanced capabilities",
"llmConfiguration": {
"system": "You are an expert customer support assistant...",
"temperature": 0.4,
"model": "claude-3-opus-20240229",
"max_tokens": 4096
}
}'
Example Response
{
"success": true
}
Chat Thread Management
Create Chat Thread
Initialize a new conversation thread with an AI assistant.
POST /api/ai/threads
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
version | number | Yes | Version number for optimistic locking |
created_at | datetime | Yes | ISO 8601 timestamp of creation |
assistant_id | uuid | Yes | ID of the AI assistant to use |
user_id | string | Yes | Unique user identifier (alphanumeric, hyphens, underscores) |
messages | array | Yes | Initial messages in the conversation |
Message Structure
Messages support multiple content types:
Text Messages
{
"role": "user",
"content": [
{
"type": "text",
"text": "Hello, I need help with my order"
}
]
}