Skip to content
site logo mobile

Forum in maintenance, we will back soon 🙂

Implementing OpenAI...
 
Notifications
Clear all

Implementing OpenAI Python SDK on simplerLLM

6 Posts
3 Users
0 Likes
53 Views
(@sahu)
Posts: 7
Active Member
Topic starter
 

Sir, I want to implement OpenAI Python SDK to simplerLLM. Its a open source model which provides API. They provides OpenAI Python SDK which I shared below & its working fine to other project but now want to use it with simplesLLM. I added it in the main Python file & got "errorMessage": "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",
"errorType": "OpenAIError",

import openai

client = openai.OpenAI(
    base_url = "https://api.endpoints.com/v1",
    api_key = "esecret_YOUR_API_KEY"
)

chat_completion = client.chat.completions.create(
    model="model-name-chat",
    messages=[{"role": "system", "content": "You are a helpful assistant."}, 
              {"role": "user", "content": "Say 'Test'."}],
    temperature=0.7
)
 
Posted : 03/24/2024 2:05 am
SSAdvisor
(@ssadvisor)
Posts: 902
Noble Member
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
 

@sahu

Posted by: @sahu

client = openai.OpenAI( base_url = "https://api.endpoints.com/v1", api_key = "esecret_YOUR_API_KEY" )

did you set your api_key value and the "esecret_YOUR_API_KEY" value is just for display here?

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 03/24/2024 4:30 am
(@sahu)
Posts: 7
Active Member
Topic starter
 

@ssadvisor 

Yes, I set the actual key value in my project  & here I just put a dummy value.

 
Posted : 03/24/2024 6:45 am
(@husein)
Posts: 250
Member Moderator
Premium Member
Prompt Engineer
Pythonista Prodigy Badge
API Entrepreneur
Power Member
 

@sahu Are you sure this same code works in other projects? I tried to run in it and it gave me a ton of OpenAI-related errors

 
Posted : 03/24/2024 9:37 am
(@sahu)
Posts: 7
Active Member
Topic starter
 

@husein 

I m not use actual openai api. Using some other llm those are provided above code to interact with openai.

 
Posted : 03/24/2024 11:20 am
(@husein)
Posts: 250
Member Moderator
Premium Member
Prompt Engineer
Pythonista Prodigy Badge
API Entrepreneur
Power Member
 

@sahu Im sorry, I didn quite understand what you're exactly trying to do.

Please explain more what's the project you're trying to implement and the error you're encountering.

 
Posted : 03/24/2024 12:36 pm
Share: