Skip to content

fix: use async clients for acompletion methods - #9

Merged
alexzhang13 merged 1 commit into
alexzhang13:mainfrom
whoisnnamdi:fix-async
Jan 4, 2026
Merged

alexzhang13 merged 1 commit into
alexzhang13:mainfrom
whoisnnamdi:fix-async

Conversation

@whoisnnamdi

@whoisnnamdi whoisnnamdi commented Jan 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Running async code paths (e.g., REPL chunk investigation) produced:
Error: object ChatCompletion can't be used in 'await' expression

Changes

  • Fixed acompletion() methods in OpenAI and Portkey clients that were incorrectly awaiting synchronous client responses
  • Added AsyncOpenAI and AsyncPortkey clients for proper async support, matching existing Anthropic client pattern

Specifically:

  • rlm/clients/openai.py: Initialize self.async_client with openai.AsyncOpenAI(), use in acompletion()
  • rlm/clients/portkey.py: Initialize self.async_client with AsyncPortkey(), use in acompletion()

The Anthropic client already followed this pattern correctly with both anthropic.Anthropic() and anthropic.AsyncAnthropic(). OpenAI and Portkey now match.

@alexzhang13

Copy link
Copy Markdown
Owner

Thanks, this is a good catch. In general I should add better testing for the asynchronous calls, it wasn't tested very heavily.

@alexzhang13
alexzhang13 merged commit 35ff799 into alexzhang13:main Jan 4, 2026
3 checks passed
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