Skip to content

Conversation

@zeke
Copy link
Member

@zeke zeke commented Sep 23, 2025

This PR adds support for the legacy api_token parameter in both Replicate and AsyncReplicate client initialization as an alternative to bearer_token.

This enables backward compatibility with v1.x client code that uses:

  • Client(api_token="...")
  • AsyncClient(api_token="...")

The implementation:

  • Accepts both api_token and bearer_token parameters
  • Raises clear error if both are provided
  • Maps api_token to bearer_token internally
  • Maintains existing environment variable behavior
  • Includes comprehensive test coverage (14 test cases)

Testing locally

gh pr checkout 66  # Replace with actual PR number
scripts/test tests/test_api_token_compatibility.py

Prompts

open a pr that just includes the changes and tests to support api_token as an alternative to bearer_token for client instantiation

Adds support for the legacy api_token parameter in both Replicate and
AsyncReplicate client initialization as an alternative to bearer_token.

This enables backward compatibility with v1.x client code that uses:
- Client(api_token="...")
- AsyncClient(api_token="...")

The implementation:
- Accepts both api_token and bearer_token parameters
- Raises clear error if both are provided
- Maps api_token to bearer_token internally
- Maintains existing environment variable behavior
- Includes comprehensive test coverage (14 test cases)
@zeke zeke requested a review from a team as a code owner September 23, 2025 00:38
@zeke zeke closed this Sep 23, 2025
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