Repository navigation
feat(llms): add OCI Generative AI API key authentication for OciGenAiConfig - #266
fede-kamel wants to merge 2 commits into
Conversation
|
Hi @fede-kamel, thank you for the contribution. This looks like a relevant addition to the language spec, I will discuss a couple of minor details with the team, and I'll get back to you as soon as possible with our feedback. |
|
@fede-kamel we agreed that the proposal is good. We would just ask for one small modification: the |
…Config Add the OciClientConfigWithGenAiApiKey client configuration (auth_type GENAI_API_KEY): an OCI Generative AI API key sent as a bearer token to the OpenAI-compatible API of the service, with no OCI configuration file and no request signing. The key is a sensitive field that runtimes may also read from the OCI_GENAI_API_KEY environment variable. - register the component, extend the OciClientConfig auth_type literal and require Agent Spec 26.4.0 (accepted and rejected version tests) - reject the configuration in OciAgent (keys only authorize inference) and in the LangGraph adapter (langchain-oci has no bearer path) - language specification, JSON schema, changelog, API reference, how-to and security guidance - TypeScript mirror: zod schema, factory, registry, sensitive field, version gate and tests Refs oracle#265 Signed-off-by: Federico Kamelhar <federico.kamelhar@oracle.com>
…igurations The OciAgent section of the language specification now requires an IAM-based OciClientConfig and declares OciClientConfigWithGenAiApiKey invalid for OciAgent, matching the validator in pyagentspec. The changelog entry mentions the constraint. Signed-off-by: Federico Kamelhar <federico.kamelhar@oracle.com>
|
Thanks @cesarebernardis. The rejection is already in this PR, and bba2ae6 makes the constraint explicit in the language specification:
The branch is also rebased on One side note: loading such a configuration through |
7fd7df2 to
bba2ae6
Compare
|
LGTM. Adding OCI Generative AI API key auth to is well-documented with live verification. TypeScript and Python parity is consistent. Ready for maintainer review. |
fede-kamel
left a comment
There was a problem hiding this comment.
Clean feature addition for OCI Generative AI API key auth.
Design is correct
- New
OciClientConfigWithGenAiApiKeywithapi_key: SensitiveField[Optional[str]]andauth_type: Literal["GENAI_API_KEY"]— consistent with existing auth types. - Optional
api_keyso runtimes can load fromOCI_GENAI_API_KEYenv var — good for CI/CD and containers. - Proper sensitive field handling with
$component_refplaceholder in exports. OciAgentcorrectly rejects this config (API keys can't do Agents service IAM auth).- LangGraph adapter rejects with
NotImplementedErrorpointing to OpenAI-compatible runtimes.
TypeScript parity is present with zod schema, factory, registry entries, sensitive field, version gate, and tests.
Version gating at 26.4.0 with accepted/rejected tests — correct approach for spec evolution.
Scope is clear: execution in adapters is deferred to the follow-up PR (#264), which is the right place since the shared OpenAI-compatible client helper is where the bearer token actually gets sent.
No blockers.
Closes #265.
Adds a fifth
OciClientConfigauthentication type forOciGenAiConfig: an OCI Generative AI API key, sent as a bearer token to the OpenAI-compatible API of the service. Today the fourOciClientConfigspecialisations all describe OCI IAM principals whose requests the OCI SDK signs, so an agent meant to run with a Generative AI API key (the credential shape used by the stockopenaiSDK, LiteLLM, opencode / models.dev provider entries and OpenRouter-style routers) cannot be expressed in Agent Spec, and falling back toOpenAiCompatibleConfigloses the OCI semantics (compartment_id,serving_mode,provider,api_type).Changes
service_endpointis inherited (the regional Generative AI inference endpoint); the baseauth_typeliteral gains"GENAI_API_KEY".api_keyis a sensitive field, exported as a$component_refplaceholder likeGeminiAIStudioAuthConfig.api_key, and optional so runtimes can load it fromOCI_GENAI_API_KEY._component_registry.py; language specification (component and sensitive-fields table), regenerated 26.4.0 JSON schema, API reference, changelog, provider how-to and security guidance.OciAgentrejects this client configuration with a clear error: Generative AI API keys only authorize model inference, not the Agents service.NotImplementedErrorpointing to the OpenAI-compatible runtimes (langchain-ocihas no bearer path).tsagentspec: zod schema, factory, registry entries, sensitive field, version gate, tests.Adapter execution is not part of this PR: the shared OpenAI-compatible client helper of #264 (AutoGen, Agent Framework, OpenAI Agents) is the natural place to turn this configuration into a plain bearer
openaiclient with no request signing and nooci-genai-authdependency, and a follow-up commit there adds it once this component exists.Behaviour of the credential, verified live
The design follows what the service does, checked against OCI Generative AI (us-chicago-1) with the stock
openaiSDK and a Generative AI API key:Authorization: Bearer <key>against<service_endpoint>/openai/v1/chat/completionsworks for Meta Llama, xAI Grok and OpenAI gpt-oss models with noopc-compartment-idheader (the key is compartment-scoped): plain completions with usage, streaming and tool calls all succeed.Tests
tests/test_ocigenaiconfig.py,tests/test_ociagent.py,tests/serialization/test_oci_genai_models.py,tests/serialization/test_sensitive_fields.py,tests/adapters/langgraph/llms/test_ocigenai_conversion.py: round trip, sensitive-field placeholder, version gating,OciAgentand LangGraph rejection.tsagentspec:oci-client-config,sensitive-fields,version-gatessuites.SKIP_LLM_TESTS=1) pass locally on Python 3.12.