Skip to navigation

LangChain

Use LangChain’s OpenAI integration with the Flow AI base URL.

Install

pip install langchain-openai

Chat

import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="openai/gpt-6-luna",
base_url="https://ai.hyperflow.fun/v1",
api_key=os.environ["HYPERFLOW_API_KEY"],
)
print(llm.invoke("Write a haiku about the sea.").content)

llm.stream(...), llm.bind_tools(...) and llm.with_structured_output(...) work on models that support streaming, tools and structured outputs.

Embeddings

from langchain_openai import OpenAIEmbeddings
embeddings = OpenAIEmbeddings(
model="cohere/cohere-embed-v4",
base_url="https://ai.hyperflow.fun/v1",
api_key=os.environ["HYPERFLOW_API_KEY"],
check_embedding_ctx_length=False,
)
vector = embeddings.embed_query("Hello!")

In Python, check_embedding_ctx_length=False makes LangChain send your text as is. Otherwise it splits it into OpenAI tokens first, which other labs’ models don’t read.