ApiNinjasTriviaSkill

View as MarkdownOpen in Claude

Fetch trivia questions from the API Ninjas service with optional category filtering.

Class: ApiNinjasTriviaSkill

Tools: get_trivia

Env vars: API_NINJAS_KEY

api_key
stringRequired

API Ninjas API key. Falls back to the API_NINJAS_KEY environment variable.

default_category
string

Default trivia category if none is specified by the user. Available categories: artliterature, language, sciencenature, general, fooddrink, peopleplaces, geography, historyholidays, entertainment, toysgames, music, mathematics, religionmythology, sportsleisure.

reveal_answer
booleanDefaults to false

Whether to include the answer in the response. When false, the AI receives the answer privately so it can quiz the user.

1import { AgentBase, ApiNinjasTriviaSkill } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'assistant', route: '/assistant' });
4agent.setPromptText('You are a helpful assistant.');
5
6await agent.addSkill(new ApiNinjasTriviaSkill({
7 default_category: 'sciencenature',
8 reveal_answer: false,
9}));
10
11agent.run();