<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Felix198902</title>
    <description>The latest articles on DEV Community by Felix198902 (@felix198902).</description>
    <link>https://dev.to/felix198902</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4183318%2Fe0af56b4-e859-4632-b705-d16b3ddf3c50.jpg</url>
      <title>DEV Community: Felix198902</title>
      <link>https://dev.to/felix198902</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/felix198902"/>
    <language>en</language>
    <item>
      <title>AI API acceptance checks: response, token usage and billing</title>
      <dc:creator>Felix198902</dc:creator>
      <pubDate>Sun, 25 Oct 2026 10:18:34 +0000</pubDate>
      <link>https://dev.to/felix198902/ai-api-acceptance-checks-response-token-usage-and-billing-5h36</link>
      <guid>https://dev.to/felix198902/ai-api-acceptance-checks-response-token-usage-and-billing-5h36</guid>
      <description>&lt;p&gt;This article was generated with AI from Xinghuo AI Gateway’s public integration guides. The publishing account is affiliated with the service operator. Xinghuo AI is an independent third-party service; model access, availability and prices depend on its current configuration.&lt;/p&gt;

&lt;p&gt;An HTTP 200 response is a useful first signal when connecting an AI client. It does not, by itself, tell you whether the client received the entire answer, whether usage was reported, or whether the bill matches the request. A small acceptance check should connect these pieces before the integration is used for larger jobs.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Confirm the destination and model
&lt;/h2&gt;

&lt;p&gt;Copy the API base address from the service’s own documentation and check its domain, protocol and path. Clients handle version prefixes differently: some append /v1 automatically, while others expect it in the configured base URL. A duplicated prefix can send an otherwise valid request to the wrong endpoint.&lt;/p&gt;

&lt;p&gt;Use a model ID from the directory available to the current account. A model mentioned in a tutorial or on a marketing page may not be enabled for the selected key or group. Keep the API key in your client or environment, and remove credentials and personal data from shared screenshots and logs.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Start with one small, non-sensitive request
&lt;/h2&gt;

&lt;p&gt;Use a short prompt such as “Reply only: connection test successful” and a modest output limit. Save the request time, requested model ID, status code and request identifier, then inspect the actual text and finish reason.&lt;/p&gt;

&lt;p&gt;An empty or unexpectedly short answer needs further investigation. Check the response structure and client logs before attributing the result to model capability or a service limitation. This article does not report a new paid generation test or certify the current availability of any model.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Verify that a stream really finished
&lt;/h2&gt;

&lt;p&gt;The first visible text fragment is not the same as a completed generation. Confirm that the connection ended normally and that the client handled the final events and finish information.&lt;/p&gt;

&lt;p&gt;Some endpoints report usage only in a final chunk; some calls do not provide a complete usage report. Treat a missing usage field as unavailable, rather than as zero. Use the service’s records and documented accounting rules when reconciling the charge.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Match the call to usage and billing records
&lt;/h2&gt;

&lt;p&gt;Find the request within the appropriate time window. Compare input tokens, output tokens, cache-related fields, the applicable model price and any group multiplier. Establish whether the fields overlap and whether a multiplier has already been applied before adding amounts together.&lt;/p&gt;

&lt;p&gt;If a client estimate differs from a billed amount, first check the model, reporting window, cache treatment and price configuration. A single total-token figure is not enough to reproduce every billing rule. When asking the operator to investigate, provide a redacted request identifier instead of a full conversation or API key.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reproduce the token calculation locally
&lt;/h3&gt;

&lt;p&gt;The free &lt;a href="https://jiaye-apple.github.io/xinghuo-ai-examples/en/" rel="noopener noreferrer"&gt;Token Cost Worksheet&lt;/a&gt; runs in the page without an API key or a model call. Enter mutually exclusive uncached-input, cached-input and output counts, then your current rates, billing unit and account multiplier. Export JSON to retain the values you checked.&lt;/p&gt;

