# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).
import oci
# Create a default config using DEFAULT profile in default location
# Refer to
# https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File
# for more info
config = oci.config.from_file()
# Initialize service client with default config file
generative_ai_inference_client = oci.generative_ai_inference.GenerativeAiInferenceClient(
config)
# Send the request to service, some parameters are not required, see API
# doc for more info
chat_response = generative_ai_inference_client.chat(
chat_details=oci.generative_ai_inference.models.ChatDetails(
compartment_id="ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
serving_mode=oci.generative_ai_inference.models.DedicatedServingMode(
serving_type="DEDICATED",
endpoint_id="ocid1.test.oc1..<unique_ID>EXAMPLE-endpointId-Value"),
chat_request=oci.generative_ai_inference.models.CohereChatRequestV2(
api_format="COHEREV2",
messages=[
oci.generative_ai_inference.models.CohereSystemMessageV2(
role="SYSTEM",
content=[
oci.generative_ai_inference.models.CohereImageContentV2(
type="IMAGE_URL",
image_url=oci.generative_ai_inference.models.CohereImageUrlV2(
url="EXAMPLE-url-Value",
detail="AUTO"))])],
documents=["EXAMPLE-documents-Value"],
citation_options=oci.generative_ai_inference.models.CitationOptionsV2(
mode="OFF"),
tools_choice="NONE",
tools=[
oci.generative_ai_inference.models.CohereToolV2(
type="FUNCTION",
function=oci.generative_ai_inference.models.Function(
name="EXAMPLE-name-Value",
parameters="EXAMPLE-parameters-Value",
description="EXAMPLE-description-Value"))],
is_strict_tools_enabled=False,
is_log_probs_enabled=True,
thinking=oci.generative_ai_inference.models.CohereThinkingV2(
type="ENABLED",
token_budget=407),
response_format=oci.generative_ai_inference.models.CohereResponseJsonFormat(
type="JSON_OBJECT",
schema="EXAMPLE-schema-Value"),
is_search_queries_only=True,
stream_options=oci.generative_ai_inference.models.StreamOptions(
is_include_usage=True),
is_stream=False,
max_tokens=676,
temperature=0.8016353,
top_k=79,
top_p=0.153871,
frequency_penalty=0.9440276,
presence_penalty=0.3435359,
seed=478,
stop_sequences=["EXAMPLE--Value"],
priority=313,
is_raw_prompting=True,
safety_mode="OFF")),
opc_retry_token="EXAMPLE-opcRetryToken-Value",
opc_request_id="V8SNRFQ3CEC5XR0VQ9K7<unique_ID>")
# Get the data from response
print(chat_response.data)