<?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: Aviv Shaked</title>
    <description>The latest articles on DEV Community by Aviv Shaked (@aviv_shaked).</description>
    <link>https://dev.to/aviv_shaked</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3923089%2F8d30aec4-81ff-4403-b29f-5e38e05b50a3.png</url>
      <title>DEV Community: Aviv Shaked</title>
      <link>https://dev.to/aviv_shaked</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aviv_shaked"/>
    <language>en</language>
    <item>
      <title>How to use your Claude Pro/Max subscription with the Agent SDK (Python + TypeScript)</title>
      <dc:creator>Aviv Shaked</dc:creator>
      <pubDate>Sun, 10 May 2026 09:52:30 +0000</pubDate>
      <link>https://dev.to/aviv_shaked/how-to-use-your-claude-promax-subscription-with-the-agent-sdk-python-typescript-4emi</link>
      <guid>https://dev.to/aviv_shaked/how-to-use-your-claude-promax-subscription-with-the-agent-sdk-python-typescript-4emi</guid>
      <description>&lt;p&gt;If you pay for Claude Pro or Max and also script things against Claude from your own code, you might be double-paying. Anthropic keeps subscription billing and API credits as completely separate accounts — and the regular &lt;code&gt;anthropic&lt;/code&gt; SDK only knows about the API one. But there's an officially-supported path that lets the &lt;strong&gt;Claude Agent SDK&lt;/strong&gt; bill against your subscription instead. Here's how it works in Python and TypeScript.&lt;/p&gt;

&lt;p&gt;A small companion repo with the full setup, both languages side by side, and worked examples:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://github.com/avivshaked/prototype-with-claude-max" rel="noopener noreferrer"&gt;github.com/avivshaked/prototype-with-claude-max&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here's the mental model.&lt;/p&gt;

&lt;h2&gt;
  
  
  The two-token mental model
&lt;/h2&gt;

&lt;p&gt;Anthropic keeps two separate billing relationships:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Auth&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;th&gt;Where you pay&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ANTHROPIC_API_KEY&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Console API key&lt;/td&gt;
&lt;td&gt;Pay-as-you-go API credits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;CLAUDE_CODE_OAUTH_TOKEN&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;OAuth token from &lt;code&gt;claude setup-token&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Your Pro/Max subscription&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The regular &lt;code&gt;anthropic&lt;/code&gt; SDK only knows about the first one. The &lt;strong&gt;Agent SDK&lt;/strong&gt; (&lt;code&gt;claude-agent-sdk&lt;/code&gt; for Python, &lt;code&gt;@anthropic-ai/claude-agent-sdk&lt;/code&gt; for TypeScript) wraps the Claude Code CLI, which natively understands both — and on the OAuth path, every call lands on your subscription quota.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hello-world
&lt;/h2&gt;

&lt;p&gt;Generate the token:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @anthropic-ai/claude-code
claude setup-token   &lt;span class="c"&gt;# opens a browser, returns a 1-year token&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Drop it into &lt;code&gt;.env&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then in Python:&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="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;asyncio&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;sys&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dotenv&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load_dotenv&lt;/span&gt;

&lt;span class="nf"&gt;load_dotenv&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;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="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ANTHROPIC_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ANTHROPIC_API_KEY is set — it would shadow your OAuth token. unset it.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;claude_agent_sdk&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ClaudeAgentOptions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;AssistantMessage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TextBlock&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Say hello in one short sentence.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;ClaudeAgentOptions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;allowed_tools&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="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;isinstance&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;AssistantMessage&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;block&lt;/span&gt; &lt;span class="ow"&gt;in&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="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TextBlock&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
                    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;block&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;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. Bills against your Max subscription, not API credits. The repo has the same thing in TypeScript, plus a &lt;code&gt;WebSearch&lt;/code&gt; + token-by-token streaming example.&lt;/p&gt;

&lt;h2&gt;
  
  
  The gotcha worth knowing about
&lt;/h2&gt;

&lt;p&gt;Auth precedence on the SDK is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;cloud creds → 2. &lt;code&gt;ANTHROPIC_AUTH_TOKEN&lt;/code&gt; → 3. &lt;code&gt;ANTHROPIC_API_KEY&lt;/code&gt; → 4. &lt;code&gt;apiKeyHelper&lt;/code&gt; → 5. &lt;code&gt;CLAUDE_CODE_OAUTH_TOKEN&lt;/code&gt; → 6. interactive &lt;code&gt;/login&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you have &lt;code&gt;ANTHROPIC_API_KEY&lt;/code&gt; exported from another project (and you almost certainly do), it &lt;strong&gt;silently&lt;/strong&gt; wins over your OAuth token. You'll be billing API credits while thinking you're using your subscription.&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="nb"&gt;unset &lt;/span&gt;ANTHROPIC_API_KEY
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The repo includes a &lt;code&gt;check_auth.py&lt;/code&gt; / &lt;code&gt;check-auth.ts&lt;/code&gt; script that tells you exactly which auth method is winning, so you can diagnose instead of guessing.&lt;/p&gt;

&lt;h2&gt;
  
  
  ⚠️ Personal use only
&lt;/h2&gt;

&lt;p&gt;This works because the OAuth token is licensed for individual use through Claude Code and the Agent SDK. &lt;strong&gt;Do not&lt;/strong&gt; ship a multi-user app on it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You'd run everyone's traffic through one person's quota — you'd hit rate limits in seconds at any real load.&lt;/li&gt;
&lt;li&gt;It likely violates Anthropic's terms. Pro/Max plans are for individual use, and as of April 2026 Anthropic actively blocks third-party harnesses that try to bridge subscription auth into other tools.&lt;/li&gt;
&lt;li&gt;A leaked token = anyone can drain your subscription until you rotate it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For production, you swap the &lt;strong&gt;auth method&lt;/strong&gt;, not the SDK — the Agent SDK itself is production-grade. Point at &lt;code&gt;ANTHROPIC_API_KEY&lt;/code&gt; from &lt;a href="https://console.anthropic.com" rel="noopener noreferrer"&gt;console.anthropic.com&lt;/a&gt; and you're good.&lt;/p&gt;

&lt;h2&gt;
  
  
  The repo
&lt;/h2&gt;

&lt;p&gt;Top-level README with the full story, plus per-language READMEs for Python and TypeScript with setup instructions, three worked examples each (&lt;code&gt;hello&lt;/code&gt;, &lt;code&gt;check_auth&lt;/code&gt;, &lt;code&gt;news&lt;/code&gt; with streaming + WebSearch), and a troubleshooting table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repo:&lt;/strong&gt; &lt;a href="https://github.com/avivshaked/prototype-with-claude-max" rel="noopener noreferrer"&gt;avivshaked/prototype-with-claude-max&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you've been double-paying for Anthropic, this fixes it for personal scripts in about 5 minutes.&lt;/p&gt;

</description>
      <category>claude</category>
      <category>ai</category>
      <category>typescript</category>
      <category>python</category>
    </item>
  </channel>
</rss>
