Model API
Agent workflow on a model vendor’s API
LangGraph as the orchestration graph mixing deterministic and model-driven steps, a closed model (GPT-5, Claude or Gemini) for the reasoning, your own tools for the actions, Langfuse for tracing and evaluation, and human approval gates on the steps that change something.
- Source
- Editorial recipe — no step evidence has been fetched yet
- Verified
- Evidence not verified
- Confidence
- Low
01Objective
Build a multi-step agent that plans, calls your tools and loops — orchestrated by LangGraph, reasoned by a closed model API, traced end to end by Langfuse — with the actions landing in systems you control and a human in the loop for the consequential ones.
- use caseAgent workflowA multi-step process where a model chooses which tool to call next — read a ticket, look something up, update a record, hand off to a person. The interesting question is not the model but where the loop is allowed to stop and who can undo what it did.
- use caseCompany researchAssembling a picture of an organisation — ownership, filings, news, sanctions exposure, key people — from public sources, with each statement traceable to the page it came from. Used for onboarding, due diligence and competitor tracking.
- use caseEmail draftingDrafting replies in the inbox from the thread, the CRM record and the company style. Small per message, large in aggregate — and the place where a wrong statement leaves the building fastest.
- use caseReport generationProducing a recurring document — a management pack, client update, board summary, compliance return — from data and prior text. The template and the data are fixed; the narrative around them is what takes the time.
- use caseSales researchPreparing for a sales conversation: what the account does, who the buyer is, what changed recently, what was said last time. Combines public web sources with the CRM record, and personalises outreach from both.
02Recommended stack
| Role | Component |
|---|---|
| Authentication | Identity provider (OIDC) for the application |
| Inference | Closed model API (OpenAI, Anthropic or Google Gemini) |
| Ingestion | Tools (your APIs and systems) |
| Observability | Langfuse |
| Orchestration | LangGraph |
Architecture and data flow
Components
- Users / triggering system — people
- Agent application (LangGraph orchestrator) — application
- Identity provider (OIDC) — identity
- Tools + retrieval (your APIs and data) — retrieval
- Agent state + Langfuse traces — database
- Vendor model API — inference server
- Company systems the agent acts on (CRM, ticketing, mailbox) — internal system
- Closed frontier model — model
Connections
- Users / triggering system to Agent application (LangGraph orchestrator) — HTTPS (confidential data)
- Agent application (LangGraph orchestrator) to Identity provider (OIDC) — OIDC sign-in (personal data)
- Agent application (LangGraph orchestrator) to Tools + retrieval (your APIs and data) — question + user groups (confidential data)
- Tools + retrieval (your APIs and data) to Agent state + Langfuse traces — documents + permissions (confidential data)
- Agent application (LangGraph orchestrator) to Agent state + Langfuse traces — chats, users, settings (personal data)
- Tools + retrieval (your APIs and data) to Vendor model API — prompt + retrieved passages (confidential data)
- Vendor model API to Closed frontier model — loaded weights
- Tools + retrieval (your APIs and data) to Company systems the agent acts on (CRM, ticketing, mailbox) — tool actions (read and write) (confidential data)
External data transfer · YES
- confidential content leaves your control on the Tools + retrieval (your APIs and data) → Vendor model API link.
- The orchestration, the tools, the state and the traces stay on your network; only the model call crosses to the vendor. The agent sends the prompt and every tool result it reasons over with it — more than a single-shot assistant.
- The actions land in systems you control; those writes are not a transfer out, but a person should approve the consequential ones.
03Suitable for
- Organisation size
- 20–10000 employees
- Data classes
- confidential, personal
- Constraints
- a genuine multi-step task — planning, tool use, looping — not a single question; a team that can build and operate an application, or an implementation partner; agreement that prompts and tool inputs may leave the network to the model vendor
- Industries
- Technology, Professional services, Financial services, Recruitment hr, Other
- Jurisdictions
- any
04Hardware
No hardware profile was sized for this answer.
Indicative costUSD · one-off plus monthly
- Software
- LangGraph and Langfuse are open source and self-hosted. What you pay the model vendor is metered and sits on the model line.
- US$0
- Model usage
- Not estimated here: priced per token — see the cost section, which multiplies a fetched price by the usage band read from your brief. An agent uses more tokens per task than a single answer, because it loops — the assumption band should reflect that.
- Not estimated
- Application hosting, state and trace store
- Not estimated: the orchestrator, a state store and the Langfuse backend, priced per your own infrastructure. No price list was fetched.
- Not estimated
- Implementation (8–22 FDE-days)
- 8–22 FDE-days at US$760–1940 per day, converted from the HK$6,000–15,000 band at the HKMA Linked Exchange Rate band of HK$7.75–7.85 to one US dollar. One-off; excludes internal staff time.
- US$6,080 – US$42,680
- The model line is the metered one and is larger per task than a single-shot assistant because an agent loops; the cost section computes it from a fetched price and the usage band.
- Implementation is dominated by designing and hardening the graph, the tools and the evaluation — the agent’s reliability is the work, not the wiring.
- Assumes the systems the agent acts on already have APIs to call.
05Difficulty
4 / 5
Multiple weeks and a team that has shipped infrastructure
06Skills
- API integrationapi-integration
- development
- LLM evaluationllm-evaluation
- ml
- Prompt engineeringprompt-engineering
- ml
- Security hardeningsecurity-hardening
- security
- TypeScripttypescript
- development
- Workflow automationworkflow-automation
- operations
07Deployment steps
Commands are copied from each project’s own documentation, and the page they came from is linked under the step. 0 of 7 steps currently open an evidence record. The rest are linked to their source; §10 says which of those documents were fetched and which were fetched without their anchor being found — two different states, named differently there.
- 01
Design the graph before the promptsversion-sensitive
AssessmentLangGraph is "a low-level orchestration framework and runtime for building, managing, and deploying long-running, stateful agents". Its point is that you can "mix deterministic, hand-coded steps with LLM-driven agentic steps in the same graph" — so make the steps that must be reliable deterministic, and reserve the model for the parts that genuinely need judgement. Draw the graph first; the prompts come after.
pip install -U langgraph - 02
Connect the model, and read its data terms firstversion-sensitive
AssessmentThe model does the planning and tool selection, so the vendor sees the prompt and the tool inputs. Before real data flows, confirm the commercial terms: Anthropic states that "by default, we will not use your inputs or outputs from our commercial products" to train, and OpenAI’s enterprise page describes commitments giving you "ownership and control over your business data". Record which plan and endpoint the wording applies to.
- 03
Define narrow tools and scope their permissions
AssessmentEach tool is a capability you hand the agent. Give each one the least access it needs, run it under the identity of the user who triggered the agent rather than a superuser service account, and validate its inputs in code — a model that can call a tool with any argument is a model that can call it with the wrong one. The orchestration graph is where these calls are wired.
- 04
Put a human gate on the consequential actions
AssessmentNot every step should run unattended. LangGraph lets you "incorporate human oversight by inspecting and modifying agent state at any point" — use it: pause before an action that spends money, emails a customer or changes a record, and require an approval. The cost of the gate is latency; the cost of not having it is an autonomous mistake.
- 05
Trace every run with Langfuse
AssessmentLangfuse is "an open-source AI engineering platform" whose "traces include all LLM and non-LLM calls, including retrieval, embedding, API calls, and more", and where "LLM agents can be visualized as a graph to illustrate the flow of complex agentic workflows". Wire it in from the first prototype: without the trace, an agent that did the wrong thing is a black box, and the trace is also the audit record.
- 06
Evaluate on real tasks, and cap the loop
AssessmentBuild a set of real tasks with agreed outcomes and run them through Langfuse’s evaluation before launch and after every prompt or model change — an agent’s failure modes are compounding, not one-shot. Cap the number of steps and the spend per run so a reasoning loop that goes wrong stops rather than bills, and alert on runs that hit the cap.
- 07
Verify the vendor’s data-handling before productionversion-sensitive
AssessmentFor the model endpoint you will call, confirm the DPA covers the API, whether a zero-data-retention mode is available, the retention period and what triggers human review, and the region the request is served from. The agent sends more to the vendor than a single-shot assistant does — every tool result it reasons over — so the data question is larger here, not smaller.
08Compliance considerations
Structured issue-spotting to support your own review — not legal advice. Verify against the cited primary sources and your counsel.
Applies everywhere
Human oversight · Automated decision-makinghigh
An agent takes actions, not just answers. Put a human approval gate on any step that changes something or affects a person — LangGraph supports pausing to inspect and modify state — and keep the trace of what was approved and by whom.
Prompt leakage · Confidentialityhigh
The vendor sees every prompt and every tool result the model reasons over — more than a single-shot assistant sends. Decide which tools may return confidential data into the model context, and keep anything under a duty of confidence out of the tools the agent can reach.
Data processing agreement · Model training · Retentionhigh
You need a DPA covering the API and the no-training default for the plan you buy. Anthropic states it does not use commercial inputs or outputs to train by default; confirm the equivalent for your vendor and whether zero data retention is available on your account.
Logging · Auditabilitymedium
The Langfuse trace is the audit record of what the agent did: which tools, which arguments, which model outputs. Keep it under the same retention and access rules as the systems the agent acts on, because it can contain their data.
09Alternatives
A managed agent service in your own cloud
Where you are already on a hyperscaler, its managed agent runtime keeps the orchestration, the model and the traces inside your own account rather than split between a framework you host and a vendor API.
- — Orchestration, model and traces in one cloud boundary and agreement
- — Less control over the graph than a framework you own, and tied to that cloud
A single retrieval-grounded answer, if that is all it needs
Many tasks framed as "agents" are one retrieval and one answer. If yours is, the assistant recipe is simpler, cheaper and far easier to make reliable.
- — Much simpler and more predictable
- — Cannot plan, use tools or loop — one question, one answer
- Model APIAssistant on a model vendor’s APIOpen WebUI as the interface, a LiteLLM gateway holding the vendor key and the spend log, a closed model (GPT-5, Claude Sonnet or Gemini) reached over its API, and pgvector for retrieval over your own documents. The application is identical to a self-hosted one; only the model moves to a vendor endpoint.
- Private cloudAgent workflow on a managed cloud runtimeA managed agent runtime that handles orchestration, memory, tool invocation and observability; a model from the same cloud; your APIs exposed as tools; private networking; and human approval gates on consequential actions. Same shape as the framework-hosted agent, one tenancy instead of two.
10Evidence
Not yet in the ledger
not yet fetched
not yet fetched
not yet fetched
not yet fetched
not yet fetched
not yet fetched
not yet fetched
- OpenAI — Enterprise privacy
Vendor page
not yet fetched
11Community
Deployed this stack, or hit something this page does not cover? Corrections, sources and implementation reports are what keep a recipe worth reading.
Improve this page
Sign in to contribute
From the field
0 deployments · 0 questions
Nobody has reported deploying this here yet, and no question has been opened against this page. Both appear once a reviewer accepts them.
12Hire an FDE
If you would rather not build it, we can introduce a forward-deployed engineer who has deployed this stack before. The enquiry form starts from this recipe.