How to Generate Ad Copy With Cohere Command on Oracle Cloud
You already pay Oracle for compute. As of this year you don't need a separate Cohere account, API key, or billing relationship to use its best model, because Cohere Command A now runs natively inside OCI Generative AI. That means your marketing team's ad copy generator can live in the same tenancy, IAM policies, and invoice as everything else you run on Oracle Cloud.
By the end of this you'll have a Python script that calls Cohere Command on Oracle Cloud straight through your OCI credentials and returns a batch of on-brand ad variants in whatever languages your campaign needs.
1. Turn on Generative AI access in your OCI tenancy
Generative AI is a regional OCI service, and it isn't live in every region yet, so check Oracle's Models by Region page before you pick one. us-chicago-1 is a safe default since it's one of Oracle's primary Generative AI hubs.
Next, grant your marketing team's IAM group permission to call the model family. Oracle's own docs on limiting Generative AI access spell out the minimum policy:
Allow group <marketing-genai-group> to use generative-ai-family in compartment <marketing-compartment>
That's enough for on-demand inference. You don't need broader access unless you're also standing up a dedicated AI cluster.
2. Install the Cohere SDK with the OCI extra
Cohere ships an OCI-aware build of its own SDK so you don't have to hand-roll OCI request signing.
pip install "cohere[oci]"
This pulls in the standard cohere package plus the OCI authentication dependencies it needs to sign requests using your existing Oracle credentials.
3. Initialize a Command A client scoped to your compartment
Command A uses Cohere's newer V2 client. Point it at your region and compartment OCID:
import cohere
client = cohere.OciClientV2(
oci_region="us-chicago-1",
oci_compartment_id="ocid1.compartment.oc1..<your-compartment-ocid>",
)
By default this reads the same ~/.oci/config file the OCI CLI uses. If this script is going to run on a schedule from an OCI compute instance or function, switch to instance principal authentication instead, so you're not shipping a key file with the job.
4. Build a brand-safe prompt template
Don't let each marketer freehand a prompt. Wrap the brief in a function so tone, character limit, and call to action are always enforced the same way:
def build_messages(product, audience, tone, char_limit, cta, language="English"):
return [
{
"role": "system",
"content": (
f"You write {tone} ad copy for a paid social campaign. "
f"Every line must be under {char_limit} characters, end with a clear "
f"call to action, and be written in {language}."
),
},
{
"role": "user",
"content": (
f"Write 5 ad copy variants for {product}, targeting {audience}. "
f"Include the call to action: '{cta}'. Return each variant on its own "
f"line, numbered 1 to 5, no extra commentary."
),
},
]
5. Generate multilingual variants in one pass
Cohere built Command A to reason natively across roughly two dozen languages, which makes it a solid pick for markets you can't staff a copywriter for in every locale. Loop over the languages you're running campaigns in and raise the temperature slightly so the five variants don't read like near-duplicates:
languages = ["English", "Spanish", "German", "Japanese", "Arabic"]
for lang in languages:
messages = build_messages(
product="a 14-day free trial of Acme Analytics",
audience="B2B marketing managers",
tone="confident, no-fluff",
char_limit=90,
cta="Start your trial",
language=lang,
)
response = client.chat(
model="command-a-03-2025",
messages=messages,
temperature=0.8,
)
print(f"--- {lang} ---")
print(response.message.content[0].text.strip())
command-a-03-2025 is the model ID the SDK expects. OCI's own console lists it as cohere.command-a-03-2025, so if you're browsing the model catalog and wondering why your code doesn't match, that's why.
6. Enforce the character limit before it hits the ad platform
Models are enthusiastic, not obedient. Trim anything that sneaks past your limit rather than trusting the prompt alone:
def enforce_limit(variants, char_limit):
return [v for v in variants if len(v.split(". ", 1)[-1]) <= char_limit]
Run every batch through this before it goes anywhere near a campaign manager's upload sheet.
Gotchas
- On-demand output is capped at 4,000 tokens per call. That's plenty for ad copy batches, but if you fold long-form landing page copy into the same pipeline, you'll want a dedicated AI cluster instead, which removes the cap.
- Two client classes exist. Command A needs
OciClientV2and amessageslist. Older Command R models useOciClientwith a singlemessagestring. Mixing them up gives you a confusing type error, not a helpful one. - Model naming has two spellings. The OCI console shows
cohere.command-a-03-2025; the SDK'smodelparameter drops thecohere.prefix. - A permission error usually means a missing policy, not a bad key. If calls fail with an authorization error, check the
generative-ai-familypolicy before you start debugging your OCI config file.
Once this is wired into whatever schedules your campaign briefs, your team spends its time picking the best variant instead of staring at a blank doc, and that's the difference between a model demo and something you can actually put in front of a client's marketing calendar.