OpenRouter Python SDK

repository·main·Indexed 40 days ago

https://github.com/openrouterteam/python-sdk

Official Python Client SDK (v1.2.8) providing type-safe access to over 400 AI models. Supports synchronous and asynchronous workflows, streaming, web search tools, and efficient file uploads. Requires Python 3.10 or higher.

Tokens
161.1K
Snippets
281
Records
476
Agent score
51%

What's inside OpenRouter

  1. Overview of SCIM Management Endpoints

    main

    The SCIM (System for Cross-domain Identity Management) endpoints in the OpenRouter SDK are used to manage group-to-workspace mappings.

    Important Distinctions:

    • These are management endpoints for configuring mappings, not the SCIM 2.0 connector endpoints used by your Identity Provider (IdP).
    • To set up provisioning in your IdP, use the specific SCIM endpoint URL found in OpenRouter under Settings > Members > SCIM Mappings.
    • These operations require a management key for authentication.
  2. Overview of Rerank endpoints

    main
    The Rerank endpoints allow you to submit requests to re-score and re-order a list of documents based on their relevance to a specific query. This is typically used to improve the precision of retrieval-augmented generation (RAG) systems by refining the results returned by an initial search step.
  3. Overview of STT (Speech-to-Text) operations

    main

    The OpenRouter Python SDK provides Speech-to-Text (STT) capabilities through two primary operations for creating transcriptions:

    1. create_transcription: Standard transcription creation.
    2. create_transcription_multipart: Transcription creation designed for multipart/form-data requests (typically used for uploading files).

    Refer to the specific operation documentation for detailed parameter requirements and usage examples.

  4. Overview of BYOK (Bring Your Own Key) endpoints

    main

    The BYOK (Bring Your Own Key) endpoints allow developers to manage provider credentials directly through the OpenRouter SDK. This enables users to provide their own API keys for various AI providers, allowing OpenRouter to route requests using the user's specific credentials.

    Supported operations include:

    • list: Retrieve a list of existing BYOK provider credentials.
    • create: Provision a new BYOK provider credential.
    • delete: Remove an existing BYOK provider credential.
    • get: Retrieve details for a specific BYOK provider credential.
    • update: Modify an existing BYOK provider credential.
  5. Overview of Container operations

    main

    The OpenRouter SDK provides several operations for interacting with containers. These operations allow you to manage and retrieve files stored within a container environment.

    Available operations include:

    • list_container_files: List the files available within a container.
    • get_container_file: Retrieve metadata or information about a specific container file.
    • download_container_file_content: Download the actual content of a container file.
    • promote_container_file: Promote a container file into workspace documents.
  6. Overview of OpenRouter Datasets

    main

    The OpenRouter Datasets provide public usage data from the OpenRouter platform. This data is useful for analyzing model popularity, token usage, and cost metrics.

    Licensing Notice: Data returned by these endpoints is licensed under CC BY 4.0. You are permitted to reuse and republish the data, including for commercial purposes, provided you give appropriate attribution to OpenRouter.

  7. Overview of OpenRouter OAuth operations

    main

    The OpenRouter Python SDK provides several OAuth-related operations for managing authentication flows:

    • exchange_auth_code_for_api_key: Exchange an authorization code from the PKCE flow for a user-controlled API key.
    • create_auth_code: Create an authorization code.
    • list_oauth_jwks: Retrieve OpenRouter access token signing keys.
    • create_oauth_token: Exchange a workload identity token.