Skip to main content

Chat with AI API

A unified chat endpoint that consolidates all AI chat interactions into a single, streamlined API.

Migration Notice

All legacy chat endpoints (CHAT_WITH_AI, CHAT_WITH_IMAGE, CHAT_WITH_PDF, CHAT_WITH_YOUTUBE_VIDEO via AI Feature API) will be deprecated in a future release. Please migrate to this unified Chat with AI API using the UNIFY_CHAT_WITH_AI type for all new integrations.

Overview

The Chat with AI API provides a dedicated endpoint for all chat-related interactions, replacing the need to use the general-purpose AI Feature API for chat. It supports both streaming and non-streaming modes, web search, image attachments, conversation history, brand voice, and memory features.

Key benefits over the legacy AI Feature API for chat:

  • Dedicated chat endpoint with optimized streaming
  • Structured prompt settings (web search, history, attachments) via a clean nested object
  • Built-in support for AI memory across conversations
  • Simplified request format

Endpoints

Streaming Chat

Non-Streaming Chat

Authentication

All requests require authentication using an API key in the request header.

FieldValue
API-KEY<api-key>
Content-Typeapplication/json

Request Payload

Required Parameters

ParameterTypeRequiredDescription
typestring✔️Feature type. Use UNIFY_CHAT_WITH_AI (defaults to this if omitted)
modelstring✔️AI model to use
promptObjectobject✔️Chat parameters (see below)

Optional Parameters

ParameterTypeRequiredDescription
brandVoiceIdstring-Brand voice ID to apply a custom tone/style to the response
metadataobject-Additional metadata for the request

Available Models

Loading available models...

promptObject Parameters

ParameterTypeRequiredDescription
promptstring✔️The user's message
conversationIdstring-Conversation ID for multi-turn chat context
settingsobject-Chat settings (see below)
attachmentsobject-File and image attachments (see below)

settings Object

ParameterTypeRequiredDescription
webSearchSettingsobject-Web search configuration
historySettingsobject-Conversation history configuration
withMemoriesboolean-Enable AI memory across conversations (default: false)

webSearchSettings

ParameterTypeDefaultDescription
webSearchbooleanfalseEnable web search for grounding responses
numOfSitenumber3Number of sites to search (when webSearch is true)
maxWordnumber1000Maximum words from web search (when webSearch is true)

historySettings

ParameterTypeDefaultDescription
isMixedbooleanfalseMix context from different AI models in conversation history
historyMessageLimitnumber10Maximum number of history messages to include as context

attachments Object

ParameterTypeDefaultDescription
imagesstring[][]Image URLs or asset keys from Asset API
filesstring[][]File IDs from Asset API

Example Requests

Simple Chat (No Context)

Loading interactive playground...

Chat with Conversation History

fetch('https://api.1min.ai/api/chat-with-ai?isStreaming=true', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'API-KEY': 'YOUR_API_KEY'
},
body: JSON.stringify({
type: 'UNIFY_CHAT_WITH_AI',
model: 'gpt-4o-mini',
promptObject: {
prompt: 'Can you elaborate on that?',
conversationId: 'c5c5e1d4-76a9-46a6-bf6b-1ba843b838db',
settings: {
historySettings: {
isMixed: false,
historyMessageLimit: 10
}
}
}
})
})
fetch('https://api.1min.ai/api/chat-with-ai?isStreaming=true', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'API-KEY': 'YOUR_API_KEY'
},
body: JSON.stringify({
type: 'UNIFY_CHAT_WITH_AI',
model: 'gpt-4o-mini',
promptObject: {
prompt: 'What are the latest developments in AI?',
settings: {
webSearchSettings: {
webSearch: true,
numOfSite: 3,
maxWord: 1000
}
}
}
})
})

Chat with Image Attachments

fetch('https://api.1min.ai/api/chat-with-ai?isStreaming=true', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'API-KEY': 'YOUR_API_KEY'
},
body: JSON.stringify({
type: 'UNIFY_CHAT_WITH_AI',
model: 'gpt-4o-mini',
promptObject: {
prompt: 'What do you see in this image?',
attachments: {
images: ['development/images/2024_09_30_13_41_50_758_photo.png']
}
}
})
})

Chat with File Attachments

Upload files via the Asset API first, then pass the returned file IDs in attachments.files.

fetch('https://api.1min.ai/api/chat-with-ai?isStreaming=true', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'API-KEY': 'YOUR_API_KEY'
},
body: JSON.stringify({
type: 'UNIFY_CHAT_WITH_AI',
model: 'gpt-4o-mini',
promptObject: {
prompt: 'Summarize the key points from this document',
attachments: {
files: ['20ad0277-74df-4629-8c50-56a2549acbd7']
}
}
})
})

Chat with YouTube Video

Include a YouTube URL directly in your prompt. The AI will automatically detect the link, fetch the video transcript, and use it as context for the conversation. Up to 3 YouTube URLs are supported per request.

fetch('https://api.1min.ai/api/chat-with-ai?isStreaming=true', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'API-KEY': 'YOUR_API_KEY'
},
body: JSON.stringify({
type: 'UNIFY_CHAT_WITH_AI',
model: 'gpt-4o-mini',
promptObject: {
prompt: 'Summarize this video https://www.youtube.com/watch?v=dQw4w9WgXcQ'
}
})
})

Non-Streaming Chat

fetch('https://api.1min.ai/api/chat-with-ai', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'API-KEY': 'YOUR_API_KEY'
},
body: JSON.stringify({
type: 'UNIFY_CHAT_WITH_AI',
model: 'gpt-4o-mini',
promptObject: {
prompt: 'Explain quantum computing in simple terms'
}
})
})

Streaming Response

