docs(mintlify): add SDK examples alongside curl - #669
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
📝 WalkthroughWalkthroughThe PR expands documentation examples across advanced APIs, features, guides, and providers. Existing cURL or Bash examples are grouped with equivalent Python and JavaScript client examples. ChangesAdvanced API examples
Feature API examples
Guide verification examples
Provider examples
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/guides/prometheus-metrics.mdx`:
- Around line 172-237: Update all six `/metrics` verification samples in the
Prometheus metrics guide to authenticate with the configured master key via
`GOMODEL_MASTER_KEY`: add the corresponding Authorization header to both curl
examples and use that key instead of `unused` in the Python and JavaScript
OpenAI client examples. Preserve the documented enabled metrics response and
disabled 404 behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 5771b3af-3c1f-4b1d-b9c8-237109af6295
📒 Files selected for processing (28)
docs/advanced/admin-endpoints.mdxdocs/advanced/anthropic-messages-api.mdxdocs/advanced/audio-api.mdxdocs/advanced/conversations-api.mdxdocs/advanced/responses-api.mdxdocs/advanced/usage-api.mdxdocs/advanced/workflows.mdxdocs/features/budgets.mdxdocs/features/labelling.mdxdocs/features/rate-limits.mdxdocs/features/user-path.mdxdocs/guides/claude-code.mdxdocs/guides/codex.mdxdocs/guides/openai-agents-sdk.mdxdocs/guides/openclaw.mdxdocs/guides/opencode-and-other-agents.mdxdocs/guides/prometheus-metrics.mdxdocs/providers/azure.mdxdocs/providers/bailian.mdxdocs/providers/bedrock-mantle.mdxdocs/providers/bedrock.mdxdocs/providers/cohere.mdxdocs/providers/llmd.mdxdocs/providers/minimax.mdxdocs/providers/multiple-ollama.mdxdocs/providers/oracle.mdxdocs/providers/sglang.mdxdocs/providers/vllm.mdx
| <CodeGroup> | ||
|
|
||
| ```bash curl | ||
| curl http://localhost:8080/metrics | ||
| # Returns Prometheus metrics in text format | ||
| ``` | ||
|
|
||
| ```python Python | ||
| from openai import OpenAI | ||
|
|
||
| client = OpenAI(base_url="http://localhost:8080", api_key="unused") | ||
| metrics = client.get("/metrics", cast_to=str) | ||
|
|
||
| print(metrics) | ||
| ``` | ||
|
|
||
| ```javascript JavaScript | ||
| import OpenAI from "openai"; | ||
|
|
||
| const client = new OpenAI({ | ||
| baseURL: "http://localhost:8080", | ||
| apiKey: "unused", | ||
| }); | ||
|
|
||
| const metrics = await client.get("/metrics"); | ||
| console.log(metrics); | ||
| ``` | ||
|
|
||
| </CodeGroup> | ||
|
|
||
| **When Disabled:** | ||
|
|
||
| ```bash | ||
| <CodeGroup> | ||
|
|
||
| ```bash curl | ||
| curl http://localhost:8080/metrics | ||
| # Returns 404 Not Found | ||
| ``` | ||
|
|
||
| ```python Python | ||
| from openai import NotFoundError, OpenAI | ||
|
|
||
| client = OpenAI(base_url="http://localhost:8080", api_key="unused") | ||
|
|
||
| try: | ||
| client.get("/metrics", cast_to=str) | ||
| except NotFoundError as error: | ||
| print(error.status_code) # 404 | ||
| ``` | ||
|
|
||
| ```javascript JavaScript | ||
| import OpenAI from "openai"; | ||
|
|
||
| const client = new OpenAI({ | ||
| baseURL: "http://localhost:8080", | ||
| apiKey: "unused", | ||
| }); | ||
|
|
||
| try { | ||
| await client.get("/metrics"); | ||
| } catch (error) { | ||
| console.log(error.status); // 404 | ||
| } | ||
| ``` | ||
|
|
||
| </CodeGroup> |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Authenticate every metrics verification request with the master key.
When a master key is configured, /metrics requires it. The curl samples omit the Authorization header. The SDK samples send Bearer unused. These requests return 401 instead of the documented metrics response or 404.
Use GOMODEL_MASTER_KEY in all six samples.
Proposed fix
-curl http://localhost:8080/metrics
+curl http://localhost:8080/metrics \
+ -H "Authorization: Bearer $GOMODEL_MASTER_KEY"
-from openai import OpenAI
+import os
+from openai import OpenAI
...
-client = OpenAI(base_url="http://localhost:8080", api_key="unused")
+client = OpenAI(
+ base_url="http://localhost:8080",
+ api_key=os.environ["GOMODEL_MASTER_KEY"],
+)
- apiKey: "unused",
+ apiKey: process.env.GOMODEL_MASTER_KEY,🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/guides/prometheus-metrics.mdx` around lines 172 - 237, Update all six
`/metrics` verification samples in the Prometheus metrics guide to authenticate
with the configured master key via `GOMODEL_MASTER_KEY`: add the corresponding
Authorization header to both curl examples and use that key instead of `unused`
in the Python and JavaScript OpenAI client examples. Preserve the documented
enabled metrics response and disabled 404 behavior.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Confidence Score: 5/5The documentation examples tested behave as documented and do not introduce a confirmed regression. The executed checks covered the primary copy-paste SDK paths and found no independent defects. Files Needing Attention: No changed file needs corrective action.
What T-Rex did
Reviews (1): Last reviewed commit: "docs(mintlify): add SDK examples alongsi..." | Re-trigger Greptile |
Summary
Validation
mint validatemint broken-linksSummary by CodeRabbit