<?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: piano505</title>
    <description>The latest articles on DEV Community by piano505 (@piano505).</description>
    <link>https://dev.to/piano505</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%2F4250772%2F779abe53-0a75-4d8f-bec0-48c233c6973c.png</url>
      <title>DEV Community: piano505</title>
      <link>https://dev.to/piano505</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/piano505"/>
    <language>en</language>
    <item>
      <title>OpenAI-compatible API relays: how to point Cursor, Claude Code and the OpenAI SDK at a custom base_url</title>
      <dc:creator>piano505</dc:creator>
      <pubDate>Wed, 18 Nov 2026 01:31:14 +0000</pubDate>
      <link>https://dev.to/piano505/openai-compatible-api-relays-how-to-point-cursor-claude-code-and-the-openai-sdk-at-a-custom-oo3</link>
      <guid>https://dev.to/piano505/openai-compatible-api-relays-how-to-point-cursor-claude-code-and-the-openai-sdk-at-a-custom-oo3</guid>
      <description>&lt;p&gt;An API relay (or gateway) is a service that sits between your code and one or more model providers. You get a single API key and a single base URL, and the relay forwards requests to the underlying models. OpenRouter is a well-known example. Because many relays expose an OpenAI-compatible interface, tools such as Cursor, Cline and the OpenAI SDK can use them just by changing the base URL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Python (OpenAI SDK)
&lt;/h2&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.niceai.dev/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;"YOUR_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;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;"gpt-4o-mini"&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;"Hello"&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;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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  curl
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://api.niceai.dev/v1/chat/completions \
  -H &lt;span class="s2"&gt;"Authorization: Bearer YOUR_KEY"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}]}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Claude Code (Anthropic-compatible /v1/messages)
&lt;/h2&gt;

&lt;p&gt;Some relays also expose an Anthropic-compatible &lt;code&gt;/v1/messages&lt;/code&gt; endpoint. For Claude Code, set the base URL and key as environment variables:&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.niceai.dev
&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;YOUR_KEY
claude
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Cursor and other tools
&lt;/h2&gt;

&lt;p&gt;In Cursor, open the model settings, override the OpenAI base URL with &lt;code&gt;https://api.niceai.dev/v1&lt;/code&gt; and paste your key. Cline and other OpenAI-compatible clients have similar base URL fields.&lt;/p&gt;

&lt;h2&gt;
  
  
  NiceAI as one such relay
&lt;/h2&gt;

&lt;p&gt;NiceAI (&lt;a href="https://niceai.dev/" rel="noopener noreferrer"&gt;https://niceai.dev/&lt;/a&gt;) is one relay of this kind. It offers OpenAI-compatible and Anthropic-compatible endpoints, pay-as-you-go pricing at a fraction of official prices, and payment by WeChat Pay, Alipay or USDT. New users get $5 in credit, plus an extra $1.5 with invite code &lt;code&gt;4C6953E0177AC2A8&lt;/code&gt; at sign-up. Support is on Telegram: &lt;a href="https://t.me/niceai_dev" rel="noopener noreferrer"&gt;https://t.me/niceai_dev&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As with any third-party relay, check the pricing, supported models and data handling before sending sensitive prompts.&lt;/p&gt;

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