1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21import OpenAI from "openai";
const client = new OpenAI({
timeout: 15 * 1000 * 60,
});
const response = await client.chat.completions.create(
{
model: "gpt-6-astra",
messages: [
{
role: "developer",
content: "List and describe all the metaphors used in this book.",
},
{ role: "user", content: "<very long text of book here>" },
],
service_tier: "flex",
},
{ timeout: 15 * 1000 * 60 }
);
console.log(response.choices[0].message.content);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18from openai import OpenAI
client = OpenAI(timeout=900.0)
response = client.chat.completions.create(
model="gpt-6-astra",
messages=[
{
"role": "developer",
"content": "List and describe all the metaphors used in this book.",
},
{"role": "user", "content": "<very long text of book here>"},
],
service_tier="flex",
timeout=900.0,
)
print(response.choices[0].message.content)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26package main
import (
"context"
"fmt"
"time"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/option"
)
func main() {
client := openai.NewClient(option.WithRequestTimeout(15 * time.Minute))
completion, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
Model: "gpt-6-astra",
ServiceTier: openai.ChatCompletionNewParamsServiceTierFlex,
Messages: []openai.ChatCompletionMessageParamUnion{
openai.DeveloperMessage("List and describe all the metaphors used in this book."),
openai.UserMessage("<very long text of book here>"),
},
})
if err != nil {
panic(err)
}
fmt.Println(completion.Choices[0].Message.Content)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.chat.completions.ChatCompletionCreateParams;
import java.time.Duration;
client = client.withOptions(options -> options.timeout(Duration.ofMinutes(15)));
ChatCompletionCreateParams params =
ChatCompletionCreateParams.builder()
.model("gpt-6-astra")
.addDeveloperMessage("List and describe all the metaphors used in this book.")
.addUserMessage("<very long text of book here>")
.serviceTier(ChatCompletionCreateParams.ServiceTier.FLEX)
.build();
client.chat().completions().create(params).choices().stream()
.flatMap(choice -> choice.message().content().stream())
.forEach(System.out::println);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22using System.ClientModel;
using OpenAI;
using OpenAI.Chat;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
string model = "gpt-6-astra";
OpenAIClientOptions clientOptions = new() { NetworkTimeout = TimeSpan.FromMinutes(15) };
ChatClient client = new(model, new ApiKeyCredential(key), clientOptions);
ChatCompletionOptions options = new() { ServiceTier = ChatServiceTier.Flex };
using CancellationTokenSource timeout = new(TimeSpan.FromMinutes(15));
ChatCompletion completion = await client.CompleteChatAsync(
[
new DeveloperChatMessage("List and describe all the metaphors used in this book."),
new UserChatMessage("<very long text of book here>"),
],
options,
timeout.Token
);
Console.WriteLine(completion.Content[0].Text);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20require "openai"
client = OpenAI::Client.new(timeout: 900.0)
completion = client.chat.completions.create(
model: "gpt-6-astra",
service_tier: :flex,
messages: [
{
role: :developer,
content: "List and describe all the metaphors used in this book."
},
{
role: :user,
content: "<very long text of book here>"
}
]
)
puts(completion.choices.fetch(0).message.content)
1
2
3
4
5
6
7
8curl https://api.openai.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY" -d '{
"model": "gpt-6-astra",
"messages": [
{"role": "developer", "content": "List and describe all the metaphors used in this book."},
{"role": "user", "content": "<very long text of book here>"}
],
"service_tier": "flex"
}' --max-time 900