Skip to content

Add support for OpenAI service_tier in OpenAiChatOptions #4235

@rafaelrddc

Description

@rafaelrddc

Please do a quick search on GitHub issues first, the feature you are about to request might have already been requested.

Expected Behavior

Users should be able to specify the service_tier parameter when making calls to OpenAI through Spring AI's OpenAiClient. This parameter should be configurable via OpenAiChatOptions.

Example usage:

OpenAiChatOptions options = OpenAiChatOptions.builder()
    .serviceTier("priority") // or "default", "flex", "auto"
    .build();

Current Behavior

The service_tier field already exists in the OpenAiApi class but is not exposed through OpenAiChatOptions. Currently, there's no way for users to set this parameter when making API calls to OpenAI through Spring AI.

Context

  • Impact: Without this parameter, we cannot explicitly control the service tier for OpenAI requests, which affects:

    • Cost management (different tiers have different pricing)
    • Performance characteristics (priority vs default processing)
    • Dedicated capacity usage (for enterprise deployments)
  • Use Case: We need to specify service tiers for:

    • Production workloads requiring guaranteed capacity ("priority")
    • Cost-sensitive applications ("default")
    • Dynamic scaling scenarios ("flex")
    • Project-level configuration adherence ("auto")

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions