Skip to content

Error code: 500 | 400 Unable to access model gpt-4o-mini. #3

Description

@Unrectified

I got the simplest code possible with api, I just got a fresh and new API key, but I get this error:

"error : Error code: 500 - {'requestId': 'ebc099bf-7562-452d-854c-c44e6d0c7b5a', 'statusCode': 500, 'timestamp': '2024-10-01T15:31:02.168Z', 'path': '/chat/completions', 'message': '400 Unable to access model gpt-4o-mini. '}"

Here my code:
`base_url = "https://api.aimlapi.com"
api_key = "94aa0232a914485591fba8ab561e7485"
system_prompt = "You are a travel agent. Be descriptive and helpful."

api = OpenAI(api_key=api_key, base_url=base_url)

Voici la cog nommée "Tests" avec sa classe correspondante

class Tests(commands.Cog, name="tests"):
def init(self, bot) -> None:
self.bot = bot

@commands.hybrid_command()
async def test_openai(self,ctx,question:str):
    user_prompt = question
    await ctx.defer()
    try:
        completion = api.chat.completions.create(
            model="mistralai/Mistral-7B-Instruct-v0.2",
            messages=[
                {"role": "system", "content": system_prompt},
                {"role": "user", "content": user_prompt},
            ],
            temperature=0.7,
            max_tokens=256,
        )

        response = completion.choices[0].message.content

        print("User:", user_prompt)
        print("AI:", response)
        await ctx.send(f"user : {user_prompt}\nAI : {response}")
    except Exception as e:
        await ctx.send(f"error : {e}")`

Is there any way to fix it?
Rgds

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions