Skip to main content
Oracle provides an inference service called OCI GenerativeAI.
Provider Slug. oracle

Portkey SDK Integration with Oracle

Portkey provides a consistent API to interact with models from Oracle. To integrate Oracle with Portkey:

1. Create an Oracle Integration

The auth headers can be configured directly in your integration or passed directly in the request headers.
The GenerativeAI service from oracle is a service domain endpoint and required signing of the request, Portkey handles the signing of the request for you and you only need to provide the headers below. These are the required headers for inference requests:
HeaderValue
x-portkey-oracle-api-versionThe Oracle API version to use (example: 20160918)
x-portkey-oracle-regionThe Oracle region (example: us-ashburn-1)
x-portkey-oracle-compartment-idThe Compartment OCID (example: ocid1.compartment.oc1..aaaaaaaab7x77777777777777777)
x-portkey-oracle-serving-modeThe serving mode. Supported values: ON_DEMAND, DEDICATED
x-portkey-oracle-tenancyThe Tenancy OCID (example: ocid1.tenancy.oc1..aaaaaaaab7x77777777777777777)
x-portkey-oracle-userThe User OCID (example: ocid1.user.oc1..aaaaaaaab7x77777777777777777)
x-portkey-oracle-fingerprintThe API key fingerprint (example: 12:34:56:78:90:ab:cd:ef:12:34:56:78:90:ab:cd:ef)
x-portkey-oracle-private-keyThe API private key (example: -----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA…)

2. Install the Portkey SDK

Add the Portkey SDK to your application to interact with Oracle’s models through Portkey’s gateway.
npm install --save portkey-ai

3. Initialize Portkey with the Virtual Key

To use Oracle with Portkey, get your API key from here, then add it to Portkey to create the virtual key.
import Portkey from 'portkey-ai'

const portkey = new Portkey({
    apiKey: "PORTKEY_API_KEY", // defaults to process.env["PORTKEY_API_KEY"]
    provider:"@PROVIDER" // Your Oracle Virtual Key
})

3. Invoke Chat Completions with Oracle

Use the Portkey instance to send requests to Oracle’s models. You can also override the virtual key directly in the API call if needed.
const chatCompletion = await portkey.chat.completions.create({
    messages: [{ role: 'user', content: 'Say this is a test' }],
    model: 'command',
});

console.log(chatCompletion.choices);

Managing Oracle Prompts

You can manage all prompts to Oracle in the Prompt Library. All the current models of Oracle are supported and you can easily start testing different prompts. Once you’re ready with your prompt, you can use the portkey.prompts.completions.create interface to use the prompt in your application.

Next Steps

The complete list of features supported in the SDK are available on the link below.

SDK

You’ll find more information in the relevant sections:
  1. Add metadata to your requests
  2. Add gateway configs to your Oracle requests
  3. Tracing Oracle requests
  4. Setup a fallback from OpenAI to Oracle APIs