new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

AI SDK · Providers · all subjects

nia/setup

5 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Nia SDK package name

The Nia adapter for the AI SDK is provided by the `@nozomioai/nia-ai-sdk` package, available on npm.

Nia API key environment variable

Set the Nia API key via the environment variable `NIA_API_KEY` with the format `nia_your_api_key`. The API key can be obtained from the Nia dashboard at https://www.trynia.ai/.

Nia tool usage example with generateText

This example shows how to use Nia research tools with generateText from the AI SDK, integrating with OpenAI's gpt-4.1 model. The tools are created with createNiaResearchTools and configured with tracer, oracle, and documentAgent services, each with their own defaultRequest settings. The tools are passed to generateText along with the model and prompt: ```ts import { generateText } from 'ai'; import { openai } from '@ai-sdk/openai'; import { createNiaResearchTools } from '@nozomioai/nia-ai-sdk'; const tools = createNiaResearchTools({ apiKey: process.env.NIA_API_KEY!, tracer: { defaultRequest: { mode: 'tracer-deep', }, }, oracle: { defaultRequest: { repositories: ['vercel/ai'], dataSources: ['Vercel AI SDK'], }, }, documentAgent: { defaultRequest: { sourceId: 'src_abc123', }, }, }); const result = await generateText({ model: openai('gpt-4.1'), prompt: 'Research how AI SDK middleware works, then summarize the best integration pattern.', tools, }); console.log(result.text); ```

Nia middleware usage example with withOracleContext

This example shows how to use Nia middleware with withOracleContext to wrap an OpenAI model, enriching the last user message with Oracle context before the model runs: ```ts import { generateText } from 'ai'; import { openai } from '@ai-sdk/openai'; import { withOracleContext } from '@nozomioai/nia-ai-sdk'; const model = withOracleContext(openai('gpt-4.1'), { apiKey: process.env.NIA_API_KEY!, defaultRequest: { repositories: ['vercel/ai'], dataSources: ['Vercel AI SDK'], }, }); const result = await generateText({ model, prompt: 'How should I think about AI SDK middleware for retrieval?', }); console.log(result.text); ```

Nia direct streaming example with streamTracer

This example shows how to use the direct streaming helper streamTracer to consume raw Nia job events: ```ts import { streamTracer } from '@nozomioai/nia-ai-sdk'; const session = await streamTracer( { apiKey: process.env.NIA_API_KEY!, }, { query: 'How does generateText stream responses?', repositories: ['vercel/ai'], mode: 'tracer-fast', }, ); for await (const event of session.events) { console.log(event.event, event.data); } ```

Give your agent this brain