<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="364208" data-post-id="364208">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="brainlid" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/brainlid/120/20975_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  brainlid
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks <a class="mention" href="/u/darnahsan" rel="nofollow">@darnahsan</a>! Merged!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="364208" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/langchain-an-elixir-langchain-like-library-for-integrating-with-llms-like-chatgpt/58551/52">Post #51</a>
	                </div>
	            </div>
              <div id="likers-container-364208" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="364208"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #51"></div>
  </section>
</div>
    <div class="postbit" id="366830" data-post-id="366830">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="darnahsan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/darnahsan/120/17164_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  darnahsan
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I have created a <a href="https://github.com/brainlid/langchain/pull/319" rel="noopener nofollow ugc">PR</a> to add native tool support to Vertex AI to make it at par with Google AI implementation.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="366830" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/langchain-an-elixir-langchain-like-library-for-integrating-with-llms-like-chatgpt/58551/53">Post #52</a>
	                </div>
	            </div>
              <div id="likers-container-366830" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="366830"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #52"></div>
  </section>
</div>
    <div class="postbit" id="367812" data-post-id="367812">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Gonza" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Gonza/120/32336_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Gonza
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hey guys, have any of you been able to make Langchain work with OpenRouter? It exposes an OpenAI-compatible API but all I’m getting is <code>null</code>. I’m pretty sure it’s hitting the right endpoint and with the right apikey, because those were problems but I got past them.</p>
<p>This is what I got:</p>
<p><em>ash_ai_demo/config/runtime.exs</em></p>
<pre data-code-wrap="exs"><code class="lang-exs">config :langchain, openai_key: fn -&gt; System.fetch_env!("OPENROUTER_API_KEY") end
</code></pre>
<p><em>ash_ai_demo/lib/ash_ai_demo/chat/message/changes/respond.ex</em></p>
<pre data-code-wrap="ex"><code class="lang-ex">      %{
        llm:
          ChatOpenAI.new!(%{
            stream: true,
            model: "google/gemini-2.0-flash-exp:free",
            endpoint: "https://openrouter.ai/api/v1/chat/completions",
            custom_context: Map.new(Ash.Context.to_opts(context))
          })
      }
      |&gt; LLMChain.new!()
</code></pre>
<p><em>ash_ai_demo/lib/ash_ai_demo/chat/conversation/changes/generate_name.ex</em></p>
<pre data-code-wrap="ex"><code class="lang-ex">      %{
        llm:
          ChatOpenAI.new!(%{
            model: "google/gemini-2.0-flash-exp:free",
            endpoint: "https://openrouter.ai/api/v1/chat/completions",
            custom_context: Map.new(Ash.Context.to_opts(context))
          }),
        verbose?: true
      }
      |&gt; LLMChain.new!()
</code></pre>
<p><em>logs:</em></p>
<pre data-code-wrap="elixir"><code class="lang-elixir">[error] Received error from API: "Expected string, received null"
[error] Error during chat call. Reason: %LangChain.LangChainError{type: nil, message: "Expected string, received null", original: nil}
</code></pre>
<p>I followed all the instructions I could find but I’m stuck</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367812" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/langchain-an-elixir-langchain-like-library-for-integrating-with-llms-like-chatgpt/58551/54">Post #53</a>
	                </div>
	            </div>
              <div id="likers-container-367812" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367812"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #53"></div>
  </section>
