#!/usr/bin/env bash # Finish a Langflow install from https://exe.dev/deploy/langflow: # 1. point the OpenAI and Anthropic model providers at exe.dev's LLM gateway # (placeholder keys; the gateway needs none) and enable a few models, # 2. create a Langflow API key for you in ~/langflow/api-key (mode 600), # 3. create "Assistant", Langflow's Simple Agent template with the URL tool, # reachable at /api/v1/run/assistant and as the MCP tool "assistant". # Safe to run again: it skips what already exists. # bash setup.sh set -euo pipefail cd "${LANGFLOW_DIR:-$HOME/langflow}" set -a; . ./.env; set +a L=http://localhost:7860 MODEL=${MODEL:-gpt-5.4-mini} TOKEN=$(curl -fsS -X POST "$L/api/v1/login" \ --data-urlencode "username=$LANGFLOW_SUPERUSER" \ --data-urlencode "password=$LANGFLOW_SUPERUSER_PASSWORD" | jq -r .access_token) api() { curl -fsS -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' "$@"; } # 1. Model providers. Langflow checks the OpenAI key against the base URL, # so the base URL goes first. Anthropic reaches the gateway through # ANTHROPIC_BASE_URL in compose.yaml. have=$(api "$L/api/v1/variables/" | jq -r '.[].name') setvar() { if grep -qx "$1" <<<"$have"; then echo "$1: already set"; return; fi jq -n --arg n "$1" --arg v "$2" --arg t "$3" '{name: $n, value: $v, type: $t, default_fields: []}' \ | api -X POST "$L/api/v1/variables/" -d @- >/dev/null echo "$1: set" } setvar OPENAI_BASE_URL https://llm.int.exe.xyz/v1 Generic setvar OPENAI_API_KEY exe-gateway Credential setvar ANTHROPIC_API_KEY exe-gateway Credential api -X POST "$L/api/v1/models/enabled_models" -d '[ {"provider": "OpenAI", "model_id": "gpt-5.4-mini", "enabled": true}, {"provider": "OpenAI", "model_id": "gpt-5.5", "enabled": true}, {"provider": "Anthropic", "model_id": "claude-sonnet-4-6", "enabled": true}, {"provider": "Anthropic", "model_id": "claude-haiku-4-5", "enabled": true} ]' >/dev/null api -X POST "$L/api/v1/models/default_model" \ -d "{\"model_name\": \"$MODEL\", \"provider\": \"OpenAI\", \"model_type\": \"language\"}" >/dev/null echo "providers: $(api "$L/api/v1/models/enabled_providers" | jq -c .enabled_providers)" # 2. A Langflow API key, for the API, webhooks, and MCP clients. if [ ! -s api-key ]; then api -X POST "$L/api/v1/api_key/" -d '{"name": "exe.dev"}' | jq -r .api_key > api-key chmod 600 api-key echo "api key: created in $PWD/api-key" else echo "api key: already in $PWD/api-key" fi # 3. The Assistant flow, from the Simple Agent template that ships in the image. # The template's Web Search tool scrapes DuckDuckGo, which blocks most server # addresses, so it is left out (with its setup note). flow=$(api "$L/api/v1/flows/?get_all=true" | jq -c '[.[] | select(.endpoint_name == "assistant")][0] // empty') if [ -n "$flow" ]; then echo "flow: Assistant already exists" else flow=$(docker compose exec -T langflow sh -c \ 'cat /app/.venv/lib/python3*/site-packages/langflow/initial_setup/starter_projects/"Simple Agent.json"'