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

openrouter/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.

OpenRouter provider module installation

The OpenRouter provider is available in the @openrouter/ai-sdk-provider module and can be installed with npm or similar package managers.

Create OpenRouter provider instance

To create an OpenRouter provider instance, import createOpenRouter from @openrouter/ai-sdk-provider and call it with an object containing apiKey property set to your OpenRouter API key.

OpenRouter API key retrieval

OpenRouter API keys can be obtained from the OpenRouter Dashboard at https://openrouter.ai/keys.

generateText with OpenRouter

Example using generateText with OpenRouter: import { createOpenRouter } from '@openrouter/ai-sdk-provider'; import { generateText } from 'ai'; const openrouter = createOpenRouter({ apiKey: 'YOU••••••EY' }); const { text } = await generateText({ model: openrouter.chat('anthropic/claude-3.5-sonnet'), prompt: 'What is OpenRouter?' }); console.log(text);

streamText with OpenRouter

Example using streamText with OpenRouter: import { createOpenRouter } from '@openrouter/ai-sdk-provider'; import { streamText } from 'ai'; const openrouter = createOpenRouter({ apiKey: 'YOU••••••EY' }); const result = streamText({ model: openrouter.chat('meta-llama/llama-3.1-405b-instruct'), prompt: 'Write a short story about AI.' }); for await (const chunk of result.textStream) { console.log(chunk); }

Give your agent this brain