
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.
llm-gateway
Advanced tools
LLM Gateway for Python: https://pypi.org/project/open-llm-gateway/ https://github.com/ottic-ai/llm-gateway-python
The LLM Gateway is a lightweight, open-source library built for fast and reliable connections to LLMs.
It simplifies integrations with multiple providers, offering fallbacks, caching, and minimal latency with a client-side solution.
openAI/AnthropicOutput:{...}
llmGatewayOutput: {
type: 'text' | 'tool_calls';
content?: string; - content for text output
tool_name?: string; - name of the tool for tool_calls
arguments?: string; - arguments for the tool.
}[]
}
Contribute, fork, or raise issues— so we can make it better together.
Starring this repo helps other developers discover the LLM Gateway! ⭐
To install the library, use npm or yarn:
npm install llm-gateway
or
yarn add llm-gateway
Check examples in examples folder.
Here's a basic example of how to use the LLM Gateway library:
import { LLMGateway, EnumLlmModelType } from 'llm-gateway';
const openAIGateway = new LLMGateway({
provider: EnumLLMProvider.OPENAI, // or ANTHROPIC, AZUREOPENAI, OPENAI
apiKey: process.env['OPENAI_API_KEY'],
});
const openAIresponse = await openAIGateway.chatCompletion({
messages: [
{ role: 'user', content: 'Write a one sentence story about a cat.' }
],
model: 'gpt-4o-mini',
max_completion_tokens:200
})
console.log('Response:', openAIresponse);
The LLM Gateway library supports configuring fallbacks to ensure that if one model fails, another can be used as a backup. This is useful for maintaining service availability and reliability.
import {LLMGateway, EnumLLMProvider} from 'llm-gateway';
const llmGateway = new LLMGateway({
provider: EnumLLMProvider.OPENAI, // or ANTHROPIC, AZUREOPENAI
apiKey: 'INCORRECT_API_KEY_TO_EMULATE_FAILURE',
}, {
fallbacks: {
fallbackModel: 'claude-3-5-sonnet-latest',
fallbackProvider: {
apiKey: process.env['ANTHROPIC_API_KEY'],
provider: EnumLLMProvider.ANTHROPIC
}
}
});
const response = await llmGateway.chatCompletion({
messages: [
{ role: 'user', content: 'Write a one sentence story about a cat.' }
],
model: 'gpt-4o-mini',
})
console.log('Response:', JSON.stringify(response.llmGatewayOutput, null ,2));
All examples work consistently across different providers (OpenAI, Anthropic, Azure) and automatically handle format conversion when falling back to a different provider.
The LLM Gateway supports streaming responses from all providers, with a unified interface that works consistently across OpenAI, Anthropic, and Azure.
const openAIGateway = new LLMGateway({
provider: EnumLLMProvider.OPENAI, // or ANTHROPIC, AZUREOPENAI
apiKey: process.env['OPENAI_API_KEY'],
});
const openAIStream = await openAIGateway.chatCompletionStream({
messages: [{ role: 'user', content: 'Write a one sentence story about a cat.' }],
model: 'gpt-4o-mini',
temperature: 0.7,
});
for await (const chunk of openAIStream) {
if(chunk.choices[0].finish_reason === 'stop') {
console.log('message_stop');
} else {
console.log(chunk.choices[0].delta.content);
}
}
OPENAI, ANTHROPIC, AZUREOPENAI).Contributions are welcome! Please feel free to submit a pull request or open an issue.
This project is licensed under the MIT License.
FAQs
LLM Gateway with direct request to provider
We found that llm-gateway 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
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.