Using OpenAI SDK with GAIA
npm install openai
pip install openai
import OpenAI from 'openai'; const client = new OpenAI({ baseURL: 'http://localhost:3000/api/v1', apiKey: 'gaia_your_api_key' });
from openai import OpenAI client = OpenAI( base_url="http://localhost:3000/api/v1", api_key="gaia_your_api_key" )
const completion = await client.chat.completions.create({ model: "proj_abc123", // your GAIA project ID messages: [ { role: "user", content: "What's in my knowledge base?" } ] }); console.log(completion.choices[0].message.content);
completion = client.chat.completions.create( model="proj_abc123", messages=[ {"role": "user", "content": "What's in my knowledge base?"} ] ) print(completion.choices[0].message.content)
const stream = await client.chat.completions.create({ model: "proj_abc123", messages: [{ role: "user", content: "Hello!" }], stream: true }); for await (const chunk of stream) { process.stdout.write(chunk.choices[0]?.delta?.content || ''); }