TramAI - governed AI workflows for Java and Kotlin

tramai-spring-provider-openai

Version: 0.6.0
Status: Preview
Role: Provider adapter module: OpenAI and OpenAI-compatible configuration for Spring applications.

Purpose

This adapter turns tramai.providers.openai.* and tramai.providers.openai-compatible.* into provider beans. It constructs providers only: model routing, fallbacks, retries, circuit breaking, caching and cost budgets stay in the runtime and are configured under tramai.* in tramai-spring-core.

What it provides

ComponentDetail
OpenAiProviderAutoConfigurationContributes both provider beans; backs off when the application defines its own Tramai bean
OpenAiPropertiesBinds tramai.providers.openai.*
OpenAiCompatiblePropertiesBinds tramai.providers.openai-compatible.*
CodexAuthenabled / auth-file for ChatGPT-codex credential files (experimental, local testing)
BeansSpringConfiguredModelProvider descriptors for provider ids openai and the configured compatible-provider name

Property surface:

KeyNotes
tramai.providers.openai.api-keyDirect key
tramai.providers.openai.api-key-secret-refSecret reference resolved through the shared chain (env:, file:, vault:, aws-secretsmanager:)
tramai.providers.openai.bearer-token, …-secret-refBearer-token auth instead of an API key
tramai.providers.openai.base-url, organization, projectEndpoint and account scoping
tramai.providers.openai-compatible.provider-nameProvider id registered on the runtime (default openai-compatible)
tramai.providers.openai-compatible.api-key, …-secret-ref, bearer-token, …-secret-ref, base-urlSame auth options for compatible endpoints

Configuring api-key and its *-secret-ref at once is a misconfiguration and fails at startup rather than silently preferring one.

Dependencies

dependencies {
    implementation(platform("dev.tramai:tramai-bom:0.6.0"))
    implementation("dev.tramai:tramai-spring-boot-starter")
    implementation("dev.tramai:tramai-spring-provider-openai")
}
tramai:
  default-provider: openai
  models:
    gpt-4o: openai
  providers:
    openai:
      api-key: ${OPENAI_API_KEY}
    openai-compatible:
      provider-name: my-local
      base-url: https://my-endpoint.example.com/v1
      api-key: ${MY_LOCAL_KEY}

When to use this module

  • You call OpenAI, an Azure-style compatible gateway, or any OpenAI-compatible endpoint from a Spring application.
  • You need credentials resolved from Vault or AWS Secrets Manager through *-secret-ref.

When NOT to use this module