Compatible is not identical
Every provider implements the chat completions route; fewer implement everything around it. Groq documents that logprobs, logit_bias and n above 1 are not supported. Cloudflare Workers AI offers chat completions and embeddings on its compatible endpoint. If your app uses tool calling, JSON mode or streaming, test those on the model you picked, because support is per model.
Put three values in configuration
The base URL, the model id and the key are what change between providers. With those three outside the code, moving from one free tier to another, or to a paid tier when the free one ends, is a configuration change.
Cloudflare’s URL contains your account
The Workers AI base URL includes the account id, so it is different for every user. Replace {account_id} with the id shown in your dashboard, and authenticate with an API token.
Model ids are not portable
The same open model has a different id on each provider: openai/gpt-oss-120b on Groq and gpt-oss-120b on Cerebras. Keep the id next to the base URL.