601 Model Information API 46c2efb8

Model Information Api

tools-only Updated 7 repo stars

File contents

Model Information Api

Model Information API

Get Model Details

def get_model_info(model_id):
    response = requests.get(
        "https://openrouter.ai/api/v1/models",
        headers={"Authorization": f"Bearer {api_key}"}
    )
    models = response.json()["data"]
    return next((m for m in models if m["id"] == model_id), None)

model = get_model_info("anthropic/claude-3.5-sonnet")
print(f"Context: {model['context_length']}")
print(f"Prompt cost: ${model['pricing']['prompt']}/token")
print(f"Completion cost: ${model['pricing']['completion']}/token")

Model Schema

{
  "id": "anthropic/claude-3.5-sonnet",
  "name": "Claude 3.5 Sonnet",
  "description": "...",
  "context_length": 200000,
  "pricing": {
    "prompt": "0.000003",
    "completion": "0.000015"
  },
  "top_provider": {
    "context_length": 200000,
    "max_completion_tokens": 8192
  },
  "per_request_limits": null
}

tools-only/X-Skills/tree/main/automation/scripting/601-model-information-api_46c2efb8 commit 24d6b76369

Frequently asked questions

npx skillmds@latest add tools-only/601-model-information-api-46c2efb8