Skip to main content
Back to Prompt Library
implementation

Configure AI SDK with Novita AI Endpoint

Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.

Linked challenge: Build Consumer AI Agent Session Risk Scoring with AI SDK and Novita AI

Format
Code-aware
Lines
19
Sections
3
Linked challenge
Build Consumer AI Agent Session Risk Scoring with AI SDK and Novita AI

Prompt source

Original prompt text with formatting preserved for inspection.

19 lines
3 sections
No variables
0 checklist items
import { createOpenAI } from '@ai-sdk/openai';
import { generateObject } from 'ai';
import { z } from 'z WordSchema';

const novita = createOpenAI({
  baseURL: 'https://api.novita.ai/v3/openai',
  apiKey: process.env.NOVITA_API_KEY,
});

export async function evaluateSessionRisk(sessionData: any) {
  const result = await generateObject({
    model: novita('meta-llama/llama-3.1-70b-instruct'),
    schema: z.object({
      threat_score: z.number().min(0).max(1),
      action_required: z.string(),
      is_autonomous_agent: z.boolean(),
    }),
    prompt: `Analyze behavioral session telemetry: ${JSON.stringify(sessionData)}`,
  });
  return result.object;
}

Adaptation plan

Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.

Keep stable

Hold the task contract and output shape stable so generated implementations remain comparable.

Tune next

Update libraries, interfaces, and environment assumptions to match the stack you actually run.

Verify after

Test failure handling, edge cases, and any code paths that depend on hidden context or secrets.