Skip to content

Instantly share code, notes, and snippets.

View yash98's full-sized avatar

Yash Malviya yash98

View GitHub Profile
@yash98
yash98 / openrouter_dspy.py
Last active June 16, 2025 18:58
How to use Open Router ( openrouter.ai ) with DSPy
import requests
from os import getenv
from dsp import LM
from ratelimit import limits
RL_CALLS=40
RL_PERIOD_SECONDS=60
class OpenRouterClient(LM):
def __init__(self, api_key=None, base_url="https://openrouter.ai/api/v1", model="meta-llama/llama-3-8b-instruct:free", extra_headers=None, **kwargs):