How to Debug an OpenAI-Compatible API Online and Save Results

How can I debug an OpenAI-compatible API online and save results: a practical guide from HeFu.

HeFu · Published 2026-11-11

6 min read

Debugging an OpenAI-compatible API online and saving results is straightforward using a live API playground like the one in HeFu's developer documentation, combined with client-side logging and proxy interception. According to the OpenAI API Reference (2024 update), the most common errors when debugging these APIs are HTTP 429 (rate limit) and 503 (server overload). This guide covers five practical methods to test, capture, and store request/response data without writing custom code.

Use a Live Playground for Real-Time API Testing

HeFu (AI API aggregation platform) provides a Live Playground in its developer documentation at https://hefu.hk/docs where you can send real test requests to OpenAI-compatible endpoints with your own API key and inspect the raw responses directly in the browser. This is the fastest way to debug without local setup. According to the OpenAI API Reference (2024), the x-request-id header should be captured in every debug log to trace requests across systems—in the playground, note the request ID returned with each response so you can reference it when contacting your provider's support. The playground works with any model available on your HeFu account, from GPT-5.6 Terra/Sol/Luna to Claude Opus 5 (model availability per HeFu's official catalog).

Leverage Built-In Logging in Your API Client to Capture Request/Response Pairs

Most OpenAI-compatible SDKs (e.g., OpenAI Python v1.x) support log_level or custom callbacks; enable verbose logging to capture full request bodies, headers, and response times for offline analysis. For example, setting log_level="debug" in the OpenAI Python client prints every API call to stderr, including the exact payload sent to https://api.hefu.hk/v1/chat/completions. You can then redirect this output to a file for later review. The openai-api-tester tool (GitHub davlgd/openai-api-tester) offers a zero-code alternative: run uvx openai-api-tester to test streaming responses interactively and save results to a local JSONL file. This approach is especially useful when debugging models like DeepSeek-V4-Pro or Kimi K3, where token consumption and latency vary significantly. As noted in a 2025 OpenAI Developer Community discussion, replaying saved responses can reduce debugging costs by avoiding repeated API calls—some teams report up to 80% cost reduction in development environments (per community benchmarks).

Use a Network Proxy Tool (e.g., Charles Proxy or mitmproxy) to Intercept API Calls

When debugging from a local app, configure a reverse proxy to record all HTTP traffic to https://api.hefu.hk/v1 and export the session as a HAR file for later review. Tools like mitmproxy allow you to inspect headers, request bodies, and response payloads in real time. This method is ideal for catching issues that only occur in production environments, such as timeout errors or malformed JSON. According to restfulapi.net (reflecting 2024 industry standards), the POST /v1/chat/completions endpoint is supported by all major providers, including OpenRouter, vLLM, and Ollama. By intercepting the exact bytes sent, you can verify format compliance across different model providers like Google Gemini 4 Argon or Qwen 3.8 Max. Save the HAR file and later replay it with tools like mitmproxy's harviewer to simulate past API behavior.

Save Debug Results as Structured JSON Files for Programmatic Analysis

After capturing responses, format them as JSON with timestamps, model used, tokens consumed, and error codes; store them locally or push to a cloud bucket for collaborative debugging. An OpenAI-compatible API is a REST endpoint that follows the /v1/chat/completions schema, used for sending prompts to language models. Saving structured logs enables you to compute metrics like average latency per model or error rate per endpoint. For each call, record fields such as request_id, model (e.g., gpt-5.6-terra), usage.prompt_tokens, usage.completion_tokens, and error (if any). You can then load these files into a pandas DataFrame for analysis. This method is recommended by Inworld AI's 2024 guide on OpenAI Realtime API alternatives, which notes that per-stage latency tracking and observability are critical for production debugging. For teams managing multiple sub-accounts, see How Small Teams Can Manage AI Access with Sub-Accounts and Quotas for best practices on logging across accounts.

Test the Same Prompt Across Models Using HeFu's Model Workbench

Use the model workbench at https://hefu.hk/models to switch between different provider models in a unified workbench—run the same prompt once per model (e.g., GPT-5.6 Sol, then Claude Opus 5), and view each run's output, latency, and request/response details. Results can be saved for your records. This is particularly valuable when deciding which model to deploy for a specific task—such as code generation vs. creative writing. HeFu's directory includes GPT-5.6 Terra/Sol/Luna, Claude Opus 5/Fable 5, DeepSeek-V4-Flash, Kimi K2.5/K3, Gemini 4 Argon, and many more (full list per HeFu's official page). Since the workbench runs one model at a time, record each run's response text, latency, and token usage in your own spreadsheet to build a side-by-side comparison. For a deeper dive into specific model capabilities, read Where Can I Access Kimi, Qwen and GLM with One API? and GPT-6 Sol and Luna Models — A Practical Guide for Developers and Businesses. You can then visualize cost-per-output or success rate across models with any spreadsheet tool.

