Skip to main content
Use GAIA with the official OpenAI SDK (Python or JavaScript).

Installation

    npm install openai

Configuration

Point the SDK to GAIA:
    import OpenAI from 'openai';

    const client = new OpenAI({
      baseURL: 'http://localhost:3000/api/v1',
      apiKey: 'gaia_your_api_key'
    });

Usage

Use your project ID as the model:
    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);

Streaming

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 || '');
}
Your agent automatically uses its configured knowledge, tools, and MCPs. See API Reference for all parameters.