Page cover

LangSmith

LangSmith is an end-to-end platform for debugging, evaluating, and monitoring language model applications. It integrates seamlessly with LangChain and other LLM frameworks to visualize traces, inspect prompts, measure performance, and manage production-grade evaluation workflows. LangSmith helps you build more reliable AI systems by turning opaque model calls into structured, traceable data through observability and experiment tracking.

This tutorial shows how to integrate Arcee AI models into LangSmith using an OpenAI-compatible endpoint. While the focus is on tracing, the same setup applies to other LangSmith features.


Prerequisites

  • Python: >=3.10 and <3.14

  • LangSmith Account and API Key:

    • If you do not have one, you can create one here

  • Arcee AI model running locally or accessible via API and an OpenAI-compatible endpoint

Quickstart

Environment and project setup:

# Create project folder
mkdir arceeai_langsmith && cd arceeai_langsmith

# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env

# Create and activate virtual environment
uv venv --python 3.12 --seed
source .venv/bin/activate

# Install LangSmith + LangChain OpenAI client
uv pip install langsmith langchain-openai

LangSmith uses environment variables for configuration. We'll also include the Arcee AI variables here. Create a .env file and include the following

# .env
LANGSMITH_TRACING=true
LANGSMITH_ENDPOINT=https://api.smith.langchain.com
LANGSMITH_API_KEY=<your-api-key>
LANGSMITH_PROJECT=arcee-langsmith-project

ARCEE_API_BASE=http://127.0.0.1:8080/v1
ARCEE_API_KEY=<your-api-key>
ARCEE_MODEL_NAME="afm-4.5b"

Create a new python file called arceeai_langsmith.py with the following:

import os
from typing_extensions import Annotated, TypedDict

from langgraph.graph import StateGraph, START, END
from langgraph.graph.message import add_messages
from langchain_core.messages import AnyMessage, SystemMessage, HumanMessage
from langchain_openai import ChatOpenAI

class State(TypedDict):
    messages: Annotated[list[AnyMessage], add_messages]

# Configure Arcee AI Model
ARCEE_BASE = os.getenv("ARCEE_API_BASE", "http://127.0.0.1:8080/v1")
ARCEE_KEY  = os.getenv("ARCEE_API_KEY", "your-arcee-api-key")
ARCEE_MODEL = os.getenv("ARCEE_MODEL_NAME", "trinity-mini")

# Initialize Arcee AI model with OpenAI-compatible configuration
arcee_llm = ChatOpenAI(
    model=ARCEE_MODEL,
    api_key=ARCEE_KEY,
    base_url=ARCEE_BASE,
)

# Define a simple graph node that uses the Arcee AI model
def summarize(state: State) -> State:
    # Add a system instruction once, if not present
    msgs = state["messages"]
    if not any(getattr(m, "role", "") == "system" for m in msgs):
        msgs = [SystemMessage(content="You are a concise technical writer.")] + msgs
    # Ask Arcee to respond
    ai = arcee_llm.invoke(msgs)
    return {"messages": [ai]}

# Build the graph that LangGraph will execute
builder = StateGraph(State)
builder.add_node("summarize", summarize)
builder.add_edge(START, "summarize")
builder.add_edge("summarize", END)
graph = builder.compile()

if __name__ == "__main__":
    text = """Arcee AI is a foundation model provider with a focus on building the highest performing models per parameter. 
They offer a range of models from on-device and edge optimized models to large language models. Their suite of models 
provides customers with the flexibility to choose the right model for the right task. All models are released Apache 2.0 
enabling the community to use safe, built-in-the-US models in their own environment or via the Arcee AI API platform."""
    inputs: State = {"messages": [HumanMessage(content=f"Summarize the following in three bullets:\n\n{text}")]}

    # Execute the LangGraph agent
    result = graph.invoke(inputs)
    
    # Print the results
    print("\n=== RESULT ===\n")
    print(result["messages"][-1].content)

Run your Arcee AI powered LangGraph Agent with LangSmith Tracing

python arceeai_langsmith.py

Last updated