Skip to content

Conversation

@langfuse-bot
Copy link
Collaborator

@langfuse-bot langfuse-bot commented Oct 31, 2025

Important

Adds functionality to retrieve organization API keys with new models and client methods in client.py.

  • Behavior:
    • Adds get_organization_api_keys() to OrganizationsClient and AsyncOrganizationsClient in client.py to retrieve all API keys for an organization.
    • Handles HTTP status codes 200, 400, 401, 403, 404, and 405 with appropriate error handling.
  • Models:
    • Adds OrganizationApiKey and OrganizationApiKeysResponse models in organization_api_key.py and organization_api_keys_response.py.
  • Exports:
    • Updates __init__.py files to include OrganizationApiKey and OrganizationApiKeysResponse in exports.

This description was created by Ellipsis for c364a0a. You can customize this summary. It will automatically update as commits are pushed.

Disclaimer: Experimental PR review

Greptile Overview

Updated On: 2025-10-31 15:09:26 UTC

Greptile Summary

This PR adds a new API endpoint to retrieve organization API keys, automatically generated from the Langfuse API specification.

Key Changes:

  • Added OrganizationApiKey Pydantic model with fields for id, timestamps, public key, and display secret key
  • Added OrganizationApiKeysResponse wrapper model for the API response
  • Implemented get_organization_api_keys() method in both sync (OrganizationsClient) and async (AsyncOrganizationsClient) clients
  • Added comprehensive error handling for HTTP status codes 400, 401, 403, 404, and 405
  • Updated all module exports across the API package hierarchy
  • Added reference documentation for the new endpoint

Code Quality:

  • All imports are properly placed at the module top (follows custom instruction c960fc07-9928-409f-a18b-a780cbdded12)
  • Code follows existing patterns and conventions in the codebase
  • Proper type hints and Pydantic field aliases are used
  • Consistent error handling with other endpoints in the same client

Confidence Score: 5/5

  • This PR is safe to merge with no identified risks
  • Auto-generated code follows established patterns, proper error handling included, all imports correctly placed, consistent with existing codebase structure
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
langfuse/api/resources/organizations/types/organization_api_key.py 5/5 Added new Pydantic model for OrganizationApiKey with proper field aliases and datetime handling
langfuse/api/resources/organizations/types/organization_api_keys_response.py 5/5 Added response wrapper model for list of OrganizationApiKey objects with proper serialization
langfuse/api/resources/organizations/client.py 5/5 Added sync and async methods to retrieve organization API keys with proper error handling

Sequence Diagram

sequenceDiagram
    participant Client
    participant OrganizationsClient
    participant HTTP as HTTP Client
    participant API as Langfuse API
    
    Client->>OrganizationsClient: get_organization_api_keys()
    OrganizationsClient->>HTTP: GET /api/public/organizations/apiKeys
    HTTP->>API: Request with org-scoped API key
    
    alt Success (200-299)
        API-->>HTTP: Return API keys data
        HTTP-->>OrganizationsClient: Response
        OrganizationsClient->>OrganizationsClient: Parse to OrganizationApiKeysResponse
        OrganizationsClient-->>Client: Return OrganizationApiKeysResponse
    else Error 400
        API-->>HTTP: Bad Request
        HTTP-->>OrganizationsClient: 400 Response
        OrganizationsClient->>Client: Raise Error
    else Error 401
        API-->>HTTP: Unauthorized
        HTTP-->>OrganizationsClient: 401 Response
        OrganizationsClient->>Client: Raise UnauthorizedError
    else Error 403
        API-->>HTTP: Access Denied
        HTTP-->>OrganizationsClient: 403 Response
        OrganizationsClient->>Client: Raise AccessDeniedError
    else Error 404
        API-->>HTTP: Not Found
        HTTP-->>OrganizationsClient: 404 Response
        OrganizationsClient->>Client: Raise NotFoundError
    else Error 405
        API-->>HTTP: Method Not Allowed
        HTTP-->>OrganizationsClient: 405 Response
        OrganizationsClient->>Client: Raise MethodNotAllowedError
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants