
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Simple AI client to interface with different LLMs in a unified way.
npm install rocket-ai
# or
yarn add rocket-ai
You need to set the api keys as environment variables. Those environment variables need to be present, even if they are just an empty string:
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
GOOGLE_API_KEY=
FIREWORKS_API_KEY=
import {AiClient} from 'rocket-ai';
const aiClient = new AiClient();
// invoke
const response = await aiClient.invoke({
model: 'gpt-4o',
message: [{role: "user", content: "tell me a joke"}],
systemPrompt: 'You are a helpful assistant.',
});
// stream
const stream = await aiClient.stream({
model: 'gpt-4o',
message: [{role: "user", content: "tell me a joke"}],
systemPrompt: 'You are a helpful assistant.',
});
for await (const chunk of stream) {
console.log(response);
}
// generate image
const image = await aiClient.generateImage({
model: 'dall-e3',
prompt: 'a painting of a flower vase',
size: '1024x1024',
n: 1
})
// generate speech
const speech = await aiClient.generateSpeech({
model: 'tts-1',
text: 'Hello, how are you doing today?',
voice: 'alloy',
})
// structured output, works for stream an invoke
import {z} from 'zod';
const schema = z.object({
joke: z.string(),
})
const structuredOutput = aiClient
.withStructuredOutput(schema)
.invoke({
model: 'gpt-4o',
message: [{role: "user", content: "tell me a joke"}],
systemPrompt: 'You are a helpful assistant.',
});
To use the agent, you need to have at least one tool. Create a sample tool that fetches weather data:
//Weather API Tool
import {z} from "zod";
import {tool} from "rocket-ai"
export const weatherApi = tool(
async ({city, country}: { city: string, country?: string }): Promise<any> => {
if (!city) {
throw new Error('City is required');
}
const key = "xxxxxx";
const response = await fetch(`https://api.openweathermap.org/data/2.5/weather?q=${city},${country}&appid=${key}`)
const res = await response.json()
return JSON.stringify(res, null, 2)
},
{
name: "weatherApi",
description: "Get weather data for a city.",
queryFormat: z.object({
city: z.string(),
country: z.string(),
}),
}
)
Now you can use the agent to interact with the tool:
import {Agent} from ".rocket-ai";
import {weatherApi} from "./weather-api";
(async () => {
const systemInstruction = "You run in a loop of Thought, Action, PAUSE, Observation.\n" +
"At the end of the loop you output an Answer\n" +
"Strictly follow the provided response format.\n" +
"Use Thought to describe your thoughts about the question you have been asked.\n" +
"Use Action to run one of the actions available to you\n" +
"Observation will be the result of running those actions.\n";
const agent = new Agent(systemInstruction);
agent.registerTools([weatherApi]);
const response = await agent.executeTask("how is the weather in berlin??");
console.log(response);
})();
All models are available through the AiModelType enum:
gpt-4ogpt-4o-minidall-e3tts-1o1-previewo1-miniclaude-3-5-sonnet-latestclaude-3-5-haiku-latestgemini-2.0-flash-latestgemini-1.5-flash-latestgemini-1.5-pro-latestfw-llama-3-3fw-deepseek-v3fw-deepseek-r1note:
fw-llama-3-3,fw-deepseek-v3andfw-deepseek-r1are used from the Fireworks AI API.
MIT
FAQs
Simple AI Client that lets you access different LLMs in a unified way.
The npm package rocket-ai receives a total of 26 weekly downloads. As such, rocket-ai popularity was classified as not popular.
We found that rocket-ai demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.