# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
response = pc.assistants.chat(
assistant_name="example-assistant",
messages=[{"role": "user", "content": "What is the inciting incident of Pride and Prejudice?"}],
model="gpt-4o",
)
print(response.message.content)
# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
stream = pc.assistants.chat(
assistant_name="example-assistant",
messages=[{"role": "user", "content": "What is the inciting incident of Pride and Prejudice?"}],
model="gpt-4o",
stream=True,
)
for fragment in stream.text():
print(fragment, end="", flush=True)
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
// Reads PINECONE_API_KEY from the environment
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'example-assistant' });
const response = await assistant.chat({
messages: [{ role: 'user', content: 'What is the inciting incident of Pride and Prejudice?' }],
model: 'gpt-4o',
});
console.log(response.message?.content);
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
// Reads PINECONE_API_KEY from the environment
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'example-assistant' });
const stream = await assistant.chatStream({
messages: [{ role: 'user', content: 'What is the inciting incident of Pride and Prejudice?' }],
model: 'gpt-4o',
});
for await (const chunk of stream) {
if (chunk.type === 'content_chunk') {
process.stdout.write(chunk.delta.content);
}
}
PINECONE_API_KEY="YOUR_API_KEY"
ASSISTANT_NAME="example-assistant"
curl "https://prod-1-data.ke.pinecone.io/assistant/chat/$ASSISTANT_NAME" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"role": "user",
"content": "What is the inciting incident of Pride and Prejudice?"
}
],
"stream": false,
"model": "gpt-4o"
}'
PINECONE_API_KEY="YOUR_API_KEY"
ASSISTANT_NAME="example-assistant"
curl "https://prod-1-data.ke.pinecone.io/assistant/chat/$ASSISTANT_NAME" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Pinecone-Api-Version: 2026-07" \
-d '{
"messages": [
{
"role": "user",
"content": "What is the inciting incident of Pride and Prejudice?"
}
],
"stream": true,
"model": "gpt-4o"
}'
{
"id": "<string>",
"finish_reason": "<string>",
"message": {
"role": "<string>",
"content": "<string>"
},
"model": "<string>",
"citations": [
{
"position": 123,
"references": [
{
"file": {
"name": "<string>",
"id": "<string>",
"size": 1048576,
"metadata": {
"created_by": "Jane Doe",
"published": "2025-10-01T00:00:00.000Z",
"tags": [
"report",
"Q4",
"analytics"
]
},
"created_on": "2025-10-01T12:30:00.000Z",
"updated_on": "2025-10-01T12:45:00.000Z",
"status": "<string>",
"signed_url": "https://storage.googleapis.com/bucket/file.pdf?...",
"multimodal": true
},
"pages": [
123
],
"highlight": {
"type": "<string>",
"content": "<string>"
}
}
]
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
},
"context_snippet_count": 123,
"content_filter_results": {
"spec": "<string>",
"results": "<unknown>"
}
}Chat with an assistant
Chat with an assistant and get back citations in structured form.
This is the recommended way to chat with an assistant, as it offers more functionality and control over the assistant’s responses and references than the OpenAI-compatible chat interface.
For guidance and examples, see Chat with an assistant.
# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
response = pc.assistants.chat(
assistant_name="example-assistant",
messages=[{"role": "user", "content": "What is the inciting incident of Pride and Prejudice?"}],
model="gpt-4o",
)
print(response.message.content)
# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
stream = pc.assistants.chat(
assistant_name="example-assistant",
messages=[{"role": "user", "content": "What is the inciting incident of Pride and Prejudice?"}],
model="gpt-4o",
stream=True,
)
for fragment in stream.text():
print(fragment, end="", flush=True)
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
// Reads PINECONE_API_KEY from the environment
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'example-assistant' });
const response = await assistant.chat({
messages: [{ role: 'user', content: 'What is the inciting incident of Pride and Prejudice?' }],
model: 'gpt-4o',
});
console.log(response.message?.content);
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
// Reads PINECONE_API_KEY from the environment
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'example-assistant' });
const stream = await assistant.chatStream({
messages: [{ role: 'user', content: 'What is the inciting incident of Pride and Prejudice?' }],
model: 'gpt-4o',
});
for await (const chunk of stream) {
if (chunk.type === 'content_chunk') {
process.stdout.write(chunk.delta.content);
}
}
PINECONE_API_KEY="YOUR_API_KEY"
ASSISTANT_NAME="example-assistant"
curl "https://prod-1-data.ke.pinecone.io/assistant/chat/$ASSISTANT_NAME" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"role": "user",
"content": "What is the inciting incident of Pride and Prejudice?"
}
],
"stream": false,
"model": "gpt-4o"
}'
PINECONE_API_KEY="YOUR_API_KEY"
ASSISTANT_NAME="example-assistant"
curl "https://prod-1-data.ke.pinecone.io/assistant/chat/$ASSISTANT_NAME" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Pinecone-Api-Version: 2026-07" \
-d '{
"messages": [
{
"role": "user",
"content": "What is the inciting incident of Pride and Prejudice?"
}
],
"stream": true,
"model": "gpt-4o"
}'
{
"id": "<string>",
"finish_reason": "<string>",
"message": {
"role": "<string>",
"content": "<string>"
},
"model": "<string>",
"citations": [
{
"position": 123,
"references": [
{
"file": {
"name": "<string>",
"id": "<string>",
"size": 1048576,
"metadata": {
"created_by": "Jane Doe",
"published": "2025-10-01T00:00:00.000Z",
"tags": [
"report",
"Q4",
"analytics"
]
},
"created_on": "2025-10-01T12:30:00.000Z",
"updated_on": "2025-10-01T12:45:00.000Z",
"status": "<string>",
"signed_url": "https://storage.googleapis.com/bucket/file.pdf?...",
"multimodal": true
},
"pages": [
123
],
"highlight": {
"type": "<string>",
"content": "<string>"
}
}
]
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
},
"context_snippet_count": 123,
"content_filter_results": {
"spec": "<string>",
"results": "<unknown>"
}
}# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
response = pc.assistants.chat(
assistant_name="example-assistant",
messages=[{"role": "user", "content": "What is the inciting incident of Pride and Prejudice?"}],
model="gpt-4o",
)
print(response.message.content)
# pip install --upgrade pinecone
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
stream = pc.assistants.chat(
assistant_name="example-assistant",
messages=[{"role": "user", "content": "What is the inciting incident of Pride and Prejudice?"}],
model="gpt-4o",
stream=True,
)
for fragment in stream.text():
print(fragment, end="", flush=True)
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
// Reads PINECONE_API_KEY from the environment
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'example-assistant' });
const response = await assistant.chat({
messages: [{ role: 'user', content: 'What is the inciting incident of Pride and Prejudice?' }],
model: 'gpt-4o',
});
console.log(response.message?.content);
// npm install @pinecone-database/pinecone
import { Pinecone } from '@pinecone-database/pinecone';
// Reads PINECONE_API_KEY from the environment
const pc = new Pinecone();
const assistant = pc.assistant({ name: 'example-assistant' });
const stream = await assistant.chatStream({
messages: [{ role: 'user', content: 'What is the inciting incident of Pride and Prejudice?' }],
model: 'gpt-4o',
});
for await (const chunk of stream) {
if (chunk.type === 'content_chunk') {
process.stdout.write(chunk.delta.content);
}
}
PINECONE_API_KEY="YOUR_API_KEY"
ASSISTANT_NAME="example-assistant"
curl "https://prod-1-data.ke.pinecone.io/assistant/chat/$ASSISTANT_NAME" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"role": "user",
"content": "What is the inciting incident of Pride and Prejudice?"
}
],
"stream": false,
"model": "gpt-4o"
}'
PINECONE_API_KEY="YOUR_API_KEY"
ASSISTANT_NAME="example-assistant"
curl "https://prod-1-data.ke.pinecone.io/assistant/chat/$ASSISTANT_NAME" \
-H "Api-Key: $PINECONE_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Pinecone-Api-Version: 2026-07" \
-d '{
"messages": [
{
"role": "user",
"content": "What is the inciting incident of Pride and Prejudice?"
}
],
"stream": true,
"model": "gpt-4o"
}'
Body
The desired configuration to chat with an assistant.
Represents a request to chat with an assistant.
Response
Search request successful.
Describes the response format of a chat request.
Indicates why the chat response generation stopped. This signals the end of the response.
-
stop: The model finished generating the response. -
length: Generation was cut off because the maximum number of tokens allowed was reached. -
content_filter: Generation stopped because content was blocked by content filtering rules. (for example, content that contains hate speech or violent material). -
tool_calls: Generation stopped because a tool call was triggered.
Content filter results provided by the LLM, describing safety-related classifications applied to the content. The structure may vary depending on the model and the content being filtered. The spec field identifies the provider, and determines the structure of results.
Show child attributes
Show child attributes
Was this page helpful?