|
| 1 | +# How to Use Cline with OCI Generative AI Models via the OpenAI API |
| 2 | + |
| 3 | +A practical guide for configuring Cline to call OCI Generative AI models through OCI's OpenAI-compatible API. |
| 4 | + |
| 5 | +Cline is an AI coding assistant that works inside your IDE and can help with day-to-day development tasks such as explaining unfamiliar code, generating new files, refactoring existing logic, writing tests, debugging errors, and summarizing repository structure. By connecting Cline to OCI Generative AI, developers can use OCI-hosted models directly from their coding environment while keeping model access, deployment choices, and enterprise controls within Oracle Cloud Infrastructure. |
| 6 | + |
| 7 | +This setup is useful when teams want AI-assisted development workflows that can use either on-demand OCI Generative AI models for quick setup or Dedicated AI Cluster (DAC)-hosted models for production-grade isolation, performance, and customization. |
| 8 | + |
| 9 | +## Overview |
| 10 | + |
| 11 | +This tutorial walks through configuring Cline to use OCI Generative AI models through the OCI OpenAI-compatible API. |
| 12 | + |
| 13 | +The process involves: |
| 14 | + |
| 15 | +1. Selecting an OCI Generative AI model |
| 16 | +2. Choosing whether to use the model on demand or from a Dedicated AI Cluster (DAC) |
| 17 | +3. Understanding the OCI OpenAI-compatible API endpoint URL |
| 18 | +4. Creating an OCI Generative AI API key |
| 19 | +5. Configuring Cline with the OCI OpenAI-compatible base URL, API key, and model ID |
| 20 | +6. Testing the setup with an example prompt |
| 21 | + |
| 22 | +OCI provides OpenAI-compatible APIs for model inference, including Chat Completions and Responses. This tutorial uses the OCI Generative AI OpenAI-compatible API documented here: |
| 23 | + |
| 24 | +https://docs.oracle.com/en-us/iaas/Content/generative-ai/openai-compatible-api.htm |
| 25 | + |
| 26 | +Cline can connect to this API by using the **OpenAI Compatible** provider configuration. |
| 27 | + |
| 28 | +## Prerequisites |
| 29 | + |
| 30 | +Before starting, ensure you have: |
| 31 | + |
| 32 | +- Access to Oracle Cloud Infrastructure |
| 33 | +- Access to OCI Generative AI |
| 34 | +- A compartment where you can create Generative AI resources |
| 35 | +- Cline installed in VS Code or PyCharm |
| 36 | + |
| 37 | +## Steps |
| 38 | + |
| 39 | +### 1. Select a Supported OCI Region |
| 40 | + |
| 41 | +Choose a region where OCI Generative AI and your target model are available. |
| 42 | + |
| 43 | +Example regions include: |
| 44 | + |
| 45 | +- `us-chicago-1` |
| 46 | +- `us-ashburn-1` |
| 47 | +- `uk-london-1` |
| 48 | +- `eu-frankfurt-1` |
| 49 | + |
| 50 | +The region is used in the OpenAI-compatible URL. |
| 51 | + |
| 52 | +On-demand example: |
| 53 | + |
| 54 | +```text |
| 55 | +https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/openai/v1 |
| 56 | +``` |
| 57 | + |
| 58 | +DAC Chat Completions example: |
| 59 | + |
| 60 | +```text |
| 61 | +https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/openai/v1/chat/completions |
| 62 | +``` |
| 63 | + |
| 64 | + |
| 65 | +### 2. Choose a Model |
| 66 | + |
| 67 | +Select the OCI Generative AI model that you want Cline to use. OCI Generative AI models can be used either on demand or from a Dedicated AI Cluster (DAC). The Cline setup is different for each option, so choose the deployment path first. |
| 68 | + |
| 69 | +#### On-Demand Models |
| 70 | + |
| 71 | +On-demand models are shared, OCI-hosted models that are ready to call directly through the OpenAI-compatible API. This is the simplest setup for testing, prototyping, and lighter usage patterns. |
| 72 | + |
| 73 | +Example OCI Model Names: |
| 74 | + |
| 75 | +```text |
| 76 | +xai.grok-code-fast-1 |
| 77 | +xai.grok-4.20-0309-reasoning |
| 78 | +meta.llama-4-maverick-17b-128e-instruct-fp8 |
| 79 | +openai.gpt-oss-120b |
| 80 | +google.gemini-2.5-flash |
| 81 | +``` |
| 82 | + |
| 83 | +For on-demand models, the Cline **Model ID** is the OCI Model Name. |
| 84 | + |
| 85 | +#### Dedicated AI Cluster (DAC)-Hosted Models |
| 86 | + |
| 87 | +DAC-hosted models run on dedicated infrastructure in your tenancy. Use a DAC-hosted model when you need production-grade control over model hosting and inference. DACs provide several advantages: |
| 88 | + |
| 89 | +- **Flexibility:** Import supported Hugging Face-format models from Hugging Face or Object Storage, test imported models with shorter commitments, choose fine-tuned or quantized versions, and right-size based on visible hardware specifications. |
| 90 | +- **Isolation:** Run workloads on dedicated GPU resources inside your tenancy, which helps protect sensitive data, avoids shared-resource contention, and supports regulated workloads. |
| 91 | +- **Predictable latency:** Dedicated infrastructure can provide more stable time-to-first-token and inference response times than shared model endpoints, especially for scaling production applications. |
| 92 | +- **Fine-tuning support:** Host fine-tuned models alongside base models, run multiple fine-tuned models on a single cluster, and control model lifecycle and upgrade cadence. |
| 93 | +- **Cost efficiency at scale:** For inference-heavy workloads, DACs can reduce effective price per token by keeping dedicated resources highly utilized and hosting multiple models on one cluster. |
| 94 | +- **Deployment near data:** Deploy in supported OCI regions, including regulated regions where available, to support data residency, lower latency, and simpler security reviews. |
| 95 | +- **Simplified management:** OCI manages the infrastructure while you manage model deployment, scaling, fine-tuning, and application integration. |
| 96 | + |
| 97 | +Before configuring Cline for a DAC-hosted model, make sure the model endpoint is already created and active. |
| 98 | + |
| 99 | +1. Open the OCI Console |
| 100 | +2. Navigate to **Analytics & AI -> Generative AI** |
| 101 | +3. Go to **Endpoints** |
| 102 | +4. Confirm that the endpoint for your DAC-hosted model is **Active** |
| 103 | +5. Keep note of the endpoint region and DAC endpoint OCID |
| 104 | + |
| 105 | +For DAC-hosted models, the Cline **Model ID** is the DAC endpoint OCID. |
| 106 | + |
| 107 | +```text |
| 108 | +ocid1.generativeaiendpoint.<region>..<unique_id> |
| 109 | +``` |
| 110 | + |
| 111 | +### 3. Understand the OCI OpenAI-Compatible API Endpoint URL |
| 112 | + |
| 113 | +Cline uses a different OCI OpenAI-compatible endpoint format depending on whether the model is on demand or DAC-hosted. |
| 114 | + |
| 115 | +For on-demand models, configure the base URL **without** `/chat/completions`: |
| 116 | + |
| 117 | +```text |
| 118 | +https://inference.generativeai.<region>.oci.oraclecloud.com/openai/v1 |
| 119 | +``` |
| 120 | + |
| 121 | +For DAC-hosted models, configure the full Chat Completions URL **with** `/chat/completions`: |
| 122 | + |
| 123 | +```text |
| 124 | +https://inference.generativeai.<region>.oci.oraclecloud.com/openai/v1/chat/completions |
| 125 | +``` |
| 126 | + |
| 127 | +Keep note of the following values: |
| 128 | + |
| 129 | +- Region |
| 130 | +- OCI Model Name or DAC endpoint OCID |
| 131 | +- Compartment |
| 132 | + |
| 133 | +### 4. Create an OCI Generative AI API Key |
| 134 | + |
| 135 | +1. In the OCI Console, select the same region as your model |
| 136 | +2. Navigate to **Analytics & AI -> Generative AI** |
| 137 | +3. Select **API keys** |
| 138 | +4. Click **Create API key** |
| 139 | +5. Enter a name, for example: |
| 140 | + |
| 141 | +```text |
| 142 | +cline-genai-key |
| 143 | +``` |
| 144 | + |
| 145 | +6. Add a description if needed |
| 146 | +7. Configure key names and expiration dates |
| 147 | +8. Click **Create** |
| 148 | +9. Copy one of the generated key values |
| 149 | + |
| 150 | +OCI Generative AI API keys are service-specific credentials and are different from OCI IAM API keys. |
| 151 | + |
| 152 | +⚠️ Store the key securely. Do not commit it to GitHub or place it in source code. |
| 153 | + |
| 154 | +### 5. Build the OCI OpenAI-Compatible URL |
| 155 | + |
| 156 | +For on-demand models, use the following base URL format for Cline: |
| 157 | + |
| 158 | +```text |
| 159 | +https://inference.generativeai.<region>.oci.oraclecloud.com/openai/v1 |
| 160 | +``` |
| 161 | + |
| 162 | +Example for US Midwest Chicago: |
| 163 | + |
| 164 | +```text |
| 165 | +https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/openai/v1 |
| 166 | +``` |
| 167 | + |
| 168 | +For DAC-hosted models, use the full Chat Completions URL shown in the DAC section. |
| 169 | + |
| 170 | +Example for UK South London: |
| 171 | + |
| 172 | +```text |
| 173 | +https://inference.generativeai.uk-london-1.oci.oraclecloud.com/openai/v1/chat/completions |
| 174 | +``` |
| 175 | + |
| 176 | + |
| 177 | +### 6. Configure Cline |
| 178 | + |
| 179 | +Open VS Code or PyCharm and configure Cline: |
| 180 | + |
| 181 | +1. Open the Cline panel |
| 182 | +2. Click the **Settings** icon |
| 183 | +3. Under **API Provider**, select: |
| 184 | + |
| 185 | +```text |
| 186 | +OpenAI Compatible |
| 187 | +``` |
| 188 | + |
| 189 | +4. Set **Base URL** to your OCI URL. |
| 190 | + |
| 191 | +For on-demand models: |
| 192 | + |
| 193 | +```text |
| 194 | +https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/openai/v1 |
| 195 | +``` |
| 196 | + |
| 197 | +For DAC-hosted models: |
| 198 | + |
| 199 | +```text |
| 200 | +https://inference.generativeai.uk-london-1.oci.oraclecloud.com/openai/v1/chat/completions |
| 201 | +``` |
| 202 | + |
| 203 | +5. Paste your OCI Generative AI API key into the **API Key** field |
| 204 | +6. Set **Model ID** to your OCI Model Name or DAC endpoint OCID |
| 205 | + |
| 206 | +Example: |
| 207 | + |
| 208 | +```text |
| 209 | +xai.grok-code-fast-1 |
| 210 | +``` |
| 211 | + |
| 212 | +For a DAC-hosted model, use the DAC endpoint OCID instead: |
| 213 | + |
| 214 | +```text |
| 215 | +ocid1.generativeaiendpoint.<region>..<unique_id> |
| 216 | +``` |
| 217 | + |
| 218 | +7. Save the configuration |
| 219 | + |
| 220 | +### 7. Test the Connection in Cline |
| 221 | + |
| 222 | +Use a simple prompt first: |
| 223 | + |
| 224 | +```text |
| 225 | +Hello. Reply with one sentence confirming that the connection works. |
| 226 | +``` |
| 227 | + |
| 228 | +If the setup is correct, Cline should return a normal response from the OCI-hosted model. |
| 229 | + |
| 230 | +### 8. Example Coding Prompt |
| 231 | + |
| 232 | +After the basic test succeeds, try a Cline-style development prompt: |
| 233 | + |
| 234 | +```text |
| 235 | +Create a small Python script that reads a text file, counts the number of lines, words, and characters, and prints the results in a clean table. Include basic error handling for missing files. |
| 236 | +``` |
| 237 | + |
| 238 | +You can also test repository-aware behavior: |
| 239 | + |
| 240 | +```text |
| 241 | +Review this project and explain the main application structure. Then suggest three small improvements that would make the code easier to maintain. |
| 242 | +``` |
| 243 | + |
| 244 | +## Troubleshooting |
| 245 | + |
| 246 | +### Invalid API Key |
| 247 | + |
| 248 | +Check that: |
| 249 | + |
| 250 | +- The key was copied correctly |
| 251 | +- The key is active |
| 252 | +- The key has not expired |
| 253 | +- The key was created in the same region as the model |
| 254 | + |
| 255 | +### Model Not Found |
| 256 | + |
| 257 | +Check that: |
| 258 | + |
| 259 | +- The model is available in the selected region |
| 260 | +- The model supports OpenAI-compatible chat completion requests |
| 261 | +- If using a DAC-hosted model, the OCI Generative AI endpoint is active and the Model ID field uses the DAC endpoint OCID |
| 262 | + |
| 263 | +### Authorization Error |
| 264 | + |
| 265 | +Check that: |
| 266 | + |
| 267 | +- IAM policy has been added |
| 268 | +- The API key OCID is correct in the policy |
| 269 | +- The policy is in the correct tenancy or compartment scope |
| 270 | +- You are using a Generative AI API key, not an OCI IAM API signing key |
| 271 | + |
| 272 | +### Connection Error |
| 273 | + |
| 274 | +Check that: |
| 275 | + |
| 276 | +- The base URL uses the correct region |
| 277 | +- For on-demand models, the URL ends with: |
| 278 | + |
| 279 | +```text |
| 280 | +/openai/v1 |
| 281 | +``` |
| 282 | + |
| 283 | +- For DAC-hosted models, the URL ends with: |
| 284 | + |
| 285 | +```text |
| 286 | +/openai/v1/chat/completions |
| 287 | +``` |
| 288 | + |
| 289 | +- Your network can reach OCI public endpoints |
| 290 | +- Private endpoints are reachable from your machine if using private networking |
| 291 | + |
| 292 | +## Recommended Tests |
| 293 | + |
| 294 | +Run the following tests in Cline: |
| 295 | + |
| 296 | +- Short coding task |
| 297 | +- Code explanation prompt |
| 298 | +- Refactoring prompt |
| 299 | +- Unit test generation prompt |
| 300 | +- Repository summarization prompt |
| 301 | + |
| 302 | +## Cleanup |
| 303 | + |
| 304 | +If this was only a test setup: |
| 305 | + |
| 306 | +1. Remove the API key from Cline |
| 307 | +2. Revoke or deactivate the OCI Generative AI API key |
| 308 | +3. If using a DAC-hosted model only for testing, delete the endpoint before deleting the Dedicated AI Cluster |
| 309 | + |
| 310 | +## OCI Services Used |
| 311 | + |
| 312 | +- **OCI Generative AI** - Model inference and endpoints |
| 313 | +- **OCI Generative AI Dedicated AI Clusters** - Dedicated hosting for deployed models |
| 314 | +- **OCI IAM** - Policies and authorization |
| 315 | +- **OCI Generative AI API Keys** - API key authentication |
| 316 | +- **Cline** - AI coding assistant in VS Code or PyCharm |
| 317 | + |
| 318 | +## References |
| 319 | + |
| 320 | +- [OCI Generative AI Documentation](https://docs.oracle.com/en-us/iaas/Content/generative-ai/home.htm) |
| 321 | +- [OCI Generative AI OpenAI-Compatible API](https://docs.oracle.com/en-us/iaas/Content/generative-ai/openai-compatible-api.htm) |
| 322 | +- [OCI Generative AI API Keys](https://docs.oracle.com/en-us/iaas/Content/generative-ai/api-keys.htm) |
| 323 | +- [Cline OpenAI Compatible Provider](https://docs.cline.bot/provider-config/openai-compatible) |
| 324 | + |
| 325 | +## License |
| 326 | + |
| 327 | +Copyright (c) 2026 Oracle and/or its affiliates. |
| 328 | + |
| 329 | +Licensed under the Universal Permissive License (UPL), Version 1.0. |
| 330 | + |
| 331 | +See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE.txt) for more details. |
0 commit comments