microsoft-foundry.rest.security.o-auth2-auth
Threads, Assistants
Get a thread
GET
/openai/v1/threads/{thread_id}
Retrieves a thread by its identifier.
路徑參數
thread_id
string
必要
The ID of the thread to retrieve.
回覆
The request has succeeded.
主體
Content-Type: application/json
id
string
必要
The identifier, which can be referenced in API endpoints.
object
enum
必要
The object type, which is always thread.
thread
created_at
integer
必要
The Unix timestamp (in seconds) for when the thread was created.
tool_resources
OpenAI.ThreadObjectToolResources | null
必要
code_interpreter
OpenAI.ThreadObjectToolResourcesCodeInterpreter
file_ids
string[]
file_search
OpenAI.ThreadObjectToolResourcesFileSearch
vector_store_ids
string[]
metadata
OpenAI.Metadata | null
必要
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
[key: string]
string
Request
curl https://api.openai.com/v1/threads/thread_abc123 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "OpenAI-Beta: assistants=v2"
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
)
thread = client.beta.threads.retrieve(
"thread_id",
)
print(thread.id)
import OpenAI from "openai";
const openai = new OpenAI();
async function main() {
const myThread = await openai.beta.threads.retrieve(
"thread_abc123"
);
console.log(myThread);
}
main();
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});
const thread = await client.beta.threads.retrieve('thread_id');
console.log(thread.id);
package main
import (
"context"
"fmt"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
thread, err := client.Beta.Threads.Get(context.TODO(), "thread_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v
", thread.ID)
}
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.Thread;
import com.openai.models.beta.threads.ThreadRetrieveParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
Thread thread = client.beta().threads().retrieve("thread_id");
}
}
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
thread = openai.beta.threads.retrieve("thread_id")
puts(thread)
回應
{
"id": "thread_abc123",
"object": "thread",
"created_at": 1699014083,
"metadata": {},
"tool_resources": {
"code_interpreter": {
"file_ids": []
}
}
}