GPT example should not need OPENAI_API_KEY at export time.

Open Beginner friendly
#177 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
ai

Research direction

Start with gpt/gpt/gpt.py at the client instantiation referenced in the issue. Reproduce the export without OPENAI_API_KEY, then defer client creation as described and verify that exporting the example no longer requires the environment variable.

Written by the indexing model from the issue text.

Description

openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable

Solution is probably just to defer client instantiation by one function call. https://github.com/reflex-dev/reflex-examples/blob/cb3e32c1974e5a533c8507e1820bb643fdde53d0/gpt/gpt/gpt.py#L11 to become

def get_client():
    return OpenAI()

Dominant language
Python
Stars
576
Forks
362
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from reflex-dev/reflex-examples

All issues in reflex-dev/reflex-examples

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.