</div>
    <div class="postbit" id="367946" data-post-id="367946">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="brainlid" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/brainlid/120/20975_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  brainlid
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Gonza" data-post="54" data-topic="58551">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gonza/48/32336_2.png" class="avatar"> Gonza:</div>
<blockquote>
<p>Hey guys, have any of you been able to make Langchain work with OpenRouter? It exposes an OpenAI-compatible API but all I’m getting is <code>null</code> . I’m pretty sure it’s hitting the right endpoint and with the right apikey, because those were problems but I got past them.</p>
</blockquote>
</aside>
<p>Hi Gonza!</p>
<p>I don’t know. I haven’t used OpenRouter. It may be <em>mostly</em> compatible with OpenAI, or there is an incompatibility in the library. One thing to note is that Ash AI is using v0.3.x of Elixir LangChain and I’m working on v0.4.0 (RC) where there have been many substantial changes. One of which is a detailed verbose_api mode support for OpenAI, which would help debug an issue like this.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367946" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/langchain-an-elixir-langchain-like-library-for-integrating-with-llms-like-chatgpt/58551/55">Post #54</a>
	                </div>
	            </div>
              <div id="likers-container-367946" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367946"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #54"></div>
  </section>
</div>
    <div class="postbit" id="367965" data-post-id="367965">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="zachdaniel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/120/31980_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  zachdaniel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Ash</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/brainlid" rel="nofollow">@brainlid</a> do you think we should update Ash AI to use the latest langchain rc?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="367965" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/langchain-an-elixir-langchain-like-library-for-integrating-with-llms-like-chatgpt/58551/56">Post #55</a>
	                </div>
	            </div>
              <div id="likers-container-367965" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="367965"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #55"></div>
  </section>
</div>
    <div class="postbit" id="368385" data-post-id="368385">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="brainlid" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/brainlid/120/20975_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  brainlid
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/zachdaniel" rel="nofollow">@zachdaniel</a> I hope a new RC 1 will be out soon-ish. That has more significant changes but also more benefits. It’s up to you, but you can wait for that one if that makes works.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="368385" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/langchain-an-elixir-langchain-like-library-for-integrating-with-llms-like-chatgpt/58551/57">Post #56</a>
	                </div>
	            </div>
              <div id="likers-container-368385" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="368385"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #56"></div>
  </section>
</div>
    <div class="postbit" id="370645" data-post-id="370645">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="herisson" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/herisson/120/31581_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  herisson
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Stumbled upon the same issue.<br>
After looking into the request made, it seems the only nil field was the <code>user</code> (nil by default).</p>
<p>To fix that you can specify the user when creating your ChatOpenAI:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">ChatOpenAI.new!(%{
        api_key: openrouter_api_key,
        model: "openrouter/horizon-beta",
        endpoint: "https://openrouter.ai/api/v1/chat/completions",
        user: "user_name"
      })
</code></pre>
<p>Hope it helps!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="370645" data-batch-url="/posts/batch_likers">
                        4
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/langchain-an-elixir-langchain-like-library-for-integrating-with-llms-like-chatgpt/58551/58">Post #57</a>
	                </div>
	            </div>
              <div id="likers-container-370645" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="370645"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #57"></div>
  </section>
</div>
    <div class="postbit" id="371812" data-post-id="371812">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="brainlid" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/brainlid/120/20975_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  brainlid
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="herisson" data-post="58" data-topic="58551">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/herisson/48/31581_2.png" class="avatar"> herisson:</div>
<blockquote>
<pre data-code-wrap="elixir"><code class="lang-elixir">ChatOpenAI.new!(%{
        api_key: openrouter_api_key,
        model: "openrouter/horizon-beta",
        endpoint: "https://openrouter.ai/api/v1/chat/completions",
        user: "user_name"
      })
</code></pre>
</blockquote>
</aside>
<p>Thanks <a class="mention" href="/u/herisson" rel="nofollow">@herisson</a> for identifying the issue! I updated the <code>main</code> branch where ChatOpenAI now only includes the <code>user</code> key in the request if a value was given. So it won’t send a <code>nil</code> anymore. Hopefully that resolves the issue with OpenRouter.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="371812" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/langchain-an-elixir-langchain-like-library-for-integrating-with-llms-like-chatgpt/58551/59">Post #58</a>
	                </div>
	            </div>
              <div id="likers-container-371812" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="371812"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>