Search code examples
javaspringopenai-apispring-ai

Spring AI automatically assuming the model as gpt4o disregarding the configurations


I had a successfully running Spring AI project for a while. However, now when I run the project now, it throws me an odd error:

org.springframework.ai.retry.NonTransientAiException: 404 - {
    "error": {
        "message": "The model `gpt-4o` does not exist or you do not have access to it.",
        "type": "invalid_request_error",
        "param": null,
        "code": "model_not_found"
    }
}

Here are my configurations and as you can see I've specified the model as 3.5:

spring.ai.openai.api-key=${OPENAI_API_KEY}
spring.ai.openai.model=gpt-3.5-turbo

Why is it automatically assumed I need gpt4o? There are no references of gpt4o anywhere in the code. There are no references in documentation about any property name change etc.

Here is the code: https://github.com/saranshbansal/spring-ai-template


Solution

  • Replace

    spring.ai.openai.model=gpt-3.5-turbo
    

    with

    spring.ai.openai.chat.options.model=gpt-3.5-turbo
    

    Check the documentation to learn more about it.

    Note: OpenAI suggests migrating from gpt-3.5-turbo to gpt-4o-mini. Check this post for more information.