
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@embedapi/core
Advanced tools
A general-purpose embedding solution for APIs, providing tools for easy integration of AI models.
EmbedAPIClient is a Node.js client library that interacts with the EmbedAPI service. It provides methods to generate AI responses, list available models, and test API connectivity. This library makes it easy to interact with the EmbedAPI for various AI services, such as OpenAI, Anthropic, VertexAI, and others.
To install the EmbedAPIClient in your project, use the following command:
npm install @embedapi/core
You can import the EmbedAPIClient class using CommonJS syntax:
const EmbedAPIClient = require('@embedapi/core');
To initialize the client, you need to provide your API key. The API key is required to authenticate requests to the EmbedAPI service.
const apiKey = 'your-api-key-here';
const client = new EmbedAPIClient(apiKey);
generate({ service, model, messages, ...options })Generates text using the specified AI service and model.
Parameters:
service (string): The name of the AI service (e.g., 'openai').model (string): The model to use (e.g., 'gpt-4').messages (array): An array of message objects containing conversation history.maxTokens (number, optional): The maximum number of tokens to generate.temperature (number, optional): Sampling temperature.topP (number, optional): Top-p sampling parameter.frequencyPenalty (number, optional): Frequency penalty parameter.presencePenalty (number, optional): Presence penalty parameter.stopSequences (array, optional): Stop sequences for controlling response generation.Usage Example:
const response = await client.generate({
service: 'openai',
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello' }],
maxTokens: 150,
temperature: 0.7
});
console.log(response);
listModels()Lists all available models for the specified service.
const models = await client.listModels();
console.log(models);
testAPIConnection()Tests the connection to the API to verify that the API key is valid.
const isConnected = await client.testAPIConnection();
console.log('API Connection Successful:', isConnected);
The client methods throw errors if the API request fails. Make sure to use try...catch blocks when calling these methods to handle potential errors gracefully.
try {
const response = await client.generate({
service: 'openai',
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello' }]
});
console.log(response);
} catch (error) {
console.error('Error generating text:', error);
}
The base URL for all API requests is:
https://embedapi.com/api/v1
POST /generate: Generates AI responses based on the provided input.GET /models: Lists all available models.GET /test: Tests the API connection.Here is a quick example of using EmbedAPIClient in a Node.js project:
const EmbedAPIClient = require('@embedapi/core');
const apiKey = 'your-api-key-here';
const client = new EmbedAPIClient(apiKey);
async function main() {
try {
// Test API connection
const isConnected = await client.testAPIConnection();
console.log('API Connection Successful:', isConnected);
// List available models
const models = await client.listModels();
console.log('Available Models:', models);
// Generate text
const response = await client.generate({
service: 'openai',
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello' }],
maxTokens: 100
});
console.log('Generated Response:', response);
} catch (error) {
console.error('An error occurred:', error);
}
}
main();
We welcome contributions! Please feel free to submit a pull request or open an issue if you find a bug or have suggestions for improvements.
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
🔥 ONE API KEY TO RULE THEM ALL! Access ANY AI model instantly through our game-changing unified API. Build AI apps in minutes, not months! The ultimate all-in-one AI agent solution you've been waiting for! 🚀
The npm package @embedapi/core receives a total of 3 weekly downloads. As such, @embedapi/core popularity was classified as not popular.
We found that @embedapi/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.