Bug
OciClientV2.chat() with tools parameter returns a 400 error from OCI Generative AI:
status_code: 400, body: {'message': 'Please pass in correct format of request.'}
Root Cause
OCI Generative AI expects all enum fields uppercased. The SDK already transforms message roles ("user" → "USER") and content types ("text" → "TEXT"), but passes the tool type field through as-is ("function" instead of "FUNCTION").
Reproduction
import cohere
client = cohere.OciClientV2(
oci_region="us-chicago-1",
oci_compartment_id="ocid1.compartment.oc1...",
)
# This returns 400
response = client.chat(
model="command-a-03-2025",
messages=[{"role": "user", "content": "What's the weather in Toronto?"}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather",
"parameters": {"type": "object", "properties": {"location": {"type": "string"}}, "required": ["location"]},
},
}],
)
Expected
Tool use works — OCI returns finish_reason=TOOL_CALL with tool_calls.
Impact
All tool use via OciClientV2 is broken on OCI on-demand inference.
Bug
OciClientV2.chat()withtoolsparameter returns a 400 error from OCI Generative AI:Root Cause
OCI Generative AI expects all enum fields uppercased. The SDK already transforms message roles (
"user"→"USER") and content types ("text"→"TEXT"), but passes the tooltypefield through as-is ("function"instead of"FUNCTION").Reproduction
Expected
Tool use works — OCI returns
finish_reason=TOOL_CALLwithtool_calls.Impact
All tool use via
OciClientV2is broken on OCI on-demand inference.