For streaming requests (?isStreaming=true), the response is sent as Server-Sent Events (SSE):

Event Types

EventDescription
contentA chunk of the AI-generated response
resultFinal AI record with full response data
doneStream completed signal
errorError occurred during processing

Streaming Event Format

event: content
data: {"content": "Artificial intelligence is"}

event: content
data: {"content": " a branch of computer science..."}

event: result
data: {"aiRecord": { ... }}

event: done
data: {"message": "Stream completed"}

Non-Streaming Response

Success Response (200)

{
"aiRecord": {
"uuid": "120qae97-d77d-468d-9d78-2e7c0b2bbb98",
"userId": "75cz1a57-c969-47ac-9dc5-82941cdcfe57",
"teamId": "595w4b41-dcc7-466f-8697-d4a919810b11",
"teamUser": {
"teamId": "595w4b41-dcc7-466f-8697-d4a919810b11",
"userId": "75cz1a57-c969-47ac-9dc5-82941cdcfe57",
"userName": "1minAI",
"userAvatar": "https://lh3.googleusercontent.com/a/ACg8ocJxHeiuADdtp",
"status": "ACTIVE",
"role": "ADMIN",
"creditLimit": 214748364,
"usedCredit": 3086973,
"createdAt": "2023-11-24T06:31:06.467Z",
"createdBy": "SYSTEM",
"updatedAt": "2024-09-29T09:17:08.210Z",
"updatedBy": "SYSTEM"
},
"model": "gpt-4o-mini",
"type": "UNIFY_CHAT_WITH_AI",
"metadata": null,
"rating": null,
"feedback": null,
"conversationId": null,
"status": "SUCCESS",
"createdAt": "2024-09-30T03:47:29.738Z",
"aiRecordDetail": {
"promptObject": {
"prompt": "Explain quantum computing in simple terms",
"linkContentList": [],
"searchContentList": []
},
"resultObject": [
"Quantum computing is a type of computing that uses quantum bits (qubits) instead of classical bits..."
]
},
"modelDetail": {
"name": "gpt-4o-mini",
"provider": "OPENAI"
}
}
}

Response Fields

aiRecord Object

FieldTypeDescription
uuidstringUnique identifier for the AI record
userIdstringUser identifier
teamIdstringTeam identifier
teamUserobjectTeam user details and permissions
modelstringModel used for processing
typestringFeature type (UNIFY_CHAT_WITH_AI)
metadataobjectAdditional metadata (nullable)
ratingnumberUser rating for the result (nullable)
feedbackstringUser feedback text (nullable)
conversationIdstringAssociated conversation ID (nullable)
statusstringProcessing status (SUCCESS, FAILED, etc.)
createdAtstringRecord creation timestamp (ISO 8601)
aiRecordDetailobjectDetailed request and response data (see below)
modelDetailobjectModel information (name, provider)

aiRecordDetail Object

FieldTypeDescription
promptObjectobjectOriginal request parameters (prompt, settings, etc.)
resultObjectstring[]AI-generated response content as a list of strings

Error Responses

Bad Request (400)

{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "Missing required parameters or invalid format"
}
}

Unauthorized (401)

{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}
}

Validation Error (422)

{
"success": false,
"error": {
"code": "PROMPT_OBJECT_VALIDATION_FAILED",
"message": "Invalid prompt object",
"details": [
{
"field": "prompt",
"message": "prompt must be a string"
}
]
}
}

Rate Limited (429)

{
"success": false,
"error": {
"code": "RATE_LIMITED",
"message": "Too many requests"
}
}

Migration Guide

Migrating from AI Feature API

If you are currently using the AI Feature API with CHAT_WITH_AI, CHAT_WITH_IMAGE, CHAT_WITH_PDF, or CHAT_WITH_YOUTUBE_VIDEO types, here's how to migrate:

Before (Legacy - AI Feature API):

{
"type": "CHAT_WITH_AI",
"model": "gpt-4o-mini",
"promptObject": {
"prompt": "Hello!",
"isMixed": false,
"webSearch": true,
"numOfSite": 3,
"maxWord": 500
}
}

After (New - Chat with AI API):

{
"type": "UNIFY_CHAT_WITH_AI",
"model": "gpt-4o-mini",
"promptObject": {
"prompt": "Hello!",
"settings": {
"historySettings": {
"isMixed": false
},
"webSearchSettings": {
"webSearch": true,
"numOfSite": 3,
"maxWord": 500
}
}
}
}

Key Differences

AspectLegacy (AI Feature API)New (Chat with AI API)
EndpointPOST /api/featuresPOST /api/chat-with-ai
TypeCHAT_WITH_AI / CHAT_WITH_IMAGE / CHAT_WITH_PDF / CHAT_WITH_YOUTUBE_VIDEOUNIFY_CHAT_WITH_AI
Prompt structureFlat promptObject with mixed paramsStructured promptObject with nested settings
Image supportSeparate CHAT_WITH_IMAGE type + imageListSame type with attachments.images
Web searchTop-level webSearch, numOfSite, maxWordNested under settings.webSearchSettings
History configTop-level isMixedNested under settings.historySettings
PDF/File supportSeparate CHAT_WITH_PDF type + conversationSame type with attachments.files
YouTube supportSeparate CHAT_WITH_YOUTUBE_VIDEO type + conversationSame type — just include YouTube URL in prompt
MemoryNot availablesettings.withMemories for cross-conversation memory
Streaming eventsRaw text streamStructured SSE with content, result, done events

Conversation Type Changes

When creating conversations via the Conversation API, use UNIFY_CHAT_WITH_AI as the type instead of CHAT_WITH_AI, CHAT_WITH_IMAGE, CHAT_WITH_PDF, or CHAT_WITH_YOUTUBE_VIDEO.