Skip to main content

A lightweight OpenRouter client with Supabase-based remote API key storage.

Project description

Magic Answer

A lightweight Python library for querying OpenRouter LLMs using API keys stored in a Supabase key-value database.

Instead of embedding an OpenRouter API key into your application, Magic Answer retrieves it from a Supabase key-value store at runtime using a lookup key. This allows API keys to be updated or rotated without modifying or redistributing client applications.

Features

  • Query any model available through OpenRouter
  • Automatic fallback between multiple models
  • Retrieve OpenRouter API keys from a Supabase key-value store
  • Exceptionally simple Python API
  • Optional clipboard integration
  • Built-in key manager for maintaining the Supabase database
  • Easily customizable through configuration

Installation

pip install magic-answer

Quick Start

Query using console input:

import magic_answer

magic_answer.ask("your_lookup_key")

Or use the clipboard:

import magic_answer

magic_answer.ask_clipboard("your_lookup_key")

Managing API Keys

Magic Answer includes a simple graphical key manager for maintaining your Supabase key-value store.

import magic_answer

magic_answer.open_key_manager()

The key manager allows you to:

  • Add or update API keys
  • Check whether a lookup key exists
  • View the stored value associated with a lookup key

Configuration

Override the default Supabase configuration:

from magic_answer import config

config.SUPABASE_URL = "https://your-project.supabase.co"
config.SUPABASE_KEY = "your_supabase_anon_key"
config.CUSTOM_INSTRUCTION = "Your custom instruction"

Configure fallback models:

from magic_answer import models

models.models = [
    "openai/gpt-oss-20b:free",
    "qwen/qwen3-235b-a22b:free",
    "deepseek/deepseek-r1:free",
]

The library will attempt each model in order until one successfully returns a response.

API

ask(lookup_key)

Prompts the user for a question, retrieves the corresponding OpenRouter API key from Supabase using lookup_key, queries OpenRouter, and prints the model's response.

ask_clipboard(lookup_key)

Reads the prompt from the clipboard, retrieves the corresponding OpenRouter API key from Supabase, queries OpenRouter, and copies the model's response back to the clipboard.

open_key_manager()

Opens the built-in HTML key manager in the default web browser, allowing you to add, update, and inspect entries in your Supabase key-value store.

Requirements

  • Python 3.10+
  • Internet connection
  • A Supabase project containing the key-value table
  • An OpenRouter API key stored in that table

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

magic_answer-0.1.3.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

magic_answer-0.1.3-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file magic_answer-0.1.3.tar.gz.

File metadata

  • Download URL: magic_answer-0.1.3.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for magic_answer-0.1.3.tar.gz
Algorithm Hash digest
SHA256 afb606c88741c5324285b2ec07cfbbb77aeccf37ddc5e91fec9d85bcf1af3db5
MD5 d97b2a98357264117b6f84aae531713f
BLAKE2b-256 29291d197b58de82a437da8fe82deb08d69d9c06fcc3556c89f3b6ef8eb8f527

See more details on using hashes here.

File details

Details for the file magic_answer-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: magic_answer-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for magic_answer-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 022908a548f7f0c9039cf9867b77306b8b2e18d662ec10b02746b13b518ae4e5
MD5 78f3d521e7ec6b6eb031d8d5d222a15d
BLAKE2b-256 472740441902f9a329731ffdd9b36477a34e41a977ce8f41b113cfe88b1d8916

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page