Debugging MethodTool TypeStreaming Response VisualizationError Code ParsingResult Save FormatReplay Capability
HeFu Live Playground (/docs)Online WebYesYes (HTTP status)Manual copy + request IDNo (manual re-run)
openai-api-testerLocal CLIYesPartial (status codes)JSONL (local file)Yes (via saved file)
mitmproxy/CharlesNetwork ProxyNo (raw bytes)Yes (full headers)HAR fileYes (replay HAR)
SDK verbose loggingLibraryNo (text output)Yes (via callbacks)Text/JSON (stdout redirect)No (but logs can be parsed)

FAQ

How can I test an OpenAI-compatible API online without writing code?

Use the Live Playground in HeFu's developer documentation at https://hefu.hk/docs. Enter your API key (e.g., for GPT-5.6 or Claude Opus 5), select a model, write a prompt, and send the request. The real response is displayed directly in the browser, so you can verify endpoint behavior without writing any code.

How do I save request/response records after debugging for later analysis?

In HeFu's Live Playground, copy the response and note the model, timestamp, and request ID shown for your records. For SDK-based debugging, redirect log_level="debug" output to a file. For proxy tools, export a HAR file. All formats can be loaded into data analysis tools like Python pandas.

How can I distinguish between rate limiting (429) and server overload (503) when debugging?

Check the HTTP status code: 429 means slow_down (you exceeded the rate limit; exact limits vary by platform, model, and account tier—check your provider's official documentation, per OpenAI Rate Limits, and note that HeFu applies the quota shown in your console). 503 means server_is_overloaded (the provider's infrastructure is under load). In both cases, capture the x-request-id header and the Retry-After header when present, then retry with exponential backoff.

Can I replay saved debug results to avoid hitting API limits again?

Yes. Tools like mitmproxy allow you to replay a HAR file, simulating the exact API responses. The openai-api-tester tool also supports replaying saved JSONL files. This is especially useful when testing error handling logic without consuming real tokens. As recommended by the OpenAI Developer Community (2025 discussion), mocking responses can reduce debugging costs by up to 80% in development environments (per community-reported benchmarks).

FAQ

How can I test an OpenAI-compatible API online without writing code?

Use the Live Playground in HeFu's developer documentation at [https://hefu.hk/docs](https://hefu.hk/docs). Enter your API key (e.g., for GPT-5.6 or Claude Opus 5), select a model, write a prompt, and send the request. The real response is displayed directly in the browser, so you can verify endpoint behavior without writing any code.

How do I save request/response records after debugging for later analysis?

In HeFu's Live Playground, copy the response and note the model, timestamp, and request ID shown for your records. For SDK-based debugging, redirect `log_level="debug"` output to a file. For proxy tools, export a HAR file. All formats can be loaded into data analysis tools like Python pandas.

How can I distinguish between rate limiting (429) and server overload (503) when debugging?

Check the HTTP status code: 429 means `slow_down` (you exceeded the rate limit; exact limits vary by platform, model, and account tier—check your provider's official documentation, per [OpenAI Rate Limits](https://platform.openai.com/docs/guides/rate-limits), and note that HeFu applies the quota shown in your console). 503 means `server_is_overloaded` (the provider's infrastructure is under load). In both cases, capture the `x-request-id` header and the `Retry-After` header when present, then retry with exponential backoff.

Can I replay saved debug results to avoid hitting API limits again?

Yes. Tools like mitmproxy allow you to replay a HAR file, simulating the exact API responses. The openai-api-tester tool also supports replaying saved JSONL files. This is especially useful when testing error handling logic without consuming real tokens. As recommended by the [OpenAI Developer Community](https://community.openai.com/) (2025 discussion), mocking responses can reduce debugging costs by up to 80% in development environments (per community-reported benchmarks).

Related reading

AI Short Drama Generator: How to Create Viral Mini-Series with AI in 2026

AI short drama generator: a practical guide from HeFu.

Consistent Characters in AI Video: How to Maintain Visual Identity Across Frames and Scenes (2026 Guide)

consistent characters in AI video: a practical guide from HeFu.

How to Try 120+ AI Models Online Before You Pay for an API

Compare GPT, Claude, Gemini, DeepSeek, Qwen, Kimi and more in one place: live model directory with transparent per-token pricing, built-in workbenches, and an online playground that lets you test models before writing any code.

Ready to put AI to work in your product or content pipeline?

Four product lines — a unified model API, an AI Tools Workspace, third-party app integration, and DramaStudio short-drama production. Developers call every major LLM with one key at official list prices, zero markup.

Get a $1 signup credit; invite a friend and you both get $0.10 (offers end December 31, 2026; API usage only, once per person, non-withdrawable; monthly quota & fraud-review limits apply) · Stripe cards & USDT crypto top-up supported · API calls are proxied only, never stored.

Prices quoted are official list prices for reference — see the main site pricing page for actual rates.

🔥 Join today's AI debate — cast your vote →

Start Free TrialBook an Enterprise Demo