LangChain & LangGraph Integration on API Store Hub

Build stateful StateGraph agents, tool bindings, and multi-model fallbacks using ChatOpenAI pointed to https://apistorehub.com/v1.

Ready to ship production AI with one unified API key, VND billing, and multi-provider failover on API Store Hub?

LangChain & LangGraph Integration on API Store Hub visual architecture diagram — API Store Hub
LangChain & LangGraph Integration on API Store Hub · Base URL https://apistorehub.com · Key prefix sk-ash-

Install command

LanguagePython
RuntimePython 3.10+, langchain-openai, langgraph
ProtocolOpenAI Compatible (/v1/chat/completions) & Anthropic (/v1/messages)
Install commandpip install -U langchain-openai langgraph

3-step quickstart setup

  1. Create an API key on API Store Hub: Sign in to the API Store Hub console, generate a key with prefix sk-ash-, and optionally attach daily or monthly spend caps.
  2. Install SDK & set Base URL: Install the official package and configure environment variables pointing to https://apistorehub.com for /v1/messages.
  3. Run inference with streaming & retry: Invoke claude-sonnet-5-5 with explicit timeout and jittered retries; every request logs tokens, TTFT, and exact cost.

Production-ready code sample

Python

import os
from langchain_openai import ChatOpenAI
from langgraph.graph import END, MessagesState, StateGraph

primary_llm = ChatOpenAI(
    model="claude-sonnet-5-5",
    base_url="https://apistorehub.com/v1",
    api_key=os.environ["API_KEY"],
    temperature=0.2,
)
fallback_llm = ChatOpenAI(
    model="deepseek-v4-pro",
    base_url="https://apistorehub.com/v1",
    api_key=os.environ["API_KEY"],
)
resilient_llm = primary_llm.with_fallbacks([fallback_llm])

def agent_node(state: MessagesState):
    return {"messages": [resilient_llm.invoke(state["messages"])]}

graph = StateGraph(MessagesState)
graph.add_node("agent", agent_node)
graph.set_entry_point("agent")
graph.add_edge("agent", END)
app = graph.compile()

cURL

curl https://apistorehub.com/v1/chat/completions \
  -H "Authorization: Bearer sk-ash-your_key" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-sonnet-5-5","messages":[{"role":"user","content":"Plan a 2-step LangGraph workflow"}]}'

Recommended models with live pricing

ModelToken priceContext & Endpoint
Claude Sonnet 5.57,700 ST / 1M tokens1M
DeepSeek V4 Pro3,600 ST / 1M tokens1M
GPT 6.2 Sol6,700 ST / 1M tokens1.1M

Production hardening checklist

  • Combine llm.with_fallbacks([backup_llm]) on the same sk-ash- API key to automatically route to DeepSeek or Gemini during load spikes.
  • Enable stream=true for long completions (> 500 tokens) to keep connections responsive and minimize time-to-first-token (TTFT).
  • Never hard-code API keys in client bundles; load them from server environment variables and rotate keys periodically in API Store Hub.
  • Configure exponential backoff with jitter for HTTP 429/502/529 and keep a secondary fallback model on the exact same API key.

Frequently asked questions

Does integrating LangChain & LangGraph with API Store Hub require rewriting existing calls?
No. API Store Hub preserves native OpenAI (https://apistorehub.com/v1) and Anthropic Messages (https://apistorehub.com/v1/messages) schemas—just update the Base URL and sk-ash- API key.
Can one API key handle streaming, function calling, and embeddings?
Yes. A single API Store Hub key works across all 187 models, including SSE streaming, strict JSON Schema outputs, tool calling, and embeddings.
How are billing and rate limits controlled?
Every request is metered transparently by token or request in the API Store Hub console, never overdrafts your balance, and supports per-key spend caps.