Skip to main content
POST
/
api
/
v1
/
ai
/
conversations
/
chat
Chat with conversation memory
curl --request POST \
  --url https://api.dualship.run/api/v1/ai/conversations/chat \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'X-Workspace-Id: <x-workspace-id>' \
  --data '
{
  "conversation_id": "<string>",
  "message": "<string>",
  "workspace_id": "<string>",
  "document_ids": [
    "<string>"
  ],
  "max_history": 50,
  "max_tokens": 8192,
  "model": "<string>",
  "system_prompt": "<string>",
  "temperature": 1
}
'
import requests

url = "https://api.dualship.run/api/v1/ai/conversations/chat"

payload = {
"conversation_id": "<string>",
"message": "<string>",
"workspace_id": "<string>",
"document_ids": ["<string>"],
"max_history": 50,
"max_tokens": 8192,
"model": "<string>",
"system_prompt": "<string>",
"temperature": 1
}
headers = {
"X-Workspace-Id": "<x-workspace-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {
'X-Workspace-Id': '<x-workspace-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
conversation_id: '<string>',
message: '<string>',
workspace_id: '<string>',
document_ids: ['<string>'],
max_history: 50,
max_tokens: 8192,
model: '<string>',
system_prompt: '<string>',
temperature: 1
})
};

fetch('https://api.dualship.run/api/v1/ai/conversations/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.dualship.run/api/v1/ai/conversations/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([
'conversation_id' => '<string>',
'message' => '<string>',
'workspace_id' => '<string>',
'document_ids' => [
'<string>'
],
'max_history' => 50,
'max_tokens' => 8192,
'model' => '<string>',
'system_prompt' => '<string>',
'temperature' => 1
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Workspace-Id: <x-workspace-id>"
],
]);

$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.dualship.run/api/v1/ai/conversations/chat"

payload := strings.NewReader("{\n \"conversation_id\": \"<string>\",\n \"message\": \"<string>\",\n \"workspace_id\": \"<string>\",\n \"document_ids\": [\n \"<string>\"\n ],\n \"max_history\": 50,\n \"max_tokens\": 8192,\n \"model\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"temperature\": 1\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("X-Workspace-Id", "<x-workspace-id>")
req.Header.Add("Authorization", "Bearer <token>")
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.dualship.run/api/v1/ai/conversations/chat")
.header("X-Workspace-Id", "<x-workspace-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"conversation_id\": \"<string>\",\n \"message\": \"<string>\",\n \"workspace_id\": \"<string>\",\n \"document_ids\": [\n \"<string>\"\n ],\n \"max_history\": 50,\n \"max_tokens\": 8192,\n \"model\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"temperature\": 1\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.dualship.run/api/v1/ai/conversations/chat")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Workspace-Id"] = '<x-workspace-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"conversation_id\": \"<string>\",\n \"message\": \"<string>\",\n \"workspace_id\": \"<string>\",\n \"document_ids\": [\n \"<string>\"\n ],\n \"max_history\": 50,\n \"max_tokens\": 8192,\n \"model\": \"<string>\",\n \"system_prompt\": \"<string>\",\n \"temperature\": 1\n}"

response = http.request(request)
puts response.read_body
{
  "content": "Here is my response...",
  "conversation_id": "conv_abc123",
  "input_tokens": 150,
  "model": "gpt-4",
  "output_tokens": 200
}
{
"code": "BAD_REQUEST",
"error": "invalid request parameters"
}
{
"code": "UNAUTHORIZED",
"error": "unauthorized"
}
{
"code": "INTERNAL_ERROR",
"error": "internal server error"
}
{
"code": "SERVICE_UNAVAILABLE",
"error": "service unavailable"
}

Authorizations

Authorization
string
header
required

JWT Bearer token authentication

Headers

X-Workspace-Id
string
required

Workspace ID

Body

application/json

Chat request

conversation_id
string
required
Required string length: 1 - 100
message
string
required
Minimum string length: 1
workspace_id
string
required
document_ids
string[]
Maximum array length: 10
max_history
integer
Required range: 1 <= x <= 100
max_tokens
integer
Required range: 1 <= x <= 16384
model
string
system_prompt
string
Maximum string length: 10000
temperature
number
Required range: 0 <= x <= 2

Response

Chat response

Conversation chat response

content
string
Example:

"Here is my response..."

conversation_id
string
Example:

"conv_abc123"

input_tokens
integer
Example:

150

model
string
Example:

"gpt-4"

output_tokens
integer
Example:

200