Start a chat
POSThttps://api.vectara.io/v2/chats
Create a chat while specifying the default retrieval parameters used by the prompt.
Request
Header Parameters
Possible values: >= 1
The API will make a best effort to complete the request in the specified seconds or time out.
Possible values: >= 1
The API will make a best effort to complete the request in the specified milliseconds or time out.
- application/json
Body
The chat message or question.
search object
generation object
chat object
Default value: true
Indicates whether to save the chat in both the chat and query history. This overrides chat.store
.
Default value: false
Indicates whether the response should be streamed or not.
Responses
- 200
- 400
- 403
- 404
A response to a chat request.
- application/json
- text/event-stream
- Schema
- Example (from schema)
Schema
If the chat response was stored, the ID of the chat.
If the chat response was stored, the ID of the turn.
The message from the chat model for the chat message.
Possible values: [auto
, eng
, deu
, fra
, zho
, kor
, ara
, rus
, tha
, nld
, ita
, por
, spa
, jpn
, pol
, tur
, vie
, ind
, ces
, ukr
, ell
, heb
, fas
, hin
, urd
, swe
, ben
, msa
, ron
]
Default value: auto
Languages that the Vectara platform supports.
search_results object[]
The probability that the summary is factually consistent with the results.
The rendered prompt sent to the LLM. Useful when creating customer prompt_template
templates.
View the actual query made to backend that was rephrased by the LLM from the input query.
{
"chat_id": "string",
"turn_id": "string",
"answer": "string",
"response_language": "auto",
"search_results": [
{
"text": "string",
"score": 0,
"part_metadata": {},
"document_metadata": {},
"document_id": "string",
"table": {
"id": "table_1",
"title": "string",
"data": {
"headers": [
[
{
"text_value": "string",
"int_value": 0,
"float_value": 0,
"bool_value": true,
"colspan": 0,
"rowspan": 0
}
]
],
"rows": [
[
{
"text_value": "string",
"int_value": 0,
"float_value": 0,
"bool_value": true,
"colspan": 0,
"rowspan": 0
}
]
]
},
"description": "string"
},
"request_corpora_index": 0
}
],
"factual_consistency_score": 0,
"rendered_prompt": "string",
"rephrased_query": "string"
}
- Schema
- Example (from schema)
Schema
- StreamSearchResponse
- ChatInfoResponse
- StreamGenerationChunk
- StreamGenerationEnd
- FactualConsistencyScore
- StreamResponseEnd
- GenerationInfo
- StreamError
Default value: search_results
When the streaming event has the search results, the
type will be search_results
.
search_results object[]
Default value: chat_info
This will be chat_info
when the stream event contains information
about how the chat is stored.
Possible values: Value must match regular expression cht_.+$
ID of the chat.
Possible values: Value must match regular expression trn_.+$
ID of the turn.
Default value: generation_chunk
When the streaming event contains the next chunk of generator output, the
type will be generation_chunk
.
Part of the message from the generator. All summary chunks must be appended together in order to get the full summary.
Default value: generation_end
Then end of generation will be denoted with an object
with the type generation_end
.
Default value: factual_consistency_score
When the streaming event contains the factual consistency score, the
type will be factual_consistency_score
.
The probability that the summary is factually consistent with the results.
Default value: end
Then end of stream will be denoted with an object
with the type end
.
Default value: generation_info
When the streaming event contains the generation information
type will be generation_info
.
The rendered prompt sent to the LLM. Useful when creating customer prompt_template
templates.
View the actual query made to backend that was rephrased by the LLM from the input query.
Default value: error
If the stream errors, an event with type error
will
be sent.
The error messages.
{}
Chat creation request was malformed.
- application/json
- Schema
- Example (from schema)
Schema
field_errors object
The ID of the request that can be used to help Vectara support debug what went wrong.
{
"field_errors": {},
"messages": [
"string"
],
"request_id": "string"
}
Permissions do not allow creating a chat in the corpus.
- application/json
- Schema
- Example (from schema)
Schema
The messages describing why the error occurred.
The ID of the request that can be used to help Vectara support debug what went wrong.
{
"messages": [
"Internal server error."
],
"request_id": "string"
}
Corpus not found.
- application/json
- Schema
- Example (from schema)
Schema
The ID cannot be found.
ID of the request that can be used to help Vectara support debug what went wrong.
{
"id": "string",
"messages": [
"string"
],
"request_id": "string"
}
Authorization: x-api-key
name: x-api-keytype: apiKeyin: header
- curl
- python
- go
- nodejs
- ruby
- csharp
- php
- java
- powershell
- CURL
curl -L -X POST 'https://api.vectara.io/v2/chats' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'x-api-key: <API_KEY_VALUE>' \
--data-raw '{
"query": "How can I use the Vectara platform?",
"search": {
"corpora": [
{
"custom_dimensions": {},
"metadata_filter": "doc.title = '\''Charlotte'\'''\''s Web'\''",
"lexical_interpolation": 0.025,
"semantics": "default",
"corpus_key": "my-corpus"
}
],
"offset": 0,
"limit": 10,
"context_configuration": {
"characters_before": 30,
"characters_after": 30,
"sentences_before": 3,
"sentences_after": 3,
"start_tag": "<em>",
"end_tag": "</em>"
},
"reranker": {
"type": "customer_reranker",
"reranker_name": "Rerank_Multilingual_v1",
"limit": 0,
"cutoff": 0
}
},
"generation": {
"generation_preset_name": "vectara-summary-ext-v1.2.0",
"max_used_search_results": 5,
"prompt_template": "[\n {\"role\": \"system\", \"content\": \"You are a helpful search assistant.\"},\n #foreach ($qResult in $vectaraQueryResults)\n {\"role\": \"user\", \"content\": \"Given the $vectaraIdxWord[$foreach.index] search result.\"},\n {\"role\": \"assistant\", \"content\": \"${qResult.getText()}\" },\n #end\n {\"role\": \"user\", \"content\": \"Generate a summary for the query '\''${vectaraQuery}'\'' based on the above results.\"}\n]\n",
"max_response_characters": 300,
"response_language": "auto",
"model_parameters": {
"max_tokens": 0,
"temperature": 0,
"frequency_penalty": 0,
"presence_penalty": 0
},
"citations": {
"style": "none",
"url_pattern": "https://vectara.com/documents/{doc.id}",
"text_pattern": "{doc.title}"
},
"enable_factual_consistency_score": true
},
"chat": {
"store": true
},
"save_history": true,
"stream_response": false
}'