&lt;p&gt;For a hypothetical teaching example, use 1,000 uncached input, 200 cached input and 100 output tokens, assumed per-million rates of USD 2, 0.20 and 8, and multiplier 1.5. The base cost is USD 0.00284 and the illustrative estimate is USD 0.00426. These are not current service prices. Actual billing may include other items and rounding rules. If total input already includes cached input, split it under the provider's definition before entering it. The worksheet is free; API generation is billed separately under the current account rules.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Investigate a timeout before retrying
&lt;/h2&gt;

&lt;p&gt;A client timeout does not prove that the server abandoned the request. Retrying immediately can produce a second result and, depending on what completed, another charge. Check request status and usage records before sending the same job again.&lt;/p&gt;

&lt;p&gt;Use an idempotency mechanism only when the endpoint explicitly documents one. At the application layer, keep retries bounded, apply backoff, and distinguish waiting, failed and completed states for the user.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Keep a compact acceptance record
&lt;/h2&gt;

&lt;p&gt;Record the client version, API prefix, model ID, request time, request identifier, final response state and matching usage or billing result. Exclude secrets, original private conversations and personal information from public records.&lt;/p&gt;

&lt;p&gt;For 401, 404 and 429 responses, read the service-specific error details. Credentials or permissions, endpoint paths or model names, and rate or quota limits are useful areas to investigate, but the same HTTP status can have different causes across services.&lt;/p&gt;

&lt;p&gt;This record cannot guarantee future calls. It does make configuration problems, client display issues and operator-side investigations easier to distinguish.&lt;/p&gt;

&lt;h2&gt;
  
  
  Public resources
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://ai.wfpromax.xyz/guides/en/api-verification.html?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=api_verification_en" rel="noopener noreferrer"&gt;English API verification guide&lt;/a&gt; provides the reference checklist. The &lt;a href="https://github.com/Jiaye-apple/xinghuo-ai-examples/blob/main/README.en.md" rel="noopener noreferrer"&gt;English GitHub examples&lt;/a&gt; show request formats and local dry-run options. For available client packages, use the &lt;a href="https://ai.wfpromax.xyz/downloads?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=api_verification_en" rel="noopener noreferrer"&gt;official downloads and configuration page&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>api</category>
      <category>ai</category>
    </item>
    <item>
      <title>AI API 调用验收：从 HTTP 200 到 Token 用量与扣费核对</title>
      <dc:creator>Felix198902</dc:creator>
      <pubDate>Sun, 25 Oct 2026 09:13:22 +0000</pubDate>
      <link>https://dev.to/felix198902/ai-api-diao-yong-yan-shou-cong-http-200-dao-token-yong-liang-yu-kou-fei-he-dui-3p11</link>
      <guid>https://dev.to/felix198902/ai-api-diao-yong-yan-shou-cong-http-200-dao-token-yong-liang-yu-kou-fei-he-dui-3p11</guid>
      <description>&lt;p&gt;接入 AI API 时，一次 HTTP 200 只能说明请求收到了成功状态。准备把调用放进业务之前，还需要分别检查模型权限、实际回答、结束原因、Token 用量和账户扣费。&lt;/p&gt;

&lt;p&gt;本文由星火AI 智能网关维护方发布，使用 AI 辅助撰写，示例用于说明自己的服务，不是独立测评。星火AI 是第三方网关，与模型厂商无官方隶属关系。&lt;/p&gt;

&lt;h2&gt;
  
  
  1. 先把客户端地址和密钥来源对齐
&lt;/h2&gt;

&lt;p&gt;OpenAI 兼容客户端的 Base URL 是带版本的前缀。以星火AI 为例：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://ai.wfpromax.xyz/v1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;完整 Chat Completions 地址则是 /v1/chat/completions。不要在客户端已经补上 /v1 时再重复填写，也不要把其他服务的密钥当作本站密钥。&lt;/p&gt;

&lt;h2&gt;
  
  
  2. 离线检查请求，再查询准确模型 ID
&lt;/h2&gt;

&lt;p&gt;我们维护的 &lt;a href="https://github.com/Jiaye-apple/xinghuo-ai-examples" rel="noopener noreferrer"&gt;Python 示例&lt;/a&gt;只使用 Python 标准库。先阅读 example.py，再执行离线预览：&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 example.py chat &lt;span class="nt"&gt;--model&lt;/span&gt; YOUR_MODEL_ID &lt;span class="nt"&gt;--dry-run&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;这个步骤不发送网络请求。正式连接时，把自己的密钥放在本机环境变量中，运行 models 子命令，选择返回列表里当前密钥有权使用的准确模型 ID。模型列表可见与实际生成成功需要分开验证。&lt;/p&gt;

&lt;h2&gt;
  
  
  3. 先发一条短请求
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 example.py chat &lt;span class="nt"&gt;--model&lt;/span&gt; YOUR_MODEL_ID &lt;span class="nt"&gt;--prompt&lt;/span&gt; &lt;span class="s1"&gt;'只回复你好'&lt;/span&gt; &lt;span class="nt"&gt;--max-tokens&lt;/span&gt; 32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;生成可能产生费用。max_tokens 是否适用取决于模型；参数不兼容时先核对接口说明。示例不自动重试，避免把排查放大成连续请求。&lt;/p&gt;

&lt;h2&gt;
  
  
  4. 保存五项可核对的结果
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;项目&lt;/th&gt;
&lt;th&gt;要检查的内容&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;实际回答&lt;/td&gt;
&lt;td&gt;是否符合这次任务，而非只有成功状态&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;结束原因&lt;/td&gt;
&lt;td&gt;是否正常结束，是否因输出限制截断&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Token 用量&lt;/td&gt;
&lt;td&gt;输入、输出及缓存字段是否存在，统计口径是什么&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;请求记录&lt;/td&gt;
&lt;td&gt;时间、模型 ID 和脱敏请求标识能否对应&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;账户扣费&lt;/td&gt;
&lt;td&gt;记录中的计费单位、分组倍率及实际金额是否一致&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;有效成本需要结合输入、输出、缓存单价、计费单位和账户倍率计算。不能只看折扣数字，也不能用接口返回的模型名独立证明上游身份。&lt;/p&gt;

&lt;h3&gt;
  
  
  用免费工具复算这一笔费用
&lt;/h3&gt;

&lt;p&gt;可以打开我们维护的&lt;a href="https://jiaye-apple.github.io/xinghuo-ai-examples/" rel="noopener noreferrer"&gt;Token 费用复算工具&lt;/a&gt;。它在页面本地计算，无需 API Key，不调用模型，并支持导出 JSON 核对记录。输入非缓存输入、缓存输入与输出这三类互不重叠的用量，再填写自己当前的单价、计费单位和账户倍率。&lt;/p&gt;

&lt;p&gt;教学假设：非缓存输入 1,000、缓存输入 200、输出 100 Token；每百万 Token 单价假设为 2、0.20、8 美元，倍率 1.5，则基础费用为 0.00284 美元，估算为 0.00426 美元。这些是演示数值，不是当前报价；真实账单还可能涉及其他项目与舍入规则。如果输入总数已包含缓存用量，应先按服务商定义拆分，避免重复相加。工具免费，API 生成调用另按当前账户规则计费。&lt;/p&gt;

&lt;h2&gt;
  
  
  5. 超时后先查用量，复杂能力单独测
&lt;/h2&gt;

&lt;p&gt;超时不代表上游没有执行，也不代表没有产生费用。先查用量记录，再决定是否重试。需要流式输出、工具调用或其他协议时，用实际业务样例单独验收；一条普通聊天请求不能证明这些能力都可用。&lt;/p&gt;

&lt;p&gt;常见状态可以按以下顺序排查：401 检查密钥，403 检查权限，404 检查路径与模型 ID，429 检查频率和配额，502/503 保存时间与脱敏请求标识再定位可用性问题。&lt;/p&gt;

&lt;p&gt;完整步骤见&lt;a href="https://ai.wfpromax.xyz/guides/api-verification.html?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=api_verification" rel="noopener noreferrer"&gt;官网调用验收指南&lt;/a&gt;。使用桌面客户端或插件可从&lt;a href="https://ai.wfpromax.xyz/downloads?utm_source=devto&amp;amp;utm_medium=referral&amp;amp;utm_campaign=api_verification" rel="noopener noreferrer"&gt;下载与接入页&lt;/a&gt;进入。&lt;/p&gt;

&lt;p&gt;一次验收只能代表相应时间、网络和任务下的观察。模型权限、价格和可用性以当前目录与账户配置为准。公开反馈请脱敏，勿上传 API Key、私人提示词或订单资料。&lt;/p&gt;

</description>
      <category>api</category>
      <category>ai</category>
    </item>
    <item>
      <title>OpenRouter alternatives: choosing an AI API relay or self-hosted gateway</title>
      <dc:creator>Felix198902</dc:creator>
      <pubDate>Wed, 14 Oct 2026 01:03:53 +0000</pubDate>
      <link>https://dev.to/felix198902/openrouter-alternatives-choosing-an-ai-api-relay-or-self-hosted-gateway-4gah</link>
      <guid>https://dev.to/felix198902/openrouter-alternatives-choosing-an-ai-api-relay-or-self-hosted-gateway-4gah</guid>
      <description>&lt;p&gt;Written by the operator of Xinghuo AI Gateway. This is a comparison of deployment choices and verification steps, not an independent ranking or benchmark. Sources were checked on October 14, 2026. Check each provider for current models, pricing and policies. &lt;a href="https://ai.wfpromax.xyz/guides/ai-api-relay-selection.html" rel="noopener noreferrer"&gt;中文版&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is an AI API relay?
&lt;/h2&gt;

&lt;p&gt;An AI API relay is a third-party service between your application and upstream model endpoints. It can handle authentication, request forwarding, protocol adaptation and usage accounting. An LLM gateway is a broader category that also includes software you deploy and operate yourself. A hosted model aggregator, a hosted relay and a self-hosted gateway have different operational responsibilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparing OpenRouter, a self-hosted gateway and Xinghuo AI
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Documented role&lt;/th&gt;
&lt;th&gt;Check before choosing&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;OpenRouter&lt;/td&gt;
&lt;td&gt;A unified API for multiple models. Its &lt;a href="https://openrouter.ai/docs/quickstart" rel="noopener noreferrer"&gt;official quickstart&lt;/a&gt; provides API and SDK examples.&lt;/td&gt;
&lt;td&gt;Your model and routing needs, account and regional eligibility, payment terms, actual cost and required features.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Self-hosted LiteLLM&lt;/td&gt;
&lt;td&gt;The &lt;a href="https://docs.litellm.ai/docs/simple_proxy" rel="noopener noreferrer"&gt;official gateway guide&lt;/a&gt; describes a self-hosted server with virtual keys, budgets and usage tracking.&lt;/td&gt;
&lt;td&gt;Upstream access, deployment, updates, monitoring, the selected version and its license. Installing gateway software does not provide model credits.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Xinghuo AI Gateway&lt;/td&gt;
&lt;td&gt;An independent hosted third-party API relay for applications, scripts and compatible clients. See our &lt;a href="https://ai.wfpromax.xyz/service-info.html" rel="noopener noreferrer"&gt;service identity&lt;/a&gt; and &lt;a href="https://ai.wfpromax.xyz/available-channels" rel="noopener noreferrer"&gt;live model catalog&lt;/a&gt;.&lt;/td&gt;
&lt;td&gt;Site-issued key permissions, account groups, model access, context and parameter support, token rates and usage records.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For an OpenRouter alternative, first decide which responsibility you want to change. Compare hosted services if you want a managed access point. Evaluate self-hosting if you need control over deployment and upstream credentials. Direct provider access is also an option when it meets your requirements. This table does not establish a price, latency or reliability winner.&lt;/p&gt;

&lt;h2&gt;
  
  
  How should you compare token costs?
&lt;/h2&gt;

&lt;p&gt;Use the same model, context tier and bounded workload. Separate input, output, cache-read and cache-write usage and rates. For rates quoted per million tokens, divide each category by one million, multiply by its rate, and add the results. Apply group and currency conversions only as documented; do not apply a multiplier twice if it is already included in displayed rates.&lt;/p&gt;

&lt;p&gt;Reconcile the estimate with the actual account charge. Credit bonuses, balance display units and model prices are different facts. A discount does not establish cache behavior. Read our &lt;a href="https://ai.wfpromax.xyz/guides/en/token-billing.html" rel="noopener noreferrer"&gt;token billing guide&lt;/a&gt; for the verification steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does OpenAI-compatible mean every client will work?
&lt;/h2&gt;

&lt;p&gt;No. Chat Completions, Responses and Anthropic Messages are different interfaces. Streaming, tools and model-specific parameters need separate verification. A successful model-list request does not prove that generation or every listed model will work.&lt;/p&gt;

&lt;p&gt;For Xinghuo AI, the OpenAI-compatible base URL is &lt;code&gt;https://ai.wfpromax.xyz/v1&lt;/code&gt;. Claude Code uses the root URL &lt;code&gt;https://ai.wfpromax.xyz&lt;/code&gt;; follow the &lt;a href="https://ai.wfpromax.xyz/guides/en/claude-code.html" rel="noopener noreferrer"&gt;Claude Code guide&lt;/a&gt;. Use a key issued by this service and avoid adding &lt;code&gt;/v1&lt;/code&gt; twice.&lt;/p&gt;

&lt;h2&gt;
  
  
  A bounded acceptance check
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Confirm the domain, service identity, support and purchase terms.&lt;/li&gt;
&lt;li&gt;Inspect the request offline with the example's &lt;code&gt;--dry-run&lt;/code&gt; option.&lt;/li&gt;
&lt;li&gt;List models using your own key, then send one short request to an exact model ID. Generation may incur charges.&lt;/li&gt;
&lt;li&gt;Check the answer, finish reason, time, usage and matching account charge. Test streaming or tools separately if needed.&lt;/li&gt;
&lt;li&gt;Record the network, workload and observation window. After a timeout, check usage before retrying.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Our &lt;a href="https://github.com/Jiaye-apple/xinghuo-ai-examples" rel="noopener noreferrer"&gt;public Python examples&lt;/a&gt; use the standard library and do not retry automatically. The &lt;a href="https://ai.wfpromax.xyz/guides/en/api-verification.html" rel="noopener noreferrer"&gt;API verification guide&lt;/a&gt; explains how to evaluate the resulting evidence.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does a model name prove its upstream identity?
&lt;/h3&gt;

&lt;p&gt;No. A returned model ID or an answer claiming to be a particular model is not independent proof. Check documented sourcing and relevant evidence; keep unsupported claims unknown.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do rankings establish long-term reliability?
&lt;/h3&gt;

&lt;p&gt;Check authorship, commercial relationships, sample size, observation window and failure definitions. An operator's article and an independent user's report are different sources. One successful request is not an uptime measurement.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is this iFlytek Spark or an official model provider?
&lt;/h3&gt;

&lt;p&gt;No. Xinghuo AI Gateway here means &lt;code&gt;ai.wfpromax.xyz&lt;/code&gt;. It is distinct from iFlytek Spark and is not the official website of OpenAI, Anthropic or Google.&lt;/p&gt;

&lt;h3&gt;
  
  
  Are API credits a ChatGPT or Claude subscription?
&lt;/h3&gt;

&lt;p&gt;No. Credits are for programmatic access and compatible clients. They do not grant another provider's web subscription. See &lt;a href="https://ai.wfpromax.xyz/guides/en/api-vs-subscription.html" rel="noopener noreferrer"&gt;API credits versus subscriptions&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Source and disclosure
&lt;/h2&gt;

&lt;p&gt;Originally published in the &lt;a href="https://ai.wfpromax.xyz/guides/en/ai-api-relay-selection.html" rel="noopener noreferrer"&gt;Xinghuo AI developer guides&lt;/a&gt;. This article was prepared by an AI agent on behalf of the service maintainer; it is not an independent product review.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>llm</category>
    </item>
  </channel>
</rss>
