Integra facilmente l'IA nella tua app Compatibilità diretta con qualsiasi client OpenAI
Punta qualsiasi libreria compatibile con OpenAI all'URL base di Nebux con la tua chiave API, senza riscrivere codice.
1import OpenAI from "openai";23const client = new OpenAI({4 apiKey: "your-api-key",5 baseURL: "https://api.nebux.cloud/v1",6});
Decidi tu cosa ricorda il modello
Ogni richiesta è indipendente: il modello conosce solo i messaggi che ci metti dentro. Per portare avanti una conversazione, invia la cronologia insieme al nuovo messaggio e scegli quale modello risponde.
7const completion = await client.chat.completions.create({8 model: "qwen3-14b",9 messages: [10 { role: "system", content: "You are a helpful assistant." },11 { role: "user", content: "Recommend me a book" },12 { role: "assistant", content: "Try The Shadow of the Wind" },13 { role: "user", content: "And a similar one?" },14 ],15});1617console.log(completion.choices[0].message.content);
Streaming in tempo reale
Mostra la risposta mentre viene scritta, token dopo token. Oppure, se preferisci, ricevila intera in una volta sola.
7const stream = await client.chat.completions.create({8 model: "qwen3-14b",9 messages: [{ role: "user", content: "Which running shoes do you recommend?" }],10 stream: true,11});1213for await (const chunk of stream) {14 process.stdout.write(chunk.choices[0]?.delta?.content ?? "");15}
Output JSON garantito
Forza la risposta in un JSON valido secondo il tuo schema.
{
"good": [{ "id": 1, "comment": "Fantastico!" }, { "id": 3, "comment": "Bene" }],
"bad": [{ "id": 2, "comment": "Pessimo" }, { "id": 4, "comment": "Lento" }]
}7const completion = await client.chat.completions.create({8 model: "qwen3-14b",9 messages: [10 { role: "system", content: "Classify each comment as good or bad, keeping its id. Reply as JSON." },11 { role: "user", content: "1: Great! 2: Awful 3: Good 4: Slow" },12 ],13 response_format: { type: "json_object" },14});1516console.log(JSON.parse(completion.choices[0].message.content));
Ragionamento, solo quando ti serve
Lascia che il modello pensi prima di rispondere nei compiti più difficili. Il ragionamento arriva separato dalla risposta, così puoi mostrarlo, salvarlo o ignorarlo, e lo paghi solo nelle richieste in cui lo attivi.
7const res = await client.chat.completions.create({8 model: "qwen3-14b",9 messages: [10 { role: "user", content: "A coffee is 1.20. What are 7 with 15% off?" },11 ],12 // chat_template_kwargs is outside the OpenAI library's types,13 // so it travels as an extra request parameter.14 // The other option is calling POST https://api.nebux.cloud/v1/chat/completions15 // directly.16 // @ts-expect-error17 chat_template_kwargs: {"enable_thinking": true},18});1920console.log(res.choices[0].message.content);
Decidi tu come risponde
Temperatura, top-p, token massimi, penalità e sequenze di stop. La stessa domanda, con il tono e la lunghezza che vuoi.
7const res = await client.chat.completions.create({8 model: "qwen3-14b",9 messages: [10 { role: "user", content: "Describe the product in one line" },11 ],12 temperature: 0.7,13 max_tokens: 1024,14 top_p: 0.95,15 frequency_penalty: 0.4,16 stop: ["\n\n"],17});1819console.log(res.choices[0].message.content);
Risultati ripetibili
Fissa un seed e porta la temperatura a zero per ottenere risposte coerenti da un'esecuzione all'altra. Ideale per classificare, estrarre dati o fare test senza sorprese.
7const res = await client.chat.completions.create({8 model: "qwen3-14b",9 messages: [10 { role: "user", content: "Classify this review" },11 ],12 temperature: 0,13 seed: 42,14});1516console.log(res.choices[0].message.content);
Chiamate di funzione
Il modello chiama i tuoi strumenti e le tue funzioni quando serve, per rispondere con i dati che restituiscono.
7const completion = await client.chat.completions.create({8 model: "qwen3-14b",9 messages: [{ role: "user", content: "What's the weather in València?" }],10 tools: [11 {12 type: "function",13 function: {14 name: "get_weather",15 description: "Get the current weather for a location",16 parameters: {17 type: "object",18 properties: { location: { type: "string" } },19 required: ["location"],20 },21 },22 },23 ],24});2526console.log(completion.choices[0].message.tool_calls);
1import OpenAI from "openai";23const client = new OpenAI({4 apiKey: "your-api-key",5 baseURL: "https://api.nebux.cloud/v1",6});
Prova e regola prima di scrivere codice
Copia il codice pronto all'uso in uno qualsiasi dei linguaggi che documentiamo e inizia a costruire.
Apri il playgroundTutta l'API, documentata
Ogni parametro dell'endpoint, con esempi: streaming, JSON garantito, chiamate di funzione e come gestire gli errori.
DocumentazioneVuoi provare Inferenza IA?
Oppure lascialo gestire a noi
Preferisci concentrarti sul tuo prodotto? Manteniamo e facciamo evolvere i tuoi sistemi come un team in più della tua azienda.
Scopri di più sul cloud gestito