Meta (Llama)
Use Meta’s Llama models via the official Llama API. Access Llama 3.3, Llama 4 Scout, Llama 4 Maverick, and more through Meta’s hosted inference endpoint.
The Llama API exposes an OpenAI-compatible interface.
Setup
Factory
import { meta } from "@radaros/core";
const model = meta("Llama-4-Scout-17B-16E-Instruct");
Model ID (e.g., "Llama-3.3-70B-Instruct", "Llama-4-Scout-17B-16E-Instruct", "Llama-4-Maverick-17B-128E-Instruct-FP8").
Optional { apiKey?, baseURL? }.
Supported Models
| Model | Description | Best For |
|---|
Llama-4-Maverick-17B-128E-Instruct-FP8 | Latest flagship, 128 experts MoE | Maximum capability |
Llama-4-Scout-17B-16E-Instruct | Latest scout model, 16 experts | Great balance of speed and quality |
Llama-3.3-70B-Instruct | Proven large model | Complex reasoning, tool calling |
Llama-3.1-8B-Instruct | Fast, efficient | Simple tasks, high throughput |
See the full list at llama.developer.meta.com/docs/models.
Basic Example
import { Agent, meta } from "@radaros/core";
const agent = new Agent({
name: "llama-agent",
model: meta("Llama-4-Scout-17B-16E-Instruct"),
instructions: "You are a helpful, harmless, and honest assistant.",
});
const result = await agent.run("Explain the difference between TCP and UDP.");
console.log(result.text);
Llama 3.1+ and Llama 4 models support function calling:
import { Agent, meta, defineTool } from "@radaros/core";
import { z } from "zod";
const agent = new Agent({
name: "tool-agent",
model: meta("Llama-3.3-70B-Instruct"),
tools: [
defineTool({
name: "calculate",
description: "Evaluate a math expression",
parameters: z.object({ expression: z.string() }),
execute: async ({ expression }) => {
try { return String(Function(`return ${expression}`)()); }
catch { return "Error evaluating expression"; }
},
}),
],
});
const result = await agent.run("What is 2^16 + 3^10?");
console.log(result.text);
Multi-Modal (Llama 4)
Llama 4 models support image input:
import { Agent, meta, type ContentPart } from "@radaros/core";
import { readFileSync } from "node:fs";
const agent = new Agent({
name: "vision-agent",
model: meta("Llama-4-Scout-17B-16E-Instruct"),
instructions: "Analyze images carefully.",
});
const imageData = readFileSync("photo.jpg").toString("base64");
const result = await agent.run([
{ type: "text", text: "Describe this image in detail." },
{ type: "image", data: imageData, mimeType: "image/jpeg" },
] as ContentPart[]);
console.log(result.text);
Full Example
import { Agent, meta, CostTracker, defineTool } from "@radaros/core";
import { z } from "zod";
const costTracker = new CostTracker({
pricing: {
"Llama-3.3-70B-Instruct": { promptPer1k: 0.00099, completionPer1k: 0.00099 },
"Llama-4-Scout-17B-16E-Instruct": { promptPer1k: 0.00015, completionPer1k: 0.0006 },
},
});
const agent = new Agent({
name: "coding-assistant",
model: meta("Llama-3.3-70B-Instruct"),
instructions: "You are a senior software engineer. Help with code reviews and architecture.",
tools: [
defineTool({
name: "readFile",
description: "Read a file's contents",
parameters: z.object({ path: z.string() }),
execute: async ({ path }) => `// ${path}\nexport function main() { console.log("hello"); }`,
}),
],
costTracker,
});
const result = await agent.run("Review the main function in index.ts");
console.log(result.text);
console.log(`Cost: $${costTracker.getSummary().totalCost.toFixed(6)}`);
Running Llama Locally
You can also run Llama models locally via Ollama:
import { ollama } from "@radaros/core";
const model = ollama("llama3.1:70b");
See Ollama for local setup instructions.
Environment Variables
| Variable | Description |
|---|
LLAMA_API_KEY | Llama API key |
Cross-References