feat(examples): add Dedalus Labs and Cloudflare AI Gateway examples#508
Merged
richardsolomou merged 4 commits intomainfrom Apr 16, 2026
Merged
feat(examples): add Dedalus Labs and Cloudflare AI Gateway examples#508richardsolomou merged 4 commits intomainfrom
richardsolomou merged 4 commits intomainfrom
Conversation
Contributor
Prompt To Fix All With AIThis is a comment left during a code review.
Path: examples/example-ai-dedalus/chat.py
Line: 36
Comment:
**Likely copy-paste model name from Cloudflare example**
Dedalus Labs is a direct OpenAI-compatible gateway, so the `openai/` provider prefix in `"openai/gpt-5-mini"` is almost certainly a copy-paste from the Cloudflare `compat` endpoint (which _requires_ a provider prefix to route across multiple providers). All other OpenAI-compatible gateway examples in this repo (Helicone, Vercel) use bare model names like `"gpt-5-mini"`. Unless Dedalus Labs explicitly requires this prefix, this should match the standard pattern.
```suggestion
model="gpt-5-mini",
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: examples/example-ai-cloudflare-ai-gateway/README.md
Line: 14
Comment:
**`POSTHOG_API_KEY` missing from required-vars list**
The code uses `os.environ["POSTHOG_API_KEY"]` (hard key lookup, not `get`), so it will raise a `KeyError` if unset. The README currently lists only the Cloudflare-specific keys as required, leaving users to discover the missing PostHog key at runtime.
```suggestion
`POSTHOG_API_KEY`, `CLOUDFLARE_ACCOUNT_ID`, `CLOUDFLARE_GATEWAY_ID`, and `OPENAI_API_KEY` are required.
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "feat(examples): add Dedalus Labs and Clo..." | Re-trigger Greptile |
Contributor
posthog-python Compliance ReportDate: 2026-04-16 10:35:35 UTC
|
| Test | Status | Duration |
|---|---|---|
| Format Validation.Event Has Required Fields | ✅ | 517ms |
| Format Validation.Event Has Uuid | ✅ | 1507ms |
| Format Validation.Event Has Lib Properties | ✅ | 1507ms |
| Format Validation.Distinct Id Is String | ✅ | 1507ms |
| Format Validation.Token Is Present | ✅ | 1507ms |
| Format Validation.Custom Properties Preserved | ✅ | 1507ms |
| Format Validation.Event Has Timestamp | ✅ | 1507ms |
| Retry Behavior.Retries On 503 | ✅ | 9519ms |
| Retry Behavior.Does Not Retry On 400 | ✅ | 3506ms |
| Retry Behavior.Does Not Retry On 401 | ✅ | 3508ms |
| Retry Behavior.Respects Retry After Header | ✅ | 9510ms |
| Retry Behavior.Implements Backoff | ✅ | 23531ms |
| Retry Behavior.Retries On 500 | ✅ | 7508ms |
| Retry Behavior.Retries On 502 | ✅ | 7511ms |
| Retry Behavior.Retries On 504 | ✅ | 7513ms |
| Retry Behavior.Max Retries Respected | ✅ | 23524ms |
| Deduplication.Generates Unique Uuids | ✅ | 1502ms |
| Deduplication.Preserves Uuid On Retry | ✅ | 7510ms |
| Deduplication.Preserves Uuid And Timestamp On Retry | ✅ | 14524ms |
| Deduplication.Preserves Uuid And Timestamp On Batch Retry | ✅ | 7509ms |
| Deduplication.No Duplicate Events In Batch | ✅ | 1503ms |
| Deduplication.Different Events Have Different Uuids | ✅ | 1508ms |
| Compression.Sends Gzip When Enabled | ✅ | 1507ms |
| Batch Format.Uses Proper Batch Structure | ✅ | 1507ms |
| Batch Format.Flush With No Events Sends Nothing | ✅ | 1005ms |
| Batch Format.Multiple Events Batched Together | ✅ | 1505ms |
| Error Handling.Does Not Retry On 403 | ✅ | 3507ms |
| Error Handling.Does Not Retry On 413 | ✅ | 3509ms |
| Error Handling.Retries On 408 | ✅ | 7510ms |
Feature_Flags Tests
View Details
| Test | Status | Duration |
|---|---|---|
| Request Payload.Request With Person Properties Device Id | ❌ | 505ms |
Failures
request_payload.request_with_person_properties_device_id
404, message='NOT FOUND', url='http://sdk-adapter:8080/get_feature_flag'
This was referenced Apr 15, 2026
Merged
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
9d18d8f to
b738fd9
Compare
d894c81 to
3da5dfa
Compare
3da5dfa to
f65a99c
Compare
marandaneto
approved these changes
Apr 15, 2026
andrewm4894
approved these changes
Apr 15, 2026
…way auth The gateway requires the upstream provider key as the main API key and the CF AI Gateway token via the cf-aig-authorization header.
5da0473 to
b54d0fc
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
We don't have runnable examples for tracking Dedalus Labs or Cloudflare AI Gateway traffic in PostHog. Both expose OpenAI-compatible endpoints, so they slot into the existing OpenTelemetry auto-instrumentation pattern we already use for OpenRouter.
Changes
Two new examples under
examples/:example-ai-dedalus— OpenAI SDK pointed athttps://api.dedaluslabs.ai/v1,DEDALUS_API_KEY, models asprovider/model-id(e.g.openai/gpt-5-mini).example-ai-cloudflare-ai-gateway— OpenAI SDK pointed at thecompatendpoint (https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/compat), upstream provider API key withcf-aig-authorizationheader for gateway auth,provider/model-idformat.Both follow the same structure as the existing OTel examples (
chat.py,pyproject.toml,README.md,uv.toml,uv.lock,.env.example) and stream spans throughPostHogSpanProcessorviaOpenAIInstrumentor.Stacked on #482.
How did you test this code?
Ran the Node.js Cloudflare AI Gateway example end-to-end against a real PostHog project and confirmed
$ai_generationevents land. The Python example follows the same pattern. To verify: