<?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: Alex</title>
    <description>The latest articles on DEV Community by Alex (@alex_martllm).</description>
    <link>https://dev.to/alex_martllm</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%2F4253280%2Fbc9d6784-76cc-4c8d-8f53-dcb95f67b602.png</url>
      <title>DEV Community: Alex</title>
      <link>https://dev.to/alex_martllm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alex_martllm"/>
    <language>en</language>
    <item>
      <title>One OpenAI-compatible key for Claude, Gemini, DeepSeek, GLM and Kimi: the base_url swap, and what still differs</title>
      <dc:creator>Alex</dc:creator>
      <pubDate>Sat, 28 Nov 2026 04:35:05 +0000</pubDate>
      <link>https://dev.to/alex_martllm/one-openai-compatible-key-for-claude-gemini-deepseek-glm-and-kimi-the-baseurl-swap-and-what-138o</link>
      <guid>https://dev.to/alex_martllm/one-openai-compatible-key-for-claude-gemini-deepseek-glm-and-kimi-the-baseurl-swap-and-what-138o</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclosure: I'm Alex, and I run MartLLM, the endpoint in these examples. The &lt;code&gt;base_url&lt;/code&gt; pattern works with any OpenAI-compatible gateway. The routing fields near the end are MartLLM's own.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Most LLM code in production is written against the OpenAI Python or TypeScript SDK, even when the model isn't OpenAI's. The SDK is good, the wire format is everywhere, and every framework (LangChain, LlamaIndex, LiteLLM, the Vercel AI SDK, Pydantic AI) can talk to it. So the cheapest way to try Claude, Gemini or DeepSeek in an existing codebase usually isn't a new SDK. It's a different &lt;code&gt;base_url&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This post shows that swap against one endpoint that serves all of them, then covers the parts that don't carry over cleanly.&lt;/p&gt;

&lt;h2&gt;
  
  
  The swap
&lt;/h2&gt;

&lt;p&gt;MartLLM implements the OpenAI Chat Completions API at &lt;code&gt;https://api.martllm.com/v1&lt;/code&gt;. The &lt;a href="https://martllm.com/docs/openai-sdk" rel="noopener noreferrer"&gt;OpenAI SDK guide&lt;/a&gt; puts it plainly: set &lt;code&gt;base_url&lt;/code&gt; and &lt;code&gt;api_key&lt;/code&gt;, and messages, tools, &lt;code&gt;response_format&lt;/code&gt;, &lt;code&gt;stream&lt;/code&gt;, &lt;code&gt;max_tokens&lt;/code&gt; and &lt;code&gt;temperature&lt;/code&gt; stay the same.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;

&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://api.martllm.com/v1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# the trailing /v1 is required&lt;/span&gt;
    &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"MARTLLM_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="no"&gt;MODELS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"anthropic/claude-sonnet-5.5"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"google/gemini-3.8-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"deepseek/deepseek-v4.1-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"z-ai/glm-5.3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"moonshotai/kimi-k3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;MODELS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"In one sentence: what is a vector database?"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;max_tokens&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;usage&lt;/span&gt;
    &lt;span class="n"&gt;cost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;getattr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"cost_usd"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# MartLLM adds usage.cost_usd to every reply&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{resp.model:32} {u.prompt_tokens:&amp;gt;4} in {u.completion_tokens:&amp;gt;4} out  ${cost}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"   "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;160&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Five makers, one client, one loop. Model ids are &lt;code&gt;maker/model&lt;/code&gt;. &lt;code&gt;GET /v1/models&lt;/code&gt; returns the ones you can call right now, in the OpenAI list shape.&lt;/p&gt;

&lt;p&gt;TypeScript is the same two settings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"openai"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;baseURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://api.martllm.com/v1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MARTLLM_API_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"anthropic/claude-sonnet-5.5"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Explain idempotency keys in two sentences."&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  If your code uses the Anthropic SDK instead
&lt;/h2&gt;

&lt;p&gt;The same endpoint also speaks Anthropic's Messages API. Note the base URL has &lt;strong&gt;no&lt;/strong&gt; &lt;code&gt;/v1&lt;/code&gt; here, because the SDK adds &lt;code&gt;/v1/messages&lt;/code&gt; itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;anthropic&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Anthropic&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Anthropic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://api.martllm.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"MARTLLM_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;msg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"google/gemini-3.8-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;# any catalog model, not only Claude&lt;/span&gt;
    &lt;span class="n"&gt;max_tokens&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;256&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Say hello in one sentence."&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The gateway translates between the two shapes, streaming included (&lt;a href="https://martllm.com/docs/anthropic-sdk" rel="noopener noreferrer"&gt;Anthropic SDK guide&lt;/a&gt;). That's also how tools like Claude Code can run on non-Claude models.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it costs: live prices for the five models
&lt;/h2&gt;

&lt;p&gt;Read from the public catalog on 2026-11-28 at 03:51 UTC, per million tokens (input / output). "List" is the maker's official price. "Cheapest offer now" is the lowest live seller price at that moment. "Paid, last 7 days" is the average buyers were actually billed over the previous week, which is the more honest number for budgeting.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;List&lt;/th&gt;
&lt;th&gt;Cheapest offer now&lt;/th&gt;
&lt;th&gt;Paid, last 7 days&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;anthropic/claude-sonnet-5.5&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$2.00 / $10.00&lt;/td&gt;
&lt;td&gt;$1.008 / $5.04&lt;/td&gt;
&lt;td&gt;$1.07 / $5.37&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;google/gemini-3.8-flash&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$0.75 / $3.75&lt;/td&gt;
&lt;td&gt;$0.126 / $0.63&lt;/td&gt;
&lt;td&gt;$0.120 / $0.602&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;deepseek/deepseek-v4.1-flash&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$0.21 / $0.78&lt;/td&gt;
&lt;td&gt;$0.1345 / $0.4996&lt;/td&gt;
&lt;td&gt;$0.0208 / $0.0771&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;z-ai/glm-5.3&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$1.40 / $4.40&lt;/td&gt;
&lt;td&gt;$0.0243 / $0.0901&lt;/td&gt;
&lt;td&gt;$0.0492 / $0.1827&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;moonshotai/kimi-k3&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;$3.00 / $15.00&lt;/td&gt;
&lt;td&gt;$0.2764 / $1.4175&lt;/td&gt;
&lt;td&gt;$0.1064 / $0.5457&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each request is sent to a third-party provider serving that model and billed what the provider charged, so the price moves with the market. The full board is at &lt;a href="https://martllm.com/llm-api-pricing" rel="noopener noreferrer"&gt;martllm.com/llm-api-pricing&lt;/a&gt;. If you need a hard ceiling, set one per request (below).&lt;/p&gt;

&lt;h2&gt;
  
  
  What carries over, and what doesn't
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Carries over unchanged:&lt;/strong&gt; messages, system prompts, &lt;code&gt;stream&lt;/code&gt;, &lt;code&gt;max_tokens&lt;/code&gt;, &lt;code&gt;temperature&lt;/code&gt;, &lt;code&gt;response_format&lt;/code&gt;, tool definitions. A reply that calls a tool always ends with &lt;code&gt;finish_reason: "tool_calls"&lt;/code&gt;, whichever provider served it. The reply shape is normalized too. You get the standard fields (&lt;code&gt;id&lt;/code&gt;, &lt;code&gt;model&lt;/code&gt;, &lt;code&gt;choices&lt;/code&gt;, &lt;code&gt;usage&lt;/code&gt;), and provider-specific extras are stripped, so code that parses &lt;code&gt;resp.choices[0].message&lt;/code&gt; doesn't need per-model branches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Needs care:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Tool calls round-trip as received.&lt;/strong&gt; Some providers attach extra data to a tool call. Gemini's thought signature arrives in an &lt;code&gt;extra_content&lt;/code&gt; field, and the model needs it back on the next turn. If you rebuild tool-call messages by hand from only &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;arguments&lt;/code&gt;, multi-step tool use on Gemini degrades. Append the assistant message you received as is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reasoning text has two names.&lt;/strong&gt; Reasoning models put their thinking in both &lt;code&gt;reasoning&lt;/code&gt; and &lt;code&gt;reasoning_content&lt;/code&gt;, with the same text, so a client that reads either works. Models that don't reason have neither field. Don't assume it exists.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Modalities differ.&lt;/strong&gt; Sending an image to a text-only model gets a clear &lt;code&gt;400&lt;/code&gt; rather than a silent drop. Check &lt;code&gt;input_modalities&lt;/code&gt; in &lt;code&gt;GET /v1/models&lt;/code&gt; before you route pictures, audio or files to a model. Of the five models above, the catalog lists Claude Sonnet 5.5, Gemini 3.8 Flash, DeepSeek V4.1 Flash and Kimi K3 as taking images (Gemini also takes audio and video). GLM 5.3 is text only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tuning knobs aren't universal.&lt;/strong&gt; Fields that only tune the answer (&lt;code&gt;top_k&lt;/code&gt;, &lt;code&gt;verbosity&lt;/code&gt;, &lt;code&gt;thinking&lt;/code&gt; and similar) are dropped for providers that refuse them instead of failing the call. If your evals depend on one of them, confirm the model supports it (&lt;code&gt;supported_parameters&lt;/code&gt; in the model list).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stateful Responses API.&lt;/strong&gt; &lt;code&gt;client.responses.create&lt;/code&gt; works on every chat model. &lt;code&gt;previous_response_id&lt;/code&gt; and stored conversations need saving turned on for the key. Otherwise send the full conversation each call.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Two request fields worth knowing
&lt;/h2&gt;

&lt;p&gt;These are MartLLM extensions, passed through the OpenAI SDK's &lt;code&gt;extra_body&lt;/code&gt; (details in &lt;a href="https://martllm.com/docs/models-and-routing" rel="noopener noreferrer"&gt;models and routing&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"deepseek/deepseek-v4.1-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Summarize this ticket: ..."&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;extra_body&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;# Tried in order only if nobody can serve the first model right now.&lt;/span&gt;
        &lt;span class="s2"&gt;"models"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"z-ai/glm-5.3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"google/gemini-3.8-flash"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="c1"&gt;# Never pay more than this per million tokens; refused (and free) if nobody sells that low.&lt;/span&gt;
        &lt;span class="s2"&gt;"provider"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"max_price"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"prompt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"completion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# the model that actually answered&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;models&lt;/code&gt;&lt;/strong&gt;: fallbacks, at most 5 models in total. The next one is tried only when the one before has no available provider (or none within your price cap). A bad request or an empty balance is answered right away, not passed down the list.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;provider.max_price&lt;/code&gt;&lt;/strong&gt;: with both &lt;code&gt;prompt&lt;/code&gt; and &lt;code&gt;completion&lt;/code&gt; set, the request is never billed above those rates for the tokens it used. If no provider sells that low right now, you get &lt;code&gt;400 max_price_exceeded&lt;/code&gt; and pay nothing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When this pattern is the wrong choice
&lt;/h2&gt;

&lt;p&gt;One OpenAI-compatible key is a good fit when you want to compare models on your own prompts, keep one code path, and pay one prepaid balance. It's a worse fit when you need a maker's newest feature on day one, if it only exists in their native SDK, or when a contract requires you to buy from the maker directly. In those cases, keep the native SDK for that one model and route everything else through the shared client.&lt;/p&gt;

&lt;p&gt;For everything in between, the change really is two lines.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Alex, CEO, MartLLM&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>python</category>
      <category>openai</category>
    </item>
    <item>
      <title>How to generate AI video from code: Veo 3.1, Kling and Seedance with one API</title>
      <dc:creator>Alex</dc:creator>
      <pubDate>Sat, 28 Nov 2026 04:31:50 +0000</pubDate>
      <link>https://dev.to/alex_martllm/how-to-generate-ai-video-from-code-veo-31-kling-and-seedance-with-one-api-3d9p</link>
      <guid>https://dev.to/alex_martllm/how-to-generate-ai-video-from-code-veo-31-kling-and-seedance-with-one-api-3d9p</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclosure: I'm Alex, and I run MartLLM, the API used in the examples. The job pattern (price, start, poll, download) is the same on most video APIs; swap the URLs and field names for your provider's.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Text models answer in a second or two. Video models don't. A five-second clip takes a minute or more, so every serious video API treats it as a &lt;strong&gt;job&lt;/strong&gt;: you start it, you check on it, and you download the file when it's done. If you write video code like chat code (one blocking request, wait for the bytes), you get timeouts, double charges on retries, and no idea what a clip will cost until the bill arrives.&lt;/p&gt;

&lt;p&gt;This post builds a small, complete Python client for that flow, then runs the same code against three model families: Google's Veo 3.1, Kuaishou's Kling and ByteDance's Seedance. Prices are what the public catalog listed on 2026-11-28.&lt;/p&gt;

&lt;h2&gt;
  
  
  The four steps
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Price it&lt;/strong&gt; without spending anything.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Start&lt;/strong&gt; the job, safely retryable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Poll&lt;/strong&gt; every 5-10 seconds until it ends.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Download&lt;/strong&gt; the file.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The endpoints, all under &lt;code&gt;https://api.martllm.com&lt;/code&gt; with &lt;code&gt;Authorization: Bearer &amp;lt;key&amp;gt;&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Call&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Price&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;POST /v1/video/generations&lt;/code&gt; with &lt;code&gt;"validate": true&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Start&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;POST /v1/video/generations&lt;/code&gt; (HTTP 202, returns a job id)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Poll&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;GET /v1/video/generations/&amp;lt;job id&amp;gt;&lt;/code&gt; (202 while running, 200 when it ends)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Download&lt;/td&gt;
&lt;td&gt;&lt;code&gt;GET /v1/media/artifacts/&amp;lt;job id&amp;gt;/0&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stop&lt;/td&gt;
&lt;td&gt;&lt;code&gt;DELETE /v1/video/generations/&amp;lt;job id&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The full reference, with every field, is in the &lt;a href="https://martllm.com/docs/media" rel="noopener noreferrer"&gt;video section of the media docs&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: price the clip before you make it
&lt;/h2&gt;

&lt;p&gt;Add &lt;code&gt;"validate": true&lt;/code&gt; to the exact request you're about to send. It's checked as if it were real (model, length, resolution, source picture), nothing is made, nothing is charged, and you get back the listed cost and the most the job can be billed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://api.martllm.com/v1/video/generations \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $MARTLLM_API_KEY"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"model": "google/veo-3.1-lite",
       "prompt": "a paper boat drifting down a rain-soaked street at dusk, neon reflections",
       "duration_seconds": 8, "resolution": "720p", "aspect_ratio": "16:9", "audio": true,
       "validate": true}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"object"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"quote"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"google/veo-3.1-lite"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"kind"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"video"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"valid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"cost_usd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.34&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"unit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"second"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"units"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"max_cost_usd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;most&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="n"&gt;can&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="n"&gt;billed&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The extra step is worth it because an invalid request fails here, before money moves. Each model only makes certain lengths, resolutions and shapes. Ask Veo 3.1 Lite for a 10-second clip and the error lists the lengths it does make (4, 6 or 8). A Seedance image-to-video model sent no picture gets &lt;code&gt;400 image_required&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: start the job
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://api.martllm.com/v1/video/generations \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $MARTLLM_API_KEY"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Idempotency-Key: $(uuidgen)"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"model": "google/veo-3.1-lite", "prompt": "...", "duration_seconds": 8,
       "resolution": "720p", "aspect_ratio": "16:9", "audio": true}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get HTTP 202 with a job:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"6f1c..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"object"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"media.job"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"kind"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"video"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"queued"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"estimated_cost_usd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.34&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"max_cost_usd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;held&lt;/span&gt; &lt;span class="n"&gt;while&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="n"&gt;runs&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"poll_url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/v1/video/generations/6f1c..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"cancel_url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/v1/video/generations/6f1c..."&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details matter in production:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Idempotency-Key&lt;/code&gt;&lt;/strong&gt;: if your HTTP client retries the POST after a network blip, the same key means one job, not two. Without it, a flaky connection can buy you the same clip twice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;max_cost_usd&lt;/code&gt;&lt;/strong&gt;: that amount is held from your balance while the job runs, and it's the most the job is billed. Store it next to the job id if you track spend per user.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 3: poll until it ends
&lt;/h2&gt;

&lt;p&gt;A job has six statuses: &lt;code&gt;queued&lt;/code&gt;, &lt;code&gt;running&lt;/code&gt;, &lt;code&gt;succeeded&lt;/code&gt;, &lt;code&gt;failed&lt;/code&gt;, &lt;code&gt;canceled&lt;/code&gt;, &lt;code&gt;expired&lt;/code&gt;. The last four are final. &lt;code&gt;failed&lt;/code&gt;, &lt;code&gt;canceled&lt;/code&gt; and &lt;code&gt;expired&lt;/code&gt; cost nothing. Poll every 5-10 seconds. Faster doesn't make the video arrive sooner.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -H &lt;span class="s2"&gt;"Authorization: Bearer $MARTLLM_API_KEY"&lt;/span&gt; \
  https://api.martllm.com/v1/video/generations/&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;job id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"6f1c..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"succeeded"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"results"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"artifact_index"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://api.martllm.com/v1/media/artifacts/6f1c.../0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nl"&gt;"content_type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"video/mp4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"duration_seconds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"usage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"cost_usd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.34&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One edge case catches people out. The exact charge comes in a little after the file is ready, usually within 30 seconds. Until then a succeeded job shows &lt;code&gt;"usage": {"cost_usd": null, "cost_pending": true}&lt;/code&gt;. Don't treat &lt;code&gt;null&lt;/code&gt; as free. Read the job again later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: download
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -L -o veo.mp4 -H &lt;span class="s2"&gt;"Authorization: Bearer $MARTLLM_API_KEY"&lt;/span&gt; \
  https://api.martllm.com/v1/media/artifacts/&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;job id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The artifact URL needs the same &lt;code&gt;Authorization&lt;/code&gt; header. It isn't a public link, so don't paste it into an &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; tag. Download it and serve it from your own storage.&lt;/p&gt;

&lt;h2&gt;
  
  
  The whole thing in Python
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;pip install requests&lt;/code&gt;, set &lt;code&gt;MARTLLM_API_KEY&lt;/code&gt;, and this runs as is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;uuid&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="no"&gt;API&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://api.martllm.com"&lt;/span&gt;
&lt;span class="no"&gt;HEADERS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Bearer {os.environ['MARTLLM_API_KEY']}"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="no"&gt;DONE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"succeeded"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"failed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"canceled"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"expired"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Same request with "validate": true: checked, priced, nothing made, nothing charged."""&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{API}/v1/video/generations"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;HEADERS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"validate"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Start the job. The Idempotency-Key makes a retried POST start one job, not two."""&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{API}/v1/video/generations"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="no"&gt;HEADERS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Idempotency-Key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uuid4&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# HTTP 202: {"id", "status": "queued", "max_cost_usd", "poll_url", ...}&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;every&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;give_up_after&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Poll every 5-10 s until the job ends (202 while running, 200 once it ends)."""&lt;/span&gt;
    &lt;span class="n"&gt;deadline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;give_up_after&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;deadline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{API}/v1/video/generations/{job_id}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;HEADERS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;DONE&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"  {job['status']} {job.get('progress') or ''}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;every&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;TimeoutError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"job {job_id} still running after {give_up_after}s"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;download&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;HEADERS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"wb"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;iter_content&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;make_video&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{body['model']}: listed ${q['cost_usd']}, at most ${q['max_cost_usd']}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;job&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"succeeded"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{job['status']}: {err.get('message')} (retryable={err.get('retryable')})"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;download&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"results"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;usage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"usage"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;usage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"cost_pending"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# The exact charge lands a little after the file is ready; GET the job again later.&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"saved"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"- charge still pending"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"saved"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"- billed $"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;usage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"cost_usd"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;job&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;make_video&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"google/veo-3.1-lite"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"prompt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"a paper boat drifting down a rain-soaked street at dusk, neon reflections"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"duration_seconds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"resolution"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"720p"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"aspect_ratio"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"16:9"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"audio"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"veo.mp4"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On a &lt;code&gt;failed&lt;/code&gt; job, &lt;code&gt;error.retryable&lt;/code&gt; tells you whether sending it again can work. A content refusal won't. A busy moment usually will.&lt;/p&gt;

&lt;h2&gt;
  
  
  Same code, three model families
&lt;/h2&gt;

