openrouter-examples  by OpenRouterTeam

API integration examples for LLMs

Created 2 years ago
269 stars

Top 95.6% on SourcePulse

GitHubView on GitHub
Project Summary

Provides tested, executable examples for integrating the OpenRouter API across various ecosystems, enabling developers to quickly adopt and utilize the service. The repository serves as a practical resource for understanding and implementing OpenRouter features with minimal friction.

How It Works

This project offers a curated collection of examples structured into distinct ecosystems: shell scripts using curl and jq, and a TypeScript monorepo managed with Bun workspaces. The TypeScript examples cover raw fetch, Vercel AI SDK v5, and Effect-TS integrations, sharing common constants and types from a centralized typescript/shared directory for consistency and type safety.

Quick Start & Requirements

Set your API key: export OPENROUTER_API_KEY="your-key-here". Install Bun runtime (curl -fsSL https://bun.sh/install | bash). For curl examples, install jq. Install TypeScript dependencies via make install or cd typescript && bun install. Run all examples with make examples, or specific ecosystems with make curl or make typescript. Individual TypeScript examples can be run from their respective directories (e.g., cd typescript/fetch && bun examples). API keys are available at https://openrouter.ai/keys.

Highlighted Details

  • Copy-paste ready and tested examples verified to work.
  • Demonstrates integration across multiple ecosystems (shell, various TypeScript frameworks).
  • Type-safe TypeScript examples leverage a monorepo structure for maintainability.
  • Includes documentation for specific features like prompt caching.

Maintenance & Community

Contribution guidelines are provided within ecosystem-specific READMEs. No specific details on core maintainers, community channels, or roadmap are present in the main README.

Licensing & Compatibility

The project is distributed under the license specified in LICENSE.md. Compatibility for commercial use depends on the terms of that license.

Limitations & Caveats

Examples for the official openrouter-sdk/ within the TypeScript monorepo are explicitly marked as a TODO and are not yet implemented.

Health Check
Last Commit

3 weeks ago

Responsiveness

Inactive

Pull Requests (30d)
1
Issues (30d)
1
Star History
15 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Ishaan Jaffer Ishaan Jaffer(Cofounder of LiteLLM), and
10 more.

llama-stack by llamastack

0.2%
8k
Composable building blocks for Llama apps
Created 1 year ago
Updated 2 days ago
Feedback? Help us improve.