Conversations
List conversation items
Returns the items belonging to the specified conversation.
Parametry cesty
conversation_id
string
vyžadováno
The id of the conversation on which the items needs to be listed.
Parametry dotazů
limit
integer
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
order
enum
Sort order by the created_at timestamp of the objects. asc for ascending order anddesc
for descending order.
after
string
A cursor for use in pagination. after is an object ID that defines your place in the list.
For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
subsequent call can include after=obj_foo in order to fetch the next page of the list.
before
string
A cursor for use in pagination. before is an object ID that defines your place in the list.
For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
subsequent call can include before=obj_foo in order to fetch the previous page of the list.
item_type
string | enum
Filter by item type. If provided, only items of the specified type will be returned.
enum
Parametry záhlaví
x-ms-user-identity
string
Opaque per-user identity string used to scope endpoint-scoped data to a specific end user. The caller must have the agents/endpoints/UserIdentityImpersonation/action RBAC permission.
Odpovědi
The request has succeeded.
Text
data
OpenAI.OutputItem[]
vyžadováno
The requested list of items.
first_id
string
The first ID represented in this list.
last_id
string
The last ID represented in this list.
has_more
boolean
vyžadováno
A value indicating whether there are additional values available not captured in this list.
Žádost
curl "https://api.openai.com/v1/conversations/conv_123/items?limit=10" \
-H "Authorization: Bearer $OPENAI_API_KEY"
import OpenAI from "openai";
const client = new OpenAI();
const items = await client.conversations.items.list("conv_123", { limit: 10 });
console.log(items.data);
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
)
page = client.conversations.items.list(
conversation_id="conv_123",
)
page = page.data[0]
print(page)
using System;
using OpenAI.Conversations;
OpenAIConversationClient client = new(
apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
);
ConversationItemList items = client.ConversationItems.List(
conversationId: "conv_123",
new ListConversationItemsOptions { Limit = 10 }
);
Console.WriteLine(items.Data.Count);
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});
// Automatically fetches more pages as needed.
for await (const conversationItem of client.conversations.items.list('conv_123')) {
console.log(conversationItem);
}
package main
import (
"context"
"fmt"
"github.com/openai/openai-go"
"github.com/openai/openai-go/conversations"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
page, err := client.Conversations.Items.List(
context.TODO(),
"conv_123",
conversations.ItemListParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v
", page)
}
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.conversations.items.ItemListPage;
import com.openai.models.conversations.items.ItemListParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ItemListPage page = client.conversations().items().list("conv_123");
}
}
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
page = openai.conversations.items.list("conv_123")
puts(page)
Response
{
"object": "list",
"data": [
{
"type": "message",
"id": "msg_abc",
"status": "completed",
"role": "user",
"content": [
{"type": "input_text", "text": "Hello!"}
]
}
],
"first_id": "msg_abc",
"last_id": "msg_abc",
"has_more": false
}