&lt;p&gt;Only the body changes. These are real model ids from the catalog, with the price each listed on 2026-11-28:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Veo 3.1 Lite, text to video, 8 s, 720p with sound.&lt;/strong&gt; $0.0425 per second, so &lt;strong&gt;$0.34&lt;/strong&gt; a clip. It makes 4, 6 or 8 second clips at 720p or 1080p, 16:9 or 9:16. (&lt;a href="https://martllm.com/models/google/veo-3.1-lite" rel="noopener noreferrer"&gt;model page&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"google/veo-3.1-lite"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"prompt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"duration_seconds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="s2"&gt;"resolution"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"720p"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"audio"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Kling V3 Standard, text to video, 5 s.&lt;/strong&gt; $0.0732 per second, about &lt;strong&gt;$0.37&lt;/strong&gt; for 5 seconds. Lengths 3 to 15 s. The image-to-video version, &lt;code&gt;kling/kling-v3-standard-image-to-video&lt;/code&gt;, takes &lt;code&gt;image_url&lt;/code&gt; and the same per-second price.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"kling/kling-v3-standard-text-to-video"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"prompt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"duration_seconds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Seedance 2.0 Mini, image to video, 5 s at 480p.&lt;/strong&gt; $0.0163 per second at 480p ($0.0351 at 720p), about &lt;strong&gt;$0.08&lt;/strong&gt; for 5 seconds. The picture becomes the first frame. Lengths 5 to 15 s. (&lt;a href="https://martllm.com/models/bytedance/seedance-2-0-mini-image-to-video" rel="noopener noreferrer"&gt;model page&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"bytedance/seedance-2-0-mini-image-to-video"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"prompt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"slow push-in as the waves roll"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="s2"&gt;"image_url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://example.com/first-frame.png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"duration_seconds"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"resolution"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"480p"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For image-to-video, send a picture that already has the shape you want (crop it to 9:16 for a vertical clip). Most Kling, Veo and Seedance image-to-video models make the clip in the shape of the source picture and refuse an &lt;code&gt;aspect_ratio&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things worth adding before production
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A backup model.&lt;/strong&gt; Add &lt;code&gt;"models": ["kling/kling-v3-standard-text-to-video"]&lt;/code&gt; and that model is tried only if the first has no free provider right now. The reply's &lt;code&gt;model&lt;/code&gt; field says which one took the job.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Webhooks instead of polling&lt;/strong&gt; if you run many jobs at once. The &lt;a href="https://martllm.com/docs/media" rel="noopener noreferrer"&gt;media docs&lt;/a&gt; cover callbacks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A per-request ceiling.&lt;/strong&gt; &lt;code&gt;max_cost&lt;/code&gt; on the request caps what one job can cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Price tracking.&lt;/strong&gt; Video prices move weekly. The &lt;a href="https://martllm.com/video-api-pricing" rel="noopener noreferrer"&gt;video API pricing page&lt;/a&gt; lists every model's rate per second, read live.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same pattern runs as a Python script, an n8n workflow or a queue worker. The job is the unit: price it, start it once, wait, fetch it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Alex, CEO, MartLLM&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>video</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Gemini 4 Neon API price compared: Google, OpenRouter, Requesty and a marketplace (November 2026)</title>
      <dc:creator>Alex</dc:creator>
      <pubDate>Sat, 21 Nov 2026 06:03:07 +0000</pubDate>
      <link>https://dev.to/alex_martllm/gemini-4-neon-api-price-compared-google-openrouter-vercel-requesty-and-a-marketplace-november-4mhd</link>
      <guid>https://dev.to/alex_martllm/gemini-4-neon-api-price-compared-google-openrouter-vercel-requesty-and-a-marketplace-november-4mhd</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclosure: I run MartLLM (formerly UberLLM), one of the sellers in this table. Every other price&lt;br&gt;
was read on the seller's own pricing page or public price list on November 21, 2026. Links are at&lt;br&gt;
the bottom so you can check each one.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Gemini 4 Neon reached the API this week with a 1M-token context window and no free tier. Here is&lt;br&gt;
what one million tokens costs everywhere I could find a public price, and what changes the bill.&lt;/p&gt;

&lt;h2&gt;
  
  
  Standard price, USD per 1M tokens
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Seller&lt;/th&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Output&lt;/th&gt;
&lt;th&gt;Cached input&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Google AI Studio / Gemini API (official)&lt;/td&gt;
&lt;td&gt;$3.00&lt;/td&gt;
&lt;td&gt;$15.00&lt;/td&gt;
&lt;td&gt;$0.15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OpenRouter&lt;/td&gt;
&lt;td&gt;$3.00&lt;/td&gt;
&lt;td&gt;$15.00&lt;/td&gt;
&lt;td&gt;$0.15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requesty (Vertex)&lt;/td&gt;
&lt;td&gt;$3.00&lt;/td&gt;
&lt;td&gt;$15.00&lt;/td&gt;
&lt;td&gt;$0.15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requesty, pinned to an EU or US region&lt;/td&gt;
&lt;td&gt;$3.30&lt;/td&gt;
&lt;td&gt;$16.50&lt;/td&gt;
&lt;td&gt;$0.165&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MartLLM, listed price&lt;/td&gt;
&lt;td&gt;$2.646&lt;/td&gt;
&lt;td&gt;$13.23&lt;/td&gt;
&lt;td&gt;$0.1323&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MartLLM, best seller offer when I looked&lt;/td&gt;
&lt;td&gt;$1.90&lt;/td&gt;
&lt;td&gt;$9.50&lt;/td&gt;
&lt;td&gt;$0.095&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The gateways pass Google's price through unchanged. The real differences are below.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changes the bill
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Waiting.&lt;/strong&gt; Google lists Batch and Flex at half price: $1.50 input, $7.50 output, $0.075 cached.
OpenRouter lists the same batch price. If your job can wait, this beats every row above.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Speed.&lt;/strong&gt; Google's Priority tier is $5.40 / $27.00 (cached $0.27).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Region.&lt;/strong&gt; Pinning traffic to an EU or US region costs 10% more on Requesty.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching.&lt;/strong&gt; Google lists implicit caching only (no explicit cache API) at 95% off input.
Prompts that share a long prefix get it without extra work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Long prompts.&lt;/strong&gt; Google lists one price for the whole 1M window; there is no separate tier
above 200k tokens.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Search grounding.&lt;/strong&gt; Google: 5,000 free searches a month shared across Gemini 3 and newer,
then $14 per 1,000. OpenRouter lists the same $14 per 1,000.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  About the MartLLM rows
&lt;/h2&gt;

&lt;p&gt;MartLLM is a marketplace: sellers post offers for the same model and each request goes to the&lt;br&gt;
cheapest one that is serving. That gives two numbers, and I show both because one alone would&lt;br&gt;
mislead you.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;listed price&lt;/strong&gt; is the most you pay: 12% below Google.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;best seller offer&lt;/strong&gt; moves through the day: 37% below Google when I looked, only while
that seller has capacity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What buyers were actually billed over the last 7 days, all calls added up: 21% below Google's&lt;br&gt;
price (649 calls from 9 accounts). That is closer to the listed price than to the best offer, so&lt;br&gt;
plan on that number, not the best one.&lt;/p&gt;

&lt;p&gt;Adding credit by card costs 5.5% + $0.50. Count that in, and compare it with Google's Batch price&lt;br&gt;
if you do not need answers right away.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which one to pick
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can wait minutes to hours: Google Batch or Flex at half price. Nothing here beats it.&lt;/li&gt;
&lt;li&gt;You need Priority speed or Google's own terms: Google direct.&lt;/li&gt;
&lt;li&gt;You want one key for many makers and do not mind paying list: OpenRouter or Requesty.&lt;/li&gt;
&lt;li&gt;You want real-time calls below list and can live with a price that moves: a marketplace. Set a
spending cap on the key and check your first invoice against the listed price.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Prices move. If you spot one that changed, comment and I will update the table.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources (read 2026-11-21)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Google: &lt;a href="https://ai.google.dev/gemini-api/docs/pricing" rel="noopener noreferrer"&gt;https://ai.google.dev/gemini-api/docs/pricing&lt;/a&gt; (redirects to &lt;a href="https://aistudio.google.com/docs/pricing" rel="noopener noreferrer"&gt;https://aistudio.google.com/docs/pricing&lt;/a&gt;), section "Gemini 4 Neon"&lt;/li&gt;
&lt;li&gt;OpenRouter public model list: &lt;a href="https://openrouter.ai/api/v1/models" rel="noopener noreferrer"&gt;https://openrouter.ai/api/v1/models&lt;/a&gt; (google/gemini-4-neon and google/gemini-4-neon:batch)&lt;/li&gt;
&lt;li&gt;Requesty public model list: &lt;a href="https://router.requesty.ai/v1/models" rel="noopener noreferrer"&gt;https://router.requesty.ai/v1/models&lt;/a&gt; (vertex/gemini-4-neon, &lt;a class="mentioned-user" href="https://dev.to/eu"&gt;@eu&lt;/a&gt;, &lt;a class="mentioned-user" href="https://dev.to/us"&gt;@us&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;MartLLM: &lt;a href="https://martllm.com/models/google/gemini-4-neon" rel="noopener noreferrer"&gt;https://martllm.com/models/google/gemini-4-neon&lt;/a&gt; , public list &lt;a href="https://api.martllm.com/v1/models" rel="noopener noreferrer"&gt;https://api.martllm.com/v1/models&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>gemini</category>
      <category>api</category>
      <category>pricing</category>
    </item>
    <item>
      <title>Streaming chat completions from an OpenAI-compatible API: the SSE lines, the usage chunk, tool calls and the usual bugs</title>
      <dc:creator>Alex</dc:creator>
      <pubDate>Fri, 20 Nov 2026 05:47:14 +0000</pubDate>
      <link>https://dev.to/alex_martllm/streaming-chat-completions-from-an-openai-compatible-api-the-sse-lines-the-usage-chunk-tool-h19</link>
      <guid>https://dev.to/alex_martllm/streaming-chat-completions-from-an-openai-compatible-api-the-sse-lines-the-usage-chunk-tool-h19</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclosure: I run MartLLM (formerly UberLLM); the examples use its API, but the setup works the same with any compatible provider where noted.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Streaming is the right default for anything with a long prompt, long output or a high token cap: the first words show up quickly, and long answers do not hit request timeouts. It is also where most client bugs live. This post walks through what actually comes over the wire from an OpenAI-compatible &lt;code&gt;/v1/chat/completions&lt;/code&gt; endpoint, and the mistakes that show up again and again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Turn it on
&lt;/h2&gt;

&lt;p&gt;Add &lt;code&gt;"stream": true&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -N https://api.martllm.com/v1/chat/completions \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $UBERLLM_API_KEY"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{
    "model": "deepseek/deepseek-v4-flash",
    "stream": true,
    "messages": [{"role": "user", "content": "Count to five, one per line."}]
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;-N&lt;/code&gt; turns off curl's buffering so you see events as they arrive. Any OpenAI-compatible provider takes the same body; change the URL, key and model id.&lt;/p&gt;

&lt;h2&gt;
  
  
  What arrives
&lt;/h2&gt;

&lt;p&gt;The reply is Server-Sent Events: lines starting with &lt;code&gt;data:&lt;/code&gt;, each a chat completion chunk, separated by blank lines, and a last line &lt;code&gt;data: [DONE]&lt;/code&gt;. Schematically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ping&lt;/span&gt;

&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"choices"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"delta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; …&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"choices"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"delta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"\n2"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; …&lt;span class="p"&gt;}&lt;/span&gt;

… &lt;span class="n"&gt;more&lt;/span&gt; &lt;span class="n"&gt;chunks&lt;/span&gt; …

&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;… &lt;span class="s2"&gt;"usage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"prompt_tokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; …&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"completion_tokens"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; …&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"cost_usd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; …&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;DONE&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three kinds of line, and a client has to handle all of them:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Comment lines&lt;/strong&gt; starting with &lt;code&gt;:&lt;/code&gt;. MartLLM sends a &lt;code&gt;: ping&lt;/code&gt; comment the moment you connect and keep-alives after that, so a long stream survives proxy idle timeouts. They are not data: skip them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;data:&lt;/code&gt; lines with JSON.&lt;/strong&gt; The text is in &lt;code&gt;choices[0].delta.content&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;data: [DONE]&lt;/code&gt;.&lt;/strong&gt; The end. It is not JSON, so do not parse it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Parsing it by hand
&lt;/h2&gt;

&lt;p&gt;If you are not using an SDK, the loop is short. With Python's &lt;code&gt;requests&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"https://api.martllm.com/v1/chat/completions"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Bearer {os.environ['UBERLLM_API_KEY']}"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek/deepseek-v4-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"stream"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"messages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Write a short poem."&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# refusals come back as a normal HTTP error before the stream&lt;/span&gt;

&lt;span class="n"&gt;done&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;usage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;iter_lines&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;               &lt;span class="c1"&gt;# bytes; decode as UTF-8 yourself&lt;/span&gt;
    &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;":"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    &lt;span class="c1"&gt;# blank separator or keep-alive comment&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"data:"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;
    &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"data:"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"[DONE]"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;done&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"usage"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;usage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"usage"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"choices"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# a chunk may carry no text&lt;/span&gt;
        &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"delta"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flush&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;done&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"stream ended without [DONE]: treat the answer as incomplete"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;usage&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Things this gets right that hand-rolled parsers often miss: comments are skipped, a chunk with no text (or no choices) does not crash the loop, &lt;code&gt;[DONE]&lt;/code&gt; is never passed to &lt;code&gt;json.loads&lt;/code&gt;, and a stream that closes &lt;strong&gt;without&lt;/strong&gt; &lt;code&gt;[DONE]&lt;/code&gt; is treated as cut off, not finished.&lt;/p&gt;

&lt;p&gt;With the OpenAI SDK you get the parsing for free:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://api.martllm.com/v1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ull_..."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"deepseek/deepseek-v4-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Write a short poem."&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;delta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;delta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flush&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the trailing &lt;code&gt;/v1&lt;/code&gt; in &lt;code&gt;base_url&lt;/code&gt;; without it every call is a 404.&lt;/p&gt;

&lt;h2&gt;
  
  
  The usage chunk
&lt;/h2&gt;

&lt;p&gt;Token counts in a stream come at the end, in a chunk with a &lt;code&gt;usage&lt;/code&gt; object. In the OpenAI format you normally have to ask for it with &lt;code&gt;stream_options: {"include_usage": true}&lt;/code&gt;. On other compatible providers, send that yourself where it is supported; in the Vercel AI SDK's OpenAI-compatible provider it is &lt;code&gt;includeUsage: true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;MartLLM adds &lt;code&gt;stream_options: {"include_usage": true}&lt;/code&gt; for you when the upstream supports it, and when an upstream sends no usage chunk it adds one before &lt;code&gt;data: [DONE]&lt;/code&gt;. The usage carries the prompt and completion token counts and &lt;code&gt;cost_usd&lt;/code&gt;, what that request is billed in US dollars.&lt;/p&gt;

&lt;p&gt;The usual bug: a loop that only looks at &lt;code&gt;delta.content&lt;/code&gt; never sees the usage chunk, so token logging silently records nothing. Read &lt;code&gt;usage&lt;/code&gt; from every chunk, as above.&lt;/p&gt;

&lt;p&gt;On MartLLM a non-streamed reply also has an &lt;code&gt;X-UberLLM-Cost-USD&lt;/code&gt; header. A stream does not, because its headers go out before the cost is known: read &lt;code&gt;usage.cost_usd&lt;/code&gt; from the last chunk.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reasoning models
&lt;/h2&gt;

&lt;p&gt;Reasoning text comes in the delta too. MartLLM sends it in &lt;strong&gt;both&lt;/strong&gt; &lt;code&gt;reasoning&lt;/code&gt; and &lt;code&gt;reasoning_content&lt;/code&gt;, with the same text, so clients that read either one get it. The bug to avoid: printing both doubles every word. Pick one. A reply with no reasoning has neither field.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tool calls
&lt;/h2&gt;

&lt;p&gt;Pass &lt;code&gt;tools&lt;/code&gt; as usual; streaming does not change the request. Things to get right:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use a model that takes tools.&lt;/strong&gt; The model list (&lt;code&gt;GET https://api.martllm.com/v1/models&lt;/code&gt;) marks &lt;code&gt;supports_tools&lt;/code&gt; on each chat model. On MartLLM, tools sent to a model that cannot call them are refused with &lt;code&gt;400 tools_not_supported&lt;/code&gt; before anything is charged.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wait for the end before running the tool.&lt;/strong&gt; Tool calls arrive in the &lt;code&gt;delta&lt;/code&gt; in pieces. Do not parse the arguments as JSON until the stream says the call is complete. SDK helpers and frameworks (LangChain, the Vercel AI SDK) assemble the pieces for you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check &lt;code&gt;finish_reason&lt;/code&gt;.&lt;/strong&gt; A reply that calls a tool ends with &lt;code&gt;finish_reason: "tool_calls"&lt;/code&gt;. Some providers have ended tool calls with &lt;code&gt;"stop"&lt;/code&gt; instead, and clients that only act on &lt;code&gt;"tool_calls"&lt;/code&gt; never ran the tool. MartLLM normalises this so it is always &lt;code&gt;"tool_calls"&lt;/code&gt;, streamed or not; on other providers, it is worth checking for tool calls whatever the finish reason says.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Send tool calls back exactly as you got them.&lt;/strong&gt; Some carry an &lt;code&gt;extra_content&lt;/code&gt; field (Gemini's thought signature) that the model needs on the next turn. Rebuilding the message from only the fields you know drops it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Errors, aborts and retries
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Before the stream starts&lt;/strong&gt;, a refusal is a normal HTTP status with an OpenAI-style error body (&lt;code&gt;{"error": {"code": …, "message": …}}&lt;/code&gt;): &lt;code&gt;402 insufficient_credits&lt;/code&gt;, &lt;code&gt;404 model_not_found&lt;/code&gt;, &lt;code&gt;429 rate_limited&lt;/code&gt;, &lt;code&gt;503 no_available_provider&lt;/code&gt;. Check the status before you start reading lines.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Once streaming has started, nothing is retried.&lt;/strong&gt; MartLLM retries a call that fails before the first content byte (up to 4 attempts), but a failure mid-stream ends the stream, and you are billed only for what was produced. Your client should treat a missing &lt;code&gt;[DONE]&lt;/code&gt; as a failure and decide whether to retry.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disconnecting is safe.&lt;/strong&gt; If you close the connection mid-stream, the gateway cancels the upstream request and settles for the tokens actually streamed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time to first byte.&lt;/strong&gt; A stream gets 10 seconds to start (more for a long prompt or a usually slow model); a reply without &lt;code&gt;"stream": true&lt;/code&gt; gets 85 seconds, because nothing arrives until it is complete. Another reason to stream long answers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The other two surfaces
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Anthropic format&lt;/strong&gt; (&lt;code&gt;/v1/messages&lt;/code&gt; with &lt;code&gt;"stream": true&lt;/code&gt;): the same idea in Anthropic's event names. &lt;code&gt;max_tokens&lt;/code&gt; is required, and on MartLLM the cost is in the &lt;code&gt;usage&lt;/code&gt; of the &lt;code&gt;message_delta&lt;/code&gt; event.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Responses API&lt;/strong&gt; (&lt;code&gt;/v1/responses&lt;/code&gt;): events have a &lt;code&gt;type&lt;/code&gt; such as &lt;code&gt;response.output_text.delta&lt;/code&gt;, and the stream ends with &lt;code&gt;response.completed&lt;/code&gt; (or &lt;code&gt;response.failed&lt;/code&gt;, never &lt;code&gt;completed&lt;/code&gt;, if it stopped early). The same &lt;code&gt;: ping&lt;/code&gt; comment lines appear while a slow model starts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Skip lines starting with &lt;code&gt;:&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Never &lt;code&gt;json.loads&lt;/code&gt; the &lt;code&gt;[DONE]&lt;/code&gt; line; treat a stream without it as incomplete.&lt;/li&gt;
&lt;li&gt;Guard for chunks with no choices or no text.&lt;/li&gt;
&lt;li&gt;Read &lt;code&gt;usage&lt;/code&gt; from the last chunk, and ask for it where your provider needs &lt;code&gt;include_usage&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Print &lt;code&gt;reasoning&lt;/code&gt; or &lt;code&gt;reasoning_content&lt;/code&gt;, not both.&lt;/li&gt;
&lt;li&gt;Assemble tool calls before parsing them, and send them back unchanged.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MartLLM docs, Streaming: &lt;a href="https://martllm.com/docs/streaming" rel="noopener noreferrer"&gt;https://martllm.com/docs/streaming&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MartLLM docs, OpenAI SDK (tool calls, reply shape, streaming usage): &lt;a href="https://martllm.com/docs/openai-sdk" rel="noopener noreferrer"&gt;https://martllm.com/docs/openai-sdk&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MartLLM docs, Models and routing (retries, time to first byte): &lt;a href="https://martllm.com/docs/models-and-routing" rel="noopener noreferrer"&gt;https://martllm.com/docs/models-and-routing&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MartLLM docs, Errors: &lt;a href="https://martllm.com/docs/errors" rel="noopener noreferrer"&gt;https://martllm.com/docs/errors&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MartLLM docs, Responses API: &lt;a href="https://martllm.com/docs/responses" rel="noopener noreferrer"&gt;https://martllm.com/docs/responses&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>api</category>
      <category>python</category>
    </item>
    <item>
      <title>AI video from n8n with the HTTP Request node: start the job, poll it, download the file</title>
      <dc:creator>Alex</dc:creator>
      <pubDate>Fri, 20 Nov 2026 05:35:50 +0000</pubDate>
      <link>https://dev.to/alex_martllm/ai-video-from-n8n-with-the-http-request-node-start-the-job-poll-it-download-the-file-3off</link>
      <guid>https://dev.to/alex_martllm/ai-video-from-n8n-with-the-http-request-node-start-the-job-poll-it-download-the-file-3off</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclosure: I run MartLLM (formerly UberLLM); the examples use its API, but the setup works the same with any compatible provider where noted.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;AI video is not a normal request/response call. A clip takes a minute or more, so video APIs treat it as a job: you start it, check on it, and download the file when it is done. n8n handles that with nodes it already has: &lt;strong&gt;HTTP Request&lt;/strong&gt;, &lt;strong&gt;Wait&lt;/strong&gt; and &lt;strong&gt;If&lt;/strong&gt;. No community node, works on n8n Cloud and self-hosted.&lt;/p&gt;

&lt;p&gt;The shape below (start, wait, poll, branch, download) works with any job-style video API. The URLs and field names are MartLLM's; swap them for your provider's.&lt;/p&gt;

&lt;h2&gt;
  
  
  The workflow
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Manual Trigger
  → Settings (Set)
  → Start video (HTTP Request, POST)
  → Wait for video (Wait, 15 s)  ←──────────────┐
  → Check video job (HTTP Request, GET)          │
  → Video ready? (If: status = succeeded)        │
       yes → Video result (Set) → Video (HTTP Request, file)
       no  → Still making video? (If) ── yes ────┘
                                       no → Stop and Error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  1. One credential for every node
&lt;/h2&gt;

&lt;p&gt;In any HTTP Request node: &lt;strong&gt;Authentication&lt;/strong&gt; → Generic credential type → &lt;strong&gt;Header Auth&lt;/strong&gt; → Create new:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Name&lt;/strong&gt;: &lt;code&gt;Authorization&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value&lt;/strong&gt;: &lt;code&gt;Bearer ull_...&lt;/code&gt; (your key)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every HTTP node in the workflow uses this same credential, including the download.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Settings
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;Set&lt;/strong&gt; node keeps the inputs in one place:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;prompt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;your prompt&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;model&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;google/veo3-1-fast-text-to-video&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;duration_seconds&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;8&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;resolution&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;720p&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;aspect_ratio&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;16:9&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;audio&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;max_cost&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;1.5&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;max_cost&lt;/code&gt; is a ceiling in US dollars: a job that could cost more is refused with &lt;code&gt;400 max_cost_too_low&lt;/code&gt; before anything is charged.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Start the job
&lt;/h2&gt;

&lt;p&gt;HTTP Request node, &lt;strong&gt;POST&lt;/strong&gt; &lt;code&gt;https://api.martllm.com/v1/video/generations&lt;/code&gt;, &lt;strong&gt;Send Headers&lt;/strong&gt; on:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Header&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Idempotency-Key&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;{{ $execution.id }}-video&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;X-UberLLM-Source&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;n8n&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Send Body&lt;/strong&gt; → JSON → this expression:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;duration_seconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;duration_seconds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;resolution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;resolution&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;aspect_ratio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;aspect_ratio&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;audio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;audio&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;max_cost&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max_cost&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The answer comes back at once with HTTP 202:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"6f1c…"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"object"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"media.job"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"kind"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"video"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"queued"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"model"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"google/veo3-1-fast-text-to-video"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"estimated_cost_usd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;…&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"max_cost_usd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;…&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"poll_url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/v1/video/generations/6f1c…"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;max_cost_usd&lt;/code&gt; is held from your balance while the job runs and is the most it can be billed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why the &lt;code&gt;Idempotency-Key&lt;/code&gt; matters in n8n:&lt;/strong&gt; if the connection drops and n8n retries the node, the same key within 24 hours returns the same job instead of starting (and paying for) a second one. The same key with a different body is refused with &lt;code&gt;409 idempotency_key_reused&lt;/code&gt;. Building the key from &lt;code&gt;$execution.id&lt;/code&gt; gives one key per run. If your provider supports idempotency keys, use them the same way.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Wait, then poll
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Wait&lt;/strong&gt; node: 15 seconds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check video job&lt;/strong&gt;, HTTP Request, &lt;strong&gt;GET&lt;/strong&gt;, URL as an expression:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'https://api.martllm.com/v1/video/generations/'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The job is in one of six states:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;code&gt;status&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;HTTP&lt;/th&gt;
&lt;th&gt;Means&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;queued&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;202&lt;/td&gt;
&lt;td&gt;Accepted, waiting to start&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;running&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;202&lt;/td&gt;
&lt;td&gt;Being made&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;succeeded&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;td&gt;Done; the file is in &lt;code&gt;results[].url&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;failed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;td&gt;Not made; &lt;code&gt;error.message&lt;/code&gt; says why&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;canceled&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;td&gt;Stopped before it was made&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;expired&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;td&gt;Not finished in time&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two &lt;strong&gt;If&lt;/strong&gt; nodes do the branching:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Video ready?&lt;/strong&gt;: &lt;code&gt;{{ $json.status }}&lt;/code&gt; equals &lt;code&gt;succeeded&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Still making video?&lt;/strong&gt; (on the false branch): a boolean expression that loops back to &lt;strong&gt;Wait&lt;/strong&gt; while the job runs, with a limit:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'queued'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'running'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nv"&gt;$runIndex&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;60 checks × 15 seconds is 15 minutes. Most videos take 1 to 5 minutes. If the loop gives up, the job still finishes and is billed (or refunded) on the server, so nothing is lost by stopping to wait. The docs suggest checking every 5 to 10 seconds; 15 keeps the execution log shorter.&lt;/p&gt;

&lt;p&gt;The false branch ends in &lt;strong&gt;Stop and Error&lt;/strong&gt; with the reason:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'The video job '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;' ended as '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;': '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
   &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'it took too long to wait for'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;failed&lt;/code&gt;, &lt;code&gt;canceled&lt;/code&gt; and &lt;code&gt;expired&lt;/code&gt; jobs cost nothing; the hold comes back.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Download the file
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;Set&lt;/strong&gt; node pulls out what you need from the finished job: &lt;code&gt;job_id&lt;/code&gt; = &lt;code&gt;{{ $json.id }}&lt;/code&gt;, &lt;code&gt;url&lt;/code&gt; = &lt;code&gt;{{ $json.results[0].url }}&lt;/code&gt;, and the cost from &lt;code&gt;usage.cost_usd&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The exact charge arrives a little after the file is ready, usually within 30 seconds. Until then a &lt;code&gt;succeeded&lt;/code&gt; job shows &lt;code&gt;"usage": { "cost_usd": null, "cost_pending": true }&lt;/code&gt;, so treat a null cost as "not in yet", not as zero.&lt;/p&gt;

&lt;p&gt;Then the last &lt;strong&gt;HTTP Request&lt;/strong&gt;: &lt;strong&gt;GET&lt;/strong&gt; &lt;code&gt;{{ $json.url }}&lt;/code&gt;, same credential, &lt;strong&gt;Options&lt;/strong&gt; → &lt;strong&gt;Response&lt;/strong&gt; → Response Format &lt;strong&gt;File&lt;/strong&gt;, Put Output in Field &lt;code&gt;data&lt;/code&gt;, and a generous timeout (the template uses 300000 ms). The video is now binary &lt;code&gt;data&lt;/code&gt;, ready for Google Drive, S3 or YouTube nodes.&lt;/p&gt;

&lt;p&gt;Two things to know about that link:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It needs your key, so a service that fetches a video by URL (Instagram, Blotato) cannot open it. Upload the file somewhere first.&lt;/li&gt;
&lt;li&gt;Video files are kept for &lt;strong&gt;about 3 hours&lt;/strong&gt; after the job ends. After that the download answers &lt;code&gt;404 artifact_expired&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To skip the download step, add &lt;code&gt;output_upload_url&lt;/code&gt; (a presigned PUT link for S3, R2 or Google Cloud Storage) to the start request and the file is uploaded there when the job succeeds.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Or get called back instead of polling
&lt;/h2&gt;

&lt;p&gt;Add &lt;code&gt;callback_url&lt;/code&gt; (an n8n Webhook URL, &lt;code&gt;https://&lt;/code&gt; on a public host) to the start request. When the job has ended and its bill is final, MartLLM sends one &lt;code&gt;POST&lt;/code&gt; with the same JSON the GET returns, plus &lt;code&gt;UberLLM-Event&lt;/code&gt;, &lt;code&gt;UberLLM-Event-Id&lt;/code&gt; and &lt;code&gt;UberLLM-Signature&lt;/code&gt; headers. Answer with any 2xx within 15 seconds; otherwise it is retried after 30 seconds, 2 minutes, 10 minutes, 30 minutes and 2 hours. A message can arrive twice, so drop repeats by &lt;code&gt;UberLLM-Event-Id&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Image to video
&lt;/h2&gt;

&lt;p&gt;Use an image-to-video model and add &lt;code&gt;image_url&lt;/code&gt; (a public &lt;code&gt;https://&lt;/code&gt; link) to the body, for example &lt;code&gt;kling/kling-v3-standard-image-to-video&lt;/code&gt; or &lt;code&gt;google/veo3-1-fast-image-to-video&lt;/code&gt;. Most of these make the clip in the shape of your picture, so crop it first (9:16 for vertical) and leave &lt;code&gt;aspect_ratio&lt;/code&gt; out. Without a picture they answer &lt;code&gt;400 image_required&lt;/code&gt;, before anything is charged.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check the price first
&lt;/h2&gt;

&lt;p&gt;Add &lt;code&gt;"validate": true&lt;/code&gt; to the start body. Nothing is made or charged; the answer gives &lt;code&gt;cost_usd&lt;/code&gt; (listed price) and &lt;code&gt;max_cost_usd&lt;/code&gt; (what would be held).&lt;/p&gt;

&lt;p&gt;For reference, the public catalog on November 20, 2026 listed &lt;code&gt;google/veo3-1-fast-text-to-video&lt;/code&gt; at $0.085 per second at 720p without sound and $0.1275 per second with sound, so the 8-second clip above is about $1.02. Prices move; check before a big batch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Coming from the Gemini "Generate a video" node
&lt;/h2&gt;

&lt;p&gt;Google turned off the Veo 3.1 preview models in the Gemini API on 22 October 2026, which broke workflows built on that node. The model names map like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Gemini model&lt;/th&gt;
&lt;th&gt;MartLLM model&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;veo-3.1-generate-preview&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;google/veo3-1-full-text-to-video&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;veo-3.1-fast-generate-preview&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;google/veo3-1-fast-text-to-video&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;veo-3.1-lite-generate-preview&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;google/veo-3.1-lite&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Import it instead of building it
&lt;/h2&gt;

&lt;p&gt;The full workflow is a ready-made file: in n8n, &lt;strong&gt;⋯&lt;/strong&gt; → &lt;strong&gt;Import from URL…&lt;/strong&gt; and paste&lt;br&gt;
&lt;code&gt;https://raw.githubusercontent.com/PSA-Team-source/uberllm-n8n-templates/main/workflows/veo-3-1-fast-text-to-video.json&lt;/code&gt;. There are also Kling image-to-video, a faceless Shorts pipeline, a UGC product ad and a Gemini Veo replacement in the same repository. MartLLM is prepaid credit; there is no free tier.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MartLLM docs, n8n video templates: &lt;a href="https://martllm.com/docs/n8n-video" rel="noopener noreferrer"&gt;https://martllm.com/docs/n8n-video&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MartLLM docs, Images, video, music and speech (jobs, callbacks, file retention, validate): &lt;a href="https://martllm.com/docs/media" rel="noopener noreferrer"&gt;https://martllm.com/docs/media&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Template source: &lt;a href="https://github.com/PSA-Team-source/uberllm-n8n-templates" rel="noopener noreferrer"&gt;https://github.com/PSA-Team-source/uberllm-n8n-templates&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Live prices: &lt;a href="https://api.martllm.com/api/v1/public/models" rel="noopener noreferrer"&gt;https://api.martllm.com/api/v1/public/models&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>n8n</category>
      <category>ai</category>
      <category>automation</category>
      <category>video</category>
    </item>
    <item>
      <title>Claude Code on an Anthropic-compatible gateway: where the key goes, which setting wins, and when it compacts</title>
      <dc:creator>Alex</dc:creator>
      <pubDate>Fri, 20 Nov 2026 05:24:18 +0000</pubDate>
      <link>https://dev.to/alex_martllm/claude-code-on-an-anthropic-compatible-gateway-where-the-key-goes-which-setting-wins-and-when-it-3gk7</link>
      <guid>https://dev.to/alex_martllm/claude-code-on-an-anthropic-compatible-gateway-where-the-key-goes-which-setting-wins-and-when-it-3gk7</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclosure: I run MartLLM (formerly UberLLM); the examples use its API, but the setup works the same with any compatible provider where noted.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Claude Code talks to the Anthropic Messages API. Any endpoint that speaks that API can serve it: a model maker's own Anthropic-compatible endpoint, a company gateway, or a marketplace. I wrote earlier about &lt;a href="https://dev.to/alex_martllm/run-claude-code-on-deepseek-glm-or-kimi-settings-what-breaks-and-fixes-2l0p"&gt;mapping Claude Code to DeepSeek, GLM or Kimi&lt;/a&gt;. This post is the plumbing underneath: where the address and key go, which setting wins when two disagree, how compaction behaves on a non-Claude model, and how to check and undo it.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. A quick test in one terminal
&lt;/h2&gt;

&lt;p&gt;Two environment variables are enough:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://api.martllm.com
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_AUTH_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ull_your_key
claude
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Windows PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;ANTHROPIC_BASE_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://api.martllm.com"&lt;/span&gt;
&lt;span class="nv"&gt;$env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;ANTHROPIC_AUTH_TOKEN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ull_your_key"&lt;/span&gt;
&lt;span class="n"&gt;claude&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the address: the Anthropic-style base URL has no &lt;code&gt;/v1&lt;/code&gt; at the end (the OpenAI-style one, for other tools, is &lt;code&gt;https://api.martllm.com/v1&lt;/code&gt;). Use your own provider's address and key here; nothing else changes.&lt;/p&gt;

&lt;p&gt;This lasts only for the current terminal. For daily use, move it into a settings file.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Keep the key out of settings files with &lt;code&gt;apiKeyHelper&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Instead of pasting the key into JSON, save it to a file only you can read:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir -p ~/.uberllm &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; chmod 700 ~/.uberllm
&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%s\n'&lt;/span&gt; &lt;span class="s1"&gt;'ull_your_key'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/.uberllm/key &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; chmod 600 ~/.uberllm/key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then point Claude Code at it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"apiKeyHelper"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"cat ~/.uberllm/key"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_BASE_URL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://api.martllm.com"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where that block goes decides its scope:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Scope&lt;/th&gt;
&lt;th&gt;File&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Every project&lt;/td&gt;
&lt;td&gt;&lt;code&gt;~/.claude/settings.json&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;One project&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;project&amp;gt;/.claude/settings.local.json&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A one-project setup leaves your other projects on your normal Anthropic plan.&lt;/p&gt;

&lt;p&gt;How the helper behaves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Claude Code runs &lt;code&gt;apiKeyHelper&lt;/code&gt; and sends what it prints as both &lt;code&gt;Authorization: Bearer&lt;/code&gt; and &lt;code&gt;x-api-key&lt;/code&gt;, which is why it works with gateways that read either header.&lt;/li&gt;
&lt;li&gt;It keeps the answer for five minutes. &lt;code&gt;CLAUDE_CODE_API_KEY_HELPER_TTL_MS&lt;/code&gt; changes that.&lt;/li&gt;
&lt;li&gt;If requests fail with &lt;code&gt;Your apiKeyHelper script is failing&lt;/code&gt;, the key file is missing or unreadable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key never lands in a settings file, so it does not end up in a backup, a dotfiles repository or a screen share. The pattern is the same for any provider's key.&lt;/p&gt;

&lt;p&gt;One more trap: Claude Code reads a project's own settings only after you trust that folder. On a computer where Claude Code was never set up, put the block in &lt;code&gt;~/.claude/settings.json&lt;/code&gt; first, or a brand-new install can still ask you to log in.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Which setting wins
&lt;/h2&gt;

&lt;p&gt;Settings files are read in this order, first one wins:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Managed settings (set by your company, if any)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;claude --settings &amp;lt;file&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;project&amp;gt;/.claude/settings.local.json&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;project&amp;gt;/.claude/settings.json&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;~/.claude/settings.json&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A variable in a settings file's &lt;code&gt;env&lt;/code&gt; block beats the same variable in your shell in most sessions. Two exceptions cause most "why is it still using my Anthropic login?" reports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The key.&lt;/strong&gt; Claude Code uses &lt;code&gt;ANTHROPIC_AUTH_TOKEN&lt;/code&gt; first, then &lt;code&gt;ANTHROPIC_API_KEY&lt;/code&gt;, then &lt;code&gt;apiKeyHelper&lt;/code&gt;. A token exported in your shell replaces the saved key.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The model.&lt;/strong&gt; &lt;code&gt;/model&lt;/code&gt; in the session wins, then &lt;code&gt;claude --model&lt;/code&gt;, then &lt;code&gt;ANTHROPIC_MODEL&lt;/code&gt;, then the &lt;code&gt;model&lt;/code&gt; setting. A shell &lt;code&gt;ANTHROPIC_MODEL&lt;/code&gt; beats the &lt;code&gt;model&lt;/code&gt; setting.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The fix is boring: once the settings file is in place, remove every &lt;code&gt;ANTHROPIC_*&lt;/code&gt; variable from your shell and your shell profile (&lt;code&gt;~/.zshrc&lt;/code&gt;, &lt;code&gt;~/.bashrc&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Models: keep Claude, or map every slot
&lt;/h2&gt;

&lt;p&gt;By default nothing is pinned. Claude Code asks for its own model names (&lt;code&gt;opus&lt;/code&gt;, &lt;code&gt;sonnet&lt;/code&gt;, &lt;code&gt;haiku&lt;/code&gt;), and a gateway that serves Claude models answers them.&lt;/p&gt;

&lt;p&gt;To run on other models, Claude Code has five slots, set in the &lt;code&gt;env&lt;/code&gt; block:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variable&lt;/th&gt;
&lt;th&gt;What it sets&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ANTHROPIC_MODEL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The model the session starts on&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ANTHROPIC_DEFAULT_OPUS_MODEL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What &lt;code&gt;opus&lt;/code&gt; means&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ANTHROPIC_DEFAULT_SONNET_MODEL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What &lt;code&gt;sonnet&lt;/code&gt; means&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ANTHROPIC_DEFAULT_HAIKU_MODEL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What &lt;code&gt;haiku&lt;/code&gt; means; also used for background work such as titles and summaries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;CLAUDE_CODE_SUBAGENT_MODEL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The model subagents run on&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Map every one. A slot left unset keeps asking for a Claude model; on a multi-model gateway that request is served and billed at Claude prices. The model must also support tool calls, since that is how Claude Code edits files and runs commands. On MartLLM a request with tools sent to a model that cannot call them is refused with &lt;code&gt;400 tools_not_supported&lt;/code&gt;; &lt;code&gt;GET https://api.martllm.com/v1/models&lt;/code&gt; marks &lt;code&gt;supports_tools&lt;/code&gt; on each chat model.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Context size and compaction
&lt;/h2&gt;

&lt;p&gt;Claude Code knows the context size of Claude models only. For any other model it assumes &lt;strong&gt;200,000 tokens&lt;/strong&gt; and compacts the conversation before that.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the model has a 1-million-token context, add &lt;code&gt;[1m]&lt;/code&gt; to the end of its id, for example &lt;code&gt;"ANTHROPIC_MODEL": "deepseek/deepseek-v4-pro[1m]"&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;For any other size, set &lt;code&gt;CLAUDE_CODE_MAX_CONTEXT_TOKENS&lt;/code&gt; to the model's real context, for example &lt;code&gt;"400000"&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;To choose when it compacts: &lt;code&gt;autoCompactWindow&lt;/code&gt; (or &lt;code&gt;CLAUDE_CODE_AUTO_COMPACT_WINDOW&lt;/code&gt;) takes a number of tokens from 100,000 to 1,000,000. &lt;code&gt;CLAUDE_AUTOCOMPACT_PCT_OVERRIDE&lt;/code&gt; (1 to 100) compacts earlier, at that share of the window. &lt;code&gt;autoCompactEnabled: false&lt;/code&gt; turns it off.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do not round up. A context set larger than the model has makes requests fail once the conversation outgrows the model.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. What changes when you leave Anthropic's endpoint
&lt;/h2&gt;

&lt;p&gt;These apply to any third-party endpoint, not just mine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Your claude.ai login is not used.&lt;/strong&gt; Features that need it, such as claude.ai connectors, &lt;code&gt;/schedule&lt;/code&gt; and Remote Control, are not available in that session.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The cost Claude Code shows is not your bill.&lt;/strong&gt; It is worked out on your computer from Anthropic's list prices, and shows nothing useful for other models. Read your provider's usage page instead. (On MartLLM, a status-line script can show your balance under the prompt; it reads &lt;code&gt;GET /v1/balance&lt;/code&gt; at most once a minute.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your code goes to whoever serves the model.&lt;/strong&gt; Everything the session reads is sent to the model. On a marketplace like MartLLM that means third-party providers, so do not use it in a repository that holds secrets, credentials or customer data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  7. Check it
&lt;/h2&gt;

&lt;p&gt;Start Claude Code and run &lt;code&gt;/status&lt;/code&gt;: the API address should be your provider's. Then call the Messages API directly with the same key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://api.martllm.com/v1/messages \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $(cat ~/.uberllm/key)"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"anthropic-version: 2023-06-01"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"content-type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"model":"claude-haiku-4-5","max_tokens":16,"messages":[{"role":"user","content":"ping"}]}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If that answers and Claude Code does not, the problem is in the settings order (section 3), not the endpoint.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Undo it
&lt;/h2&gt;

&lt;p&gt;Remove &lt;code&gt;apiKeyHelper&lt;/code&gt; and the &lt;code&gt;ANTHROPIC_*&lt;/code&gt; entries from the settings file, and unset any you exported. Claude Code goes back to your Anthropic login on the next start.&lt;/p&gt;

&lt;p&gt;If you used one of MartLLM's installers, each has its own undo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# installed with: curl -fsSL https://martllm.com/install/claude-code.sh | sh&lt;/span&gt;
curl -fsSL https://martllm.com/install/claude-code.sh &lt;span class="o"&gt;|&lt;/span&gt; sh -s -- --uninstall

&lt;span class="c"&gt;# installed with: npx uberllm init&lt;/span&gt;
npx uberllm init --undo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Uninstalling stops using the key; it does not revoke it. Delete the key in your provider's dashboard for any computer you no longer trust.&lt;/p&gt;

&lt;p&gt;MartLLM is prepaid credit with no free tier, so for a first test with one model family, a maker's own Anthropic-compatible endpoint is also a fine place to start. Sections 2 to 8 apply there too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MartLLM docs, Claude Code: &lt;a href="https://martllm.com/docs/claude-code" rel="noopener noreferrer"&gt;https://martllm.com/docs/claude-code&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MartLLM docs, Errors (&lt;code&gt;tools_not_supported&lt;/code&gt;): &lt;a href="https://martllm.com/docs/errors" rel="noopener noreferrer"&gt;https://martllm.com/docs/errors&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MartLLM docs, Models and routing (&lt;code&gt;/v1/models&lt;/code&gt; fields): &lt;a href="https://martllm.com/docs/models-and-routing" rel="noopener noreferrer"&gt;https://martllm.com/docs/models-and-routing&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Live model list: &lt;a href="https://api.martllm.com/v1/models" rel="noopener noreferrer"&gt;https://api.martllm.com/v1/models&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>devtools</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>GPT-6.2 API price compared: OpenAI, OpenRouter, Requesty and a marketplace (November 2026)</title>
      <dc:creator>Alex</dc:creator>
      <pubDate>Fri, 20 Nov 2026 02:03:46 +0000</pubDate>
      <link>https://dev.to/alex_martllm/gpt-62-api-price-compared-openai-openrouter-vercel-requesty-and-a-marketplace-november-2026-5fkp</link>
      <guid>https://dev.to/alex_martllm/gpt-62-api-price-compared-openai-openrouter-vercel-requesty-and-a-marketplace-november-2026-5fkp</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclosure: I run MartLLM (formerly UberLLM), one of the sellers in this table. Every other price was read on the seller's own pricing page or public price list on November 20, 2026. Links are at the bottom so you can check each one.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;GPT-6.2 Sol and GPT-6.2 Astra reached the API this week. Here is what one million tokens costs on each place I could find a public price for, and where the price is not what it looks like.&lt;/p&gt;

&lt;h2&gt;
  
  
  Standard price, USD per 1M tokens
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Seller&lt;/th&gt;
&lt;th&gt;Sol input&lt;/th&gt;
&lt;th&gt;Sol output&lt;/th&gt;
&lt;th&gt;Astra input&lt;/th&gt;
&lt;th&gt;Astra output&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;OpenAI (official)&lt;/td&gt;
&lt;td&gt;$2.00&lt;/td&gt;
&lt;td&gt;$10.00&lt;/td&gt;
&lt;td&gt;$8.00&lt;/td&gt;
&lt;td&gt;$40.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OpenRouter&lt;/td&gt;
&lt;td&gt;$2.00&lt;/td&gt;
&lt;td&gt;$10.00&lt;/td&gt;
&lt;td&gt;$8.00&lt;/td&gt;
&lt;td&gt;$40.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requesty (OpenAI)&lt;/td&gt;
&lt;td&gt;$2.00&lt;/td&gt;
&lt;td&gt;$10.00&lt;/td&gt;
&lt;td&gt;$8.00&lt;/td&gt;
&lt;td&gt;$40.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requesty (Azure, East US)&lt;/td&gt;
&lt;td&gt;$2.00&lt;/td&gt;
&lt;td&gt;$10.00&lt;/td&gt;
&lt;td&gt;$8.00&lt;/td&gt;
&lt;td&gt;$40.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requesty (Azure, EU regions)&lt;/td&gt;
&lt;td&gt;$2.40&lt;/td&gt;
&lt;td&gt;$12.00&lt;/td&gt;
&lt;td&gt;$9.60&lt;/td&gt;
&lt;td&gt;$48.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MartLLM, listed price&lt;/td&gt;
&lt;td&gt;$1.323&lt;/td&gt;
&lt;td&gt;$6.615&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$8.40&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$42.00&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MartLLM, best seller offer when I looked&lt;/td&gt;
&lt;td&gt;$0.552&lt;/td&gt;
&lt;td&gt;$2.762&lt;/td&gt;
&lt;td&gt;$2.199&lt;/td&gt;
&lt;td&gt;$10.995&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So the gateways all pass OpenAI's price through unchanged. The differences are in the rows below.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changes the bill
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cached input.&lt;/strong&gt; OpenAI charges $0.10 per 1M cached input tokens on Sol and $0.40 on Astra, a 95% cut. Requesty lists the same cached prices. If your prompts share a long prefix, this matters more than which gateway you pick.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Long prompts.&lt;/strong&gt; Requesty lists a second tier above about 272,000 prompt tokens: Sol goes to $4.00 input and $15.00 output, Astra to $16.00 and $60.00.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Waiting.&lt;/strong&gt; OpenAI's page says eligible background requests cost 30% below Standard with a 2-hour completion window and 40% below with an 8-hour window. OpenRouter lists a batch price at half: Sol $1.00 / $5.00, Astra $4.00 / $20.00.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Region.&lt;/strong&gt; OpenAI charges 10% more for data-residency endpoints. Requesty's Azure EU regions are 20% above East US.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  About the MartLLM rows
&lt;/h2&gt;

&lt;p&gt;MartLLM is a marketplace: sellers post offers for the same model and a request goes to the cheapest one that is serving. That gives two numbers, and I am showing both because one alone would mislead you.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;listed price&lt;/strong&gt; is the most you pay. For Sol it is 34% below OpenAI. For Astra it is 5% &lt;strong&gt;above&lt;/strong&gt; OpenAI, so if no cheaper seller is serving, Astra costs more here than at the source.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;best seller offer&lt;/strong&gt; moves through the day. It is what you pay when that seller has capacity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What buyers were actually billed over the last 7 days, all calls added up: GPT-6.2 Sol came out 70% below OpenAI's price (641 calls), GPT-6.2 Astra 40% below (49 calls). Small samples, new models; treat them as a first reading, not a promise.&lt;/p&gt;

&lt;p&gt;Adding credit by card costs 5.5% + $0.50 on MartLLM. Count that in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which one to pick
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You need the model the minute it ships, with batch, background and data residency: OpenAI direct.&lt;/li&gt;
&lt;li&gt;You want one key for many makers and do not mind paying list: OpenRouter or Requesty. Check each one's fee for adding credit.&lt;/li&gt;
&lt;li&gt;You want Sol below list and can live with a price that moves: a marketplace. Set a spending cap on the key and compare your first invoice against the listed price.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Prices move. If you spot one that changed, comment and I will update the table.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources (read 2026-11-20)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;OpenAI: &lt;a href="https://developers.openai.com/api/docs/pricing" rel="noopener noreferrer"&gt;https://developers.openai.com/api/docs/pricing&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OpenRouter public model list: &lt;a href="https://openrouter.ai/api/v1/models" rel="noopener noreferrer"&gt;https://openrouter.ai/api/v1/models&lt;/a&gt; (openai/gpt-6.2-sol, openai/gpt-6.2-astra and their :batch entries)&lt;/li&gt;
&lt;li&gt;Requesty public model list: &lt;a href="https://router.requesty.ai/v1/models" rel="noopener noreferrer"&gt;https://router.requesty.ai/v1/models&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MartLLM: &lt;a href="https://martllm.com/models/openai/gpt-6.2-sol" rel="noopener noreferrer"&gt;https://martllm.com/models/openai/gpt-6.2-sol&lt;/a&gt; , &lt;a href="https://martllm.com/models/openai/gpt-6.2-astra" rel="noopener noreferrer"&gt;https://martllm.com/models/openai/gpt-6.2-astra&lt;/a&gt; , public list &lt;a href="https://api.martllm.com/v1/models" rel="noopener noreferrer"&gt;https://api.martllm.com/v1/models&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>openai</category>
      <category>api</category>
      <category>pricing</category>
    </item>
    <item>
      <title>OpenRouter alternatives in November 2026: what each one is actually for</title>
      <dc:creator>Alex</dc:creator>
      <pubDate>Fri, 20 Nov 2026 01:09:05 +0000</pubDate>
      <link>https://dev.to/alex_martllm/openrouter-alternatives-in-november-2026-what-each-one-is-actually-for-2jco</link>
      <guid>https://dev.to/alex_martllm/openrouter-alternatives-in-november-2026-what-each-one-is-actually-for-2jco</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclosure: I run MartLLM (formerly UberLLM), one of the options below. Every other fact was read on that company's own page on November 20, 2026; links at the bottom.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;OpenRouter is the default answer for "one key, many models": hundreds of models behind one OpenAI-compatible API. It charges a 5.5% fee ($0.80 minimum) when you buy credits by card, 5% by crypto, and its free models are limited to 20 requests a minute and 50 a day (1,000 a day once you have bought at least 10 credits). You might look elsewhere for three reasons: a lower per-token price, your own provider keys, or more control. Every option here takes OpenAI-style requests, so switching is a new base URL and key.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you want a lower price on the same models
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;DeepInfra.&lt;/strong&gt; Runs models on its own inference infrastructure, with no upfront costs or contracts. Its price list now includes Claude and Gemini models alongside open models like DeepSeek, Qwen and Llama. &lt;em&gt;Watch for:&lt;/em&gt; no OpenAI GPT models on its list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Novita AI.&lt;/strong&gt; Open models, also available as a Hugging Face inference provider. &lt;em&gt;Watch for:&lt;/em&gt; mostly open models; check that yours is listed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MartLLM.&lt;/strong&gt; An API marketplace: sellers list capacity for a model and each request goes to a third-party provider, so prices move with the market. No fee on requests; adding credit by card costs 5.5% + $0.50. The same key also covers image, video, music and speech models. &lt;em&gt;Watch for:&lt;/em&gt; prices change during the day, and a request can cost more when cheaper sellers are busy (you can cap it with &lt;code&gt;provider.max_price&lt;/code&gt;). No free models, fewer models than OpenRouter, and a short track record: it opened in 2026.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you want routing and controls
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Requesty.&lt;/strong&gt; Routing rules and fallbacks, with budgets per user and API key (team spend controls look like an Enterprise feature). A 5% service fee is added when you top up credits; there is a free plan with 200 requests a day. Roo Code and Kilo Code both list it as a provider. &lt;em&gt;Watch for:&lt;/em&gt; model prices plus 5%, so not cheaper per token.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you already hold provider keys
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;LiteLLM.&lt;/strong&gt; Open-source proxy you run yourself, free under the MIT licence. &lt;em&gt;Watch for:&lt;/em&gt; you run and update the server, and pay each provider directly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloudflare AI Gateway.&lt;/strong&gt; Caching, logs and rate limits in front of your providers, in your Cloudflare account. Provider prices pass through with no markup; 5% is added to credits bought through its Unified Billing. &lt;em&gt;Watch for:&lt;/em&gt; its OpenAI-style chat completions endpoint is deprecated for single-model calls; Cloudflare points new integrations to its REST API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Portkey&lt;/strong&gt; was a common pick here; it is now sold as Palo Alto Networks' Prisma AIRS AI Gateway, with sales-led pricing, so check whether it still fits a small team.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to choose
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Lowest per-token price on models OpenRouter also sells: compare the exact model on DeepInfra, Novita and MartLLM. It changes by model; no one is cheapest on everything.&lt;/li&gt;
&lt;li&gt;Spend controls and fallbacks, price not the issue: Requesty.&lt;/li&gt;
&lt;li&gt;You have keys and want control: LiteLLM (self-hosted) or Cloudflare AI Gateway (hosted).&lt;/li&gt;
&lt;li&gt;Need free models: stay on OpenRouter.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources (read 2026-11-20)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;OpenRouter: &lt;a href="https://openrouter.ai/docs/faq" rel="noopener noreferrer"&gt;https://openrouter.ai/docs/faq&lt;/a&gt; , &lt;a href="https://openrouter.ai/docs/api-reference/limits" rel="noopener noreferrer"&gt;https://openrouter.ai/docs/api-reference/limits&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;DeepInfra: &lt;a href="https://deepinfra.com/pricing" rel="noopener noreferrer"&gt;https://deepinfra.com/pricing&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Novita on Hugging Face: &lt;a href="https://huggingface.co/docs/inference-providers/providers/novita" rel="noopener noreferrer"&gt;https://huggingface.co/docs/inference-providers/providers/novita&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Requesty: &lt;a href="https://requesty.ai/pricing" rel="noopener noreferrer"&gt;https://requesty.ai/pricing&lt;/a&gt; , &lt;a href="https://roocodeinc.github.io/Roo-Code/providers/requesty" rel="noopener noreferrer"&gt;https://roocodeinc.github.io/Roo-Code/providers/requesty&lt;/a&gt; , &lt;a href="https://kilo.ai/docs/providers/requesty" rel="noopener noreferrer"&gt;https://kilo.ai/docs/providers/requesty&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;LiteLLM: &lt;a href="https://litellm.ai" rel="noopener noreferrer"&gt;https://litellm.ai&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Cloudflare AI Gateway: &lt;a href="https://developers.cloudflare.com/ai-gateway/features/unified-billing/" rel="noopener noreferrer"&gt;https://developers.cloudflare.com/ai-gateway/features/unified-billing/&lt;/a&gt; , &lt;a href="https://developers.cloudflare.com/ai-gateway/usage/chat-completion/" rel="noopener noreferrer"&gt;https://developers.cloudflare.com/ai-gateway/usage/chat-completion/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Portkey: &lt;a href="https://portkey.ai/docs/product/enterprise-offering" rel="noopener noreferrer"&gt;https://portkey.ai/docs/product/enterprise-offering&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;MartLLM: &lt;a href="https://martllm.com/llm-api-pricing" rel="noopener noreferrer"&gt;https://martllm.com/llm-api-pricing&lt;/a&gt; , &lt;a href="https://martllm.com/how-it-works" rel="noopener noreferrer"&gt;https://martllm.com/how-it-works&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>api</category>
      <category>openrouter</category>
    </item>
    <item>
      <title>What AI video APIs actually cost per second in late 2026 (Veo 3.1, Kling, Seedance, Hailuo, Wan, LTX, Vidu)</title>
      <dc:creator>Alex</dc:creator>
      <pubDate>Fri, 20 Nov 2026 01:05:35 +0000</pubDate>
      <link>https://dev.to/alex_martllm/seedance-kling-and-veo-31-api-prices-per-second-compared-across-6-sellers-november-2026-287o</link>
      <guid>https://dev.to/alex_martllm/seedance-kling-and-veo-31-api-prices-per-second-compared-across-6-sellers-november-2026-287o</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclosure: I'm Alex, and I run MartLLM, the marketplace these prices come from. Every number below was read from its public catalog on 2026-11-28 at 03:51 UTC. That catalog is public JSON, so you can check any row yourself (link at the end). Where I have an outside list price, it's in the table, including where we aren't the lowest.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;"How much does a video API cost?" has no single answer, because nobody bills video the same way. Some models charge per second. Some charge per clip. Most per-second models have a different rate for each resolution, and several double the rate when you turn sound on. A table with one number per model hides exactly the things that change your bill.&lt;/p&gt;

&lt;p&gt;So this table keeps each model's own unit and tiers. All the models below bill &lt;strong&gt;per second of finished video&lt;/strong&gt;. A clip costs its length times the rate for the settings you asked for.&lt;/p&gt;

&lt;h2&gt;
  
  
  The table
&lt;/h2&gt;

&lt;p&gt;"List" is the maker's official per-second price as the catalog records it. "Now" is what the catalog listed at fetch time. &lt;strong&gt;Fixed&lt;/strong&gt; rows have a set price: the cost is known when the job starts and that's what it's billed. &lt;strong&gt;Live&lt;/strong&gt; rows come from a market of sellers and can move during the day. For those, the API reply states the most a job can cost before it starts.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model (id)&lt;/th&gt;
&lt;th&gt;Setting&lt;/th&gt;
&lt;th&gt;List / s&lt;/th&gt;
&lt;th&gt;Now / s&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Veo 3.1 Lite, text to video (&lt;code&gt;google/veo-3.1-lite&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;720p, no sound&lt;/td&gt;
&lt;td&gt;$0.03&lt;/td&gt;
&lt;td&gt;$0.0255&lt;/td&gt;
&lt;td&gt;fixed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;720p, with sound&lt;/td&gt;
&lt;td&gt;$0.05&lt;/td&gt;
&lt;td&gt;$0.0425&lt;/td&gt;
&lt;td&gt;fixed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;1080p, no sound&lt;/td&gt;
&lt;td&gt;$0.05&lt;/td&gt;
&lt;td&gt;$0.0425&lt;/td&gt;
&lt;td&gt;fixed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;1080p, with sound&lt;/td&gt;
&lt;td&gt;$0.08&lt;/td&gt;
&lt;td&gt;$0.068&lt;/td&gt;
&lt;td&gt;fixed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Veo 3.1 Fast, image to video (&lt;code&gt;google/veo3-1-fast-image-to-video&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;720p&lt;/td&gt;
&lt;td&gt;$0.165&lt;/td&gt;
&lt;td&gt;$0.084&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;1080p&lt;/td&gt;
&lt;td&gt;$0.165&lt;/td&gt;
&lt;td&gt;$0.0862&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;4K&lt;/td&gt;
&lt;td&gt;$0.385&lt;/td&gt;
&lt;td&gt;$0.252&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Veo 3.1, image to video (&lt;code&gt;google/veo3-1-full-image-to-video&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;720p / 1080p&lt;/td&gt;
&lt;td&gt;$0.44&lt;/td&gt;
&lt;td&gt;$0.1725&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;4K&lt;/td&gt;
&lt;td&gt;$0.66&lt;/td&gt;
&lt;td&gt;$0.345&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kling V3 Standard, image to video (&lt;code&gt;kling/kling-v3-standard-image-to-video&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;one rate&lt;/td&gt;
&lt;td&gt;$0.14&lt;/td&gt;
&lt;td&gt;$0.0732&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kling V3 Pro, image to video (&lt;code&gt;kling/kling-v3-pro-image-to-video&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;one rate&lt;/td&gt;
&lt;td&gt;$0.1833&lt;/td&gt;
&lt;td&gt;$0.0972&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kling O3 Pro, image to video (&lt;code&gt;kling/kling-o3-pro-image-to-video&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;one rate&lt;/td&gt;
&lt;td&gt;$0.1533&lt;/td&gt;
&lt;td&gt;$0.1333&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kling 2.5 Turbo Pro, image to video (&lt;code&gt;kling/kling-2-5-turbo-pro-image-to-video&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;one rate&lt;/td&gt;
&lt;td&gt;$0.078&lt;/td&gt;
&lt;td&gt;$0.0666&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Seedance 2.5, image to video (&lt;code&gt;venice/seedance-2-5-image-to-video-basic&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;480p&lt;/td&gt;
&lt;td&gt;$0.1287&lt;/td&gt;
&lt;td&gt;$0.0839&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;720p&lt;/td&gt;
&lt;td&gt;$0.289&lt;/td&gt;
&lt;td&gt;$0.1886&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;1080p&lt;/td&gt;
&lt;td&gt;$0.7107&lt;/td&gt;
&lt;td&gt;$0.4667&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Seedance 2.0, image to video (&lt;code&gt;bytedance/seedance-2-0-image-to-video&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;480p&lt;/td&gt;
&lt;td&gt;$0.088&lt;/td&gt;
&lt;td&gt;$0.0593&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;720p&lt;/td&gt;
&lt;td&gt;$0.19&lt;/td&gt;
&lt;td&gt;$0.1276&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;1080p&lt;/td&gt;
&lt;td&gt;$0.468&lt;/td&gt;
&lt;td&gt;$0.3185&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Seedance 2.0 Fast, image to video (&lt;code&gt;bytedance/seedance-2-0-fast-image-to-video&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;480p&lt;/td&gt;
&lt;td&gt;$0.07&lt;/td&gt;
&lt;td&gt;$0.0403&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;720p&lt;/td&gt;
&lt;td&gt;$0.152&lt;/td&gt;
&lt;td&gt;$0.0769&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Seedance 2.0 Mini, image to video (&lt;code&gt;bytedance/seedance-2-0-mini-image-to-video&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;480p&lt;/td&gt;
&lt;td&gt;$0.044&lt;/td&gt;
&lt;td&gt;$0.0163&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;720p&lt;/td&gt;
&lt;td&gt;$0.094&lt;/td&gt;
&lt;td&gt;$0.0351&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hailuo 02 Standard, image to video (&lt;code&gt;minimax/hailuo-02-standard-image-to-video&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;768p&lt;/td&gt;
&lt;td&gt;$0.045&lt;/td&gt;
&lt;td&gt;$0.03825&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;512p&lt;/td&gt;
&lt;td&gt;$0.017&lt;/td&gt;
&lt;td&gt;$0.01445&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wan 3.0 (&lt;code&gt;wan/wan-3-0&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;480p&lt;/td&gt;
&lt;td&gt;$0.04&lt;/td&gt;
&lt;td&gt;$0.0332&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;720p&lt;/td&gt;
&lt;td&gt;$0.08&lt;/td&gt;
&lt;td&gt;$0.0665&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;1080p&lt;/td&gt;
&lt;td&gt;$0.16&lt;/td&gt;
&lt;td&gt;$0.1329&lt;/td&gt;
&lt;td&gt;live&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LTX 2.3, text to video (&lt;code&gt;lightricks/ltx-2-3-text-to-video&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;1080p&lt;/td&gt;
&lt;td&gt;$0.08&lt;/td&gt;
&lt;td&gt;$0.068&lt;/td&gt;
&lt;td&gt;fixed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;1440p&lt;/td&gt;
&lt;td&gt;$0.16&lt;/td&gt;
&lt;td&gt;$0.136&lt;/td&gt;
&lt;td&gt;fixed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;2160p&lt;/td&gt;
&lt;td&gt;$0.32&lt;/td&gt;
&lt;td&gt;$0.272&lt;/td&gt;
&lt;td&gt;fixed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vidu Q3 Turbo, text to video (&lt;code&gt;vidu/viduq3-turbo-text-to-video&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;360p / 540p&lt;/td&gt;
&lt;td&gt;$0.035&lt;/td&gt;
&lt;td&gt;$0.02975&lt;/td&gt;
&lt;td&gt;fixed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;720p / 1080p&lt;/td&gt;
&lt;td&gt;$0.077&lt;/td&gt;
&lt;td&gt;$0.06545&lt;/td&gt;
&lt;td&gt;fixed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The catalog had &lt;strong&gt;303 video models with a live per-second price&lt;/strong&gt; when I pulled it. The table is the subset people ask about most, plus the cheapest tier of each.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a real clip costs
&lt;/h2&gt;

&lt;p&gt;Per-second rates are hard to picture. Here are typical clips at the "Now" price:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Clip&lt;/th&gt;
&lt;th&gt;Math&lt;/th&gt;
&lt;th&gt;Cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Veo 3.1 Lite, 8 s, 720p with sound&lt;/td&gt;
&lt;td&gt;8 × $0.0425&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$0.34&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Veo 3.1 Fast, 8 s, 720p&lt;/td&gt;
&lt;td&gt;8 × $0.084&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$0.67&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kling V3 Standard, 5 s&lt;/td&gt;
&lt;td&gt;5 × $0.0732&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$0.37&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Seedance 2.0 Mini, 5 s, 480p&lt;/td&gt;
&lt;td&gt;5 × $0.0163&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$0.08&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Seedance 2.5, 5 s, 720p&lt;/td&gt;
&lt;td&gt;5 × $0.1886&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$0.94&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hailuo 02 Standard, 6 s, 768p&lt;/td&gt;
&lt;td&gt;6 × $0.03825&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$0.23&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LTX 2.3, 10 s, 1080p&lt;/td&gt;
&lt;td&gt;10 × $0.068&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$0.68&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three things jump out:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Resolution is the biggest lever.&lt;/strong&gt; Seedance 2.0 goes from $0.0593 at 480p to $0.3185 at 1080p, more than 5×. Seedance 2.5 does about the same. If the clip ends up in a phone feed, check whether 480p or 720p is enough before you default to 1080p.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sound often costs extra.&lt;/strong&gt; On Veo 3.1 Lite, sound takes 720p from $0.0255 to $0.0425 a second. Several Kling and Veo models add sound unless you send &lt;code&gt;"audio": false&lt;/code&gt;, so set it on purpose.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Mini", "Fast", "Lite" and "Turbo" are real price tiers.&lt;/strong&gt; Seedance 2.0 Mini at 480p costs about a quarter of Seedance 2.0 at the same resolution. For drafts and A/B tests, prototype on the small tier and render finals on the big one.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Outside prices I could check
&lt;/h2&gt;

&lt;p&gt;For two models I have a public price from another source on the same setting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Veo 3.1 Lite&lt;/strong&gt;: Google Vertex AI lists $0.03/s (720p, no sound) and $0.05/s (720p, with sound), as recorded on MartLLM's Veo comparison page (Google's list read 30 Oct 2026). An 8-second 720p clip with sound costs $0.40 at Vertex and $0.34 here. Details on the &lt;a href="https://martllm.com/answers/veo-3-api-price-per-second" rel="noopener noreferrer"&gt;Veo 3.1 price per second page&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Seedance 2.0&lt;/strong&gt;: Replicate lists $0.08/s at 480p. The catalog's live rate for Seedance 2.0 image to video at 480p was $0.0593. Since that rate comes from a live market, the &lt;a href="https://martllm.com/answers/seedance-api-price-per-second" rel="noopener noreferrer"&gt;Seedance price per second page&lt;/a&gt; shows it alongside Replicate's.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sora 2&lt;/strong&gt;: MartLLM doesn't sell Sora 2 at a fixed per-second price today. Replicate lists $0.10/s. If Sora is a must for you, that's the number to plan with.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I left out, and why
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rows where the live price sat above the catalog's list price&lt;/strong&gt; at fetch time (Grok Imagine, Kling 4.0, Seedance 2.5 Flash at 480p). The list figure may be stale or the market may have been thin. Either way, check those on their model pages before you build on them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Models with no list price&lt;/strong&gt;, so there's nothing to compare against.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Card fees.&lt;/strong&gt; Credit on MartLLM is prepaid. A card top-up adds 5.5% + $0.50, and calls carry no extra fee on top. If you compare with a provider that bills monthly in arrears, add that fee to our side.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How billing works under these numbers
&lt;/h2&gt;

&lt;p&gt;This part is MartLLM-specific, but similar rules exist on most video APIs, so check your provider's:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A failed, canceled or expired job costs nothing.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You can price a request for free.&lt;/strong&gt; Send it with &lt;code&gt;"validate": true&lt;/code&gt; to get the listed cost and the most it can be billed, with nothing made or charged.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The reply states the ceiling.&lt;/strong&gt; Every job comes back with &lt;code&gt;max_cost_usd&lt;/code&gt;, the amount held while it runs and the most it's billed. Send your own &lt;code&gt;max_cost&lt;/code&gt; to cap it lower.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Check it yourself
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Live table, every video model: &lt;a href="https://martllm.com/video-api-pricing" rel="noopener noreferrer"&gt;martllm.com/video-api-pricing&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Raw JSON behind this post (no key needed): &lt;code&gt;https://martllm.com/api/v1/public/models&lt;/code&gt;. Video models carry &lt;code&gt;media_unit&lt;/code&gt;, and per-tier rates are in &lt;code&gt;media_rates&lt;/code&gt; or &lt;code&gt;media_by_resolution&lt;/code&gt; (&lt;code&gt;usd_per_second&lt;/code&gt;, &lt;code&gt;list_usd_per_second&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Each model's Markdown spec (parameters, allowed lengths, price): add &lt;code&gt;.md&lt;/code&gt; to its model page URL, e.g. &lt;code&gt;https://martllm.com/models/google/veo-3.1-lite.md&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Prices move weekly, and the market rows move daily. If you're reading this after November 2026, use the links above rather than the table.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Alex, CEO, MartLLM&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>video</category>
      <category>api</category>
      <category>pricing</category>
    </item>
    <item>
      <title>Run Claude Code on DeepSeek, GLM or Kimi: settings, what breaks, and fixes</title>
      <dc:creator>Alex</dc:creator>
      <pubDate>Thu, 19 Nov 2026 07:54:29 +0000</pubDate>
      <link>https://dev.to/alex_martllm/run-claude-code-on-deepseek-glm-or-kimi-settings-what-breaks-and-fixes-2l0p</link>
      <guid>https://dev.to/alex_martllm/run-claude-code-on-deepseek-glm-or-kimi-settings-what-breaks-and-fixes-2l0p</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclosure: I'm Alex, the founder of &lt;a href="https://martllm.com" rel="noopener noreferrer"&gt;MartLLM (formerly UberLLM)&lt;/a&gt;, a marketplace API with an Anthropic-compatible endpoint. The examples use it because it is the one I know. The settings themselves apply to any Anthropic-compatible endpoint, and the last section gives each model maker's own endpoint, which is the most direct route.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Claude Code talks to one API: Anthropic's Messages API. It does not care who answers, as long as the answer has the right shape. So it can run on DeepSeek, GLM or Kimi models. It also breaks in quiet ways when one setting is missing. This post is the settings, what changes on a model that is not Claude, and the errors people have hit with their fixes.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The address and the key
&lt;/h2&gt;

&lt;p&gt;Claude Code reads two settings to use another endpoint. It adds &lt;code&gt;/v1/messages&lt;/code&gt; to the base URL itself, so the base URL has &lt;strong&gt;no &lt;code&gt;/v1&lt;/code&gt; at the end&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://api.martllm.com
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_AUTH_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ull_your_key
claude
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;/status&lt;/code&gt; inside Claude Code to see which address it is using.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Map every model slot
&lt;/h2&gt;

&lt;p&gt;This is the part people get wrong. Claude Code does not use one model. It has slots, and each one asks for a Claude model name unless you say otherwise:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variable&lt;/th&gt;
&lt;th&gt;What it sets&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ANTHROPIC_MODEL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The model the session starts on&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ANTHROPIC_DEFAULT_OPUS_MODEL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What &lt;code&gt;opus&lt;/code&gt; means&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ANTHROPIC_DEFAULT_SONNET_MODEL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What &lt;code&gt;sonnet&lt;/code&gt; means&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ANTHROPIC_DEFAULT_HAIKU_MODEL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;What &lt;code&gt;haiku&lt;/code&gt; means; also used for background work such as titles and summaries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;CLAUDE_CODE_SUBAGENT_MODEL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The model subagents run on&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A slot left unset keeps asking for a Claude model. On a single-maker endpoint that request fails. On a multi-model endpoint it is served, and you pay Claude prices for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Tell Claude Code the context size
&lt;/h2&gt;

&lt;p&gt;Claude Code knows the context size of Claude models only. For any other model it assumes 200,000 tokens and compacts the conversation before that.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the model has a 1M-token context, end the main model id with &lt;code&gt;[1m]&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;For any other size, set &lt;code&gt;CLAUDE_CODE_MAX_CONTEXT_TOKENS&lt;/code&gt; to the real size.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do not round up. A context set larger than the model has makes requests fail once the conversation outgrows the model.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. One block per model family
&lt;/h2&gt;

&lt;p&gt;Model ids are as they were in our catalog on November 19, 2026. All three models take tool calls, which Claude Code needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DeepSeek&lt;/strong&gt; (DeepSeek V4.1 Flash, 1,048,576 tokens of context):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://api.martllm.com
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_AUTH_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ull_your_key
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'deepseek/deepseek-v4.1-flash[1m]'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_DEFAULT_OPUS_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'deepseek/deepseek-v4.1-flash'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_DEFAULT_SONNET_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'deepseek/deepseek-v4.1-flash'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_DEFAULT_HAIKU_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'deepseek/deepseek-v4.1-flash'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;CLAUDE_CODE_SUBAGENT_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'deepseek/deepseek-v4.1-flash'&lt;/span&gt;
claude
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;GLM&lt;/strong&gt; (GLM 5.3, 1,000,000 tokens of context):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://api.martllm.com
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_AUTH_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ull_your_key
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'z-ai/glm-5.3[1m]'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_DEFAULT_OPUS_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'z-ai/glm-5.3'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_DEFAULT_SONNET_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'z-ai/glm-5.3'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_DEFAULT_HAIKU_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'z-ai/glm-5.3'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;CLAUDE_CODE_SUBAGENT_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'z-ai/glm-5.3'&lt;/span&gt;
claude
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Kimi&lt;/strong&gt; (Kimi K3.1 Pro, 1,048,576 tokens of context):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://api.martllm.com
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_AUTH_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ull_your_key
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'moonshotai/kimi-k3.1-pro[1m]'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_DEFAULT_OPUS_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'moonshotai/kimi-k3.1-pro'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_DEFAULT_SONNET_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'moonshotai/kimi-k3.1-pro'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_DEFAULT_HAIKU_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'moonshotai/kimi-k3.1-pro'&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;CLAUDE_CODE_SUBAGENT_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'moonshotai/kimi-k3.1-pro'&lt;/span&gt;
claude
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Keep it in a settings file, with the key out of it
&lt;/h2&gt;

&lt;p&gt;Save the key to a file only you can read:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir -p ~/.uberllm &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; chmod 700 ~/.uberllm
&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s1"&gt;'%s\n'&lt;/span&gt; &lt;span class="s1"&gt;'ull_your_key'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/.uberllm/key &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; chmod 600 ~/.uberllm/key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then put the address, a key helper and the model variables in &lt;code&gt;~/.claude/settings.json&lt;/code&gt; (every project) or &lt;code&gt;&amp;lt;project&amp;gt;/.claude/settings.local.json&lt;/code&gt; (one project; your other projects stay on your Anthropic plan):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"apiKeyHelper"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"cat ~/.uberllm/key"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_BASE_URL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://api.martllm.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek/deepseek-v4.1-flash[1m]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_DEFAULT_OPUS_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek/deepseek-v4.1-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_DEFAULT_SONNET_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek/deepseek-v4.1-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_DEFAULT_HAIKU_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek/deepseek-v4.1-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"CLAUDE_CODE_SUBAGENT_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek/deepseek-v4.1-flash"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Claude Code runs &lt;code&gt;apiKeyHelper&lt;/code&gt; to get the key, so the key is never written into a settings file. Once the file is in place, remove every &lt;code&gt;ANTHROPIC_*&lt;/code&gt; variable from your shell and shell profile: a token exported in the shell replaces the saved key, and &lt;code&gt;ANTHROPIC_MODEL&lt;/code&gt; exported in the shell beats the model setting.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Check that it works
&lt;/h2&gt;

&lt;p&gt;Start Claude Code and run &lt;code&gt;/status&lt;/code&gt;. Then test the Messages API directly, which is the address Claude Code calls:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://api.martllm.com/v1/messages \
  -H &lt;span class="s2"&gt;"Authorization: Bearer $(cat ~/.uberllm/key)"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"anthropic-version: 2023-06-01"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"content-type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"model":"deepseek/deepseek-v4.1-flash","max_tokens":16,"messages":[{"role":"user","content":"ping"}]}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run a real task in a scratch folder and check that files actually change. Some models are weaker at long tool loops than Claude, and no endpoint fixes that.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. What changes on a model that is not Claude
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tool calls.&lt;/strong&gt; Claude Code works through tool calls, so it needs a model that takes them. On our endpoint a request with tools sent to a model that cannot call them is refused with &lt;code&gt;400 tools_not_supported&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thinking blocks.&lt;/strong&gt; Claude Code requires a &lt;code&gt;signature&lt;/code&gt; field on thinking it gets back. Some providers sent DeepSeek's reasoning without it, and a long session could stop. We fixed that on our side on October 28, 2026.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DeepSeek, thinking and tools.&lt;/strong&gt; DeepSeek's thinking mode wants the reasoning of every earlier turn sent back when tools are used, and answers 400 when it is missing. When a DeepSeek provider refuses a tool call for that reason, we answer the call with thinking off instead of failing it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kimi sampling.&lt;/strong&gt; Kimi K3 and Kimi K3.1 Pro run at a fixed temperature and top_p and refuse a request that sets its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The cost Claude Code shows is not your bill.&lt;/strong&gt; It is worked out on your computer from Anthropic's list prices. Look at your provider's usage page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your claude.ai login is not used.&lt;/strong&gt; Features that need it, such as claude.ai connectors, &lt;code&gt;/schedule&lt;/code&gt; and Remote Control, are not available.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your code goes to whoever serves the model.&lt;/strong&gt; See the trade-offs below.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  8. Troubleshooting
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What you see&lt;/th&gt;
&lt;th&gt;Cause and fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Missing required field in assistant message: 'signature'&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The endpoint returned thinking without a signature. Fixed on ours since October 28, 2026; on another endpoint, turn thinking off.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Parameter 'temperature'=0.5 is not supported for kimi-k3 model.&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Kimi runs at a fixed temperature. Since November 18, 2026 we resend such a request without that setting; elsewhere, remove it.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Your apiKeyHelper script is failing.&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The key file is missing or unreadable. Save the key again with the two commands in section 5.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claude Code still asks you to log in, or still uses your Anthropic plan&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;ANTHROPIC_AUTH_TOKEN&lt;/code&gt; or &lt;code&gt;ANTHROPIC_API_KEY&lt;/code&gt; exported in the shell wins over the saved key. Also, Claude Code reads a project's settings only after you trust that folder.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claude models on your bill&lt;/td&gt;
&lt;td&gt;A model slot was left unset. Set &lt;code&gt;ANTHROPIC_MODEL&lt;/code&gt; and all four slot variables.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requests fail once the conversation gets long&lt;/td&gt;
&lt;td&gt;The context you told Claude Code is larger than the model has. Use the real size.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;400 context_length_exceeded&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The prompt is longer than the model takes. The message gives both sizes.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;404 model_not_found&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The model id is not in the catalog. &lt;code&gt;GET https://api.martllm.com/v1/models&lt;/code&gt; lists the ids.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;402 insufficient_credits&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The prepaid balance cannot cover the request, so it was not sent.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;503 no_available_provider&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Nobody can serve that model right now, even after retries. Retry shortly or pick another model. Nothing was charged.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;429 rate_limited&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The key went over its request limit per minute. Wait and retry.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  9. Switch back to Claude
&lt;/h2&gt;

&lt;p&gt;Close the terminal, or clear the variables in it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;unset&lt;/span&gt; ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_MODEL \
  ANTHROPIC_DEFAULT_OPUS_MODEL ANTHROPIC_DEFAULT_SONNET_MODEL \
  ANTHROPIC_DEFAULT_HAIKU_MODEL CLAUDE_CODE_SUBAGENT_MODEL \
  CLAUDE_CODE_MAX_CONTEXT_TOKENS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a settings file, remove &lt;code&gt;apiKeyHelper&lt;/code&gt; and the &lt;code&gt;ANTHROPIC_*&lt;/code&gt; entries of its &lt;code&gt;env&lt;/code&gt; block. Claude Code goes back to your Anthropic login on the next start.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. The direct route: each maker's own endpoint
&lt;/h2&gt;

&lt;p&gt;You do not need a marketplace for this. Each maker publishes an Anthropic-compatible endpoint, used with a key from that maker. From each maker's own docs, read on November 19, 2026:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Kimi (Moonshot AI):&lt;/strong&gt; &lt;code&gt;ANTHROPIC_BASE_URL&lt;/code&gt; is &lt;code&gt;https://api.moonshot.ai/anthropic&lt;/code&gt; and the model is &lt;code&gt;kimi-k3[1m]&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GLM (Z.ai):&lt;/strong&gt; &lt;code&gt;ANTHROPIC_BASE_URL&lt;/code&gt; is &lt;code&gt;https://api.z.ai/api/anthropic&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DeepSeek:&lt;/strong&gt; &lt;code&gt;ANTHROPIC_BASE_URL&lt;/code&gt; is &lt;code&gt;https://api.deepseek.com/anthropic&lt;/code&gt;. Their page lists what that endpoint ignores, such as &lt;code&gt;cache_control&lt;/code&gt; and the &lt;code&gt;budget_tokens&lt;/code&gt; of thinking.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A maker's endpoint serves that maker's models, billed by that maker. Sections 2, 3, 8 and 9 apply to them too.&lt;/p&gt;

&lt;h2&gt;
  
  
  The trade-offs of doing this through MartLLM
&lt;/h2&gt;

&lt;p&gt;I would rather you read these from me than find them later:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Third-party sellers.&lt;/strong&gt; We do not run the models. Each request is served by a third-party provider through a seller's account, and everything the session reads is sent there. Do not use it in a repository that holds secrets, credentials or customer data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;We save requests for 90 days by default.&lt;/strong&gt; Each API key has a "Do not save my requests and answers" switch that turns this off.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Our checks have limits.&lt;/strong&gt; No software check proves which weights produced an answer. What we test, and what we cannot prove, is at &lt;a href="https://martllm.com/verification" rel="noopener noreferrer"&gt;martllm.com/verification&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It is prepaid, from $5, by card or PayPal. There is no free credit.&lt;/strong&gt; If you only want to try one model family, the maker's own endpoint in section 10 is the simpler test.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;We are a new company&lt;/strong&gt; with no independent reviews yet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full guide, with the current model table, lives at &lt;a href="https://martllm.com/answers/claude-code-with-deepseek-glm-kimi" rel="noopener noreferrer"&gt;martllm.com/answers/claude-code-with-deepseek-glm-kimi&lt;/a&gt;. If a setting here is wrong for your version of Claude Code, tell me in the comments and I will fix the post.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>llm</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
