Skip to content

OpenAI Incorrect API key (invalid_api_key) - set_env quotation issue #211

@faradawn

Description

@faradawn

PLEASE FILL IN THE BUG REPORT BELOW ENSURING ALL CHECKLIST ITEMS ABOVE HAVE BEEN CONSIDERED.

Bug Description

In the basic example, the set_env command does not correct set the openAI API key in colab.

%set_env OPENAI_API_KEY="sk-..."

It produces an error

AuthenticationError: litellm.AuthenticationError: AuthenticationError: OpenAIException - Error code: 401 - {'error': {'message': 'Incorrect API key provided: "sk-proj**********************************************************************************************************************************************************vQA". You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}
Image

Solution: remove the quotation marks around the API KEY

%set_env OPENAI_API_KEY=sk-...
Image

This resolves the issue.

Expected Behavior

Steps to Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Environment Information

Operating System:

  • macOS
  • Linux
  • Windows
  • Other (please specify)

Python Version:

Package Versions:

Error Messages and Logs

Screenshots

Minimal Reproduction Example

# Minimal code to reproduce the bug

Additional Context

Checklist

  • I have searched existing issues to avoid duplicates
  • I have provided all required information
  • I have tested with the latest version of the package
  • I have included a minimal reproduction example (if applicable)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions