
BotHub: Experimente grátis!bot
Exemplo de código e API para gpt-4.5-previewOferecemos acesso completo à API OpenAI através do nosso serviço. Todos os nossos endpoints estão totalmente em conformidade com os endpoints OpenAI e podem ser usados tanto com plugins quanto ao desenvolver seu próprio software através do SDK.Criar chave API
import OpenAI from 'openai';
const openai = new OpenAI({
apiKey: '<your bothub access token>',
baseURL: 'https://bothub.chat/api/v2/openai/v1'
});
// Sync - Text generation
async function main() {
const chatCompletion = await openai.chat.completions.create({
messages: [{ role: 'user', content: 'Say this is a test' }],
model: 'gpt-4.5-preview',
});
}
// Async - Text generation
async function main() {
const stream = await openai.chat.completions.create({
messages: [{ role: 'user', content: 'Say this is a test' }],
model: 'gpt-4.5-preview',
stream: true
});
for await (const chunk of stream) {
const part: string | null = chunk.choices[0].delta?.content ?? null;
}
}
main();
Como funciona gpt-4.5-preview?
Os bothubs coletam informações...