Skip to content

Quickstart: full text ​

This page has every step and detail. The overview is the short version.

Build a two-resource LLM API from one workflow.yaml. With loop: on the chat, the same file is an agent loop.

The mental model ​

A resource is one step in its own YAML file (here: an LLM call, then a response). A workflow is a folder of resources plus a workflow.yaml manifest. Each resource names what it requires:, and kdeps runs the steps in that dependency order (a DAG). The next step reads the output of a step with get('<actionId>'). This fixed order is the pipeline, and it is what you deploy.

Overview ​

This quickstart guides you through:

  • Creating a project
  • Writing a two-resource workflow (an LLM call and a response)
  • Running it as an HTTP API

It is for developers who have used a terminal and an HTTP API before. For install options (Windows, source, Docker), see Installation.

Before you start ​

  • kdeps installed (kdeps --version)
  • No LLM server: models run as local llamafiles (the default file backend). On the first run, you confirm the default model (llama3.2:1b, about 1.1 GB). Then kdeps downloads it to ~/.kdeps/models/ automatically.

Create a project ​

bash
kdeps new my-agent
cd my-agent

Or create the structure manually:

bash
mkdir -p my-agent/resources && cd my-agent

Define your workflow ​

workflow.yaml:

yaml
# workflow.yaml
apiVersion: kdeps.io/v1
kind: Workflow

metadata:
  name: my-agent
  version: "1.0.0"
  targetActionId: response

deploy:
  apiServer:
    hostIp: "127.0.0.1"
    portNum: 16395
    routes:
      - path: /api/v1/chat
        methods: [POST]

Add an LLM resource ​

resources/llm.yaml:

yaml
# resources/llm.yaml
actionId: llm
name: LLM Chat
validations:
  methods: [POST]
  routes: [/api/v1/chat]
  check:
    - get('q') != ''
  error:
    code: 400
    message: "'q' is required"
chat:
  model:
    name: llama3.2:1b
    timeout: 60s
  context:
    role: user
    prompt: "{{ get('q') }}"

Add a response resource ​

resources/response.yaml:

yaml
# resources/response.yaml
actionId: response
name: API Response
flow:
  requires: [llm]
apiResponse:
  success: true
  response:
    # chat output is the raw response object; the reply text is at .message.content
    answer: get('llm').message.content

Run it ​

When you configure apiServer, kdeps needs an API auth token before it starts. Set one for local development (never in workflow.yaml):

bash
export KDEPS_API_AUTH_TOKEN=dev-token
kdeps run workflow.yaml

You can also set api_auth_token in ~/.kdeps/config.yaml. See Security reference.

Test the API:

bash
curl -X POST http://localhost:16395/api/v1/chat \
  -H "Authorization: Bearer $KDEPS_API_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"q": "What is entropy?"}'

Expected response:

json
{
  "success": true,
  "data": {
    "answer": "Entropy is a measure of disorder..."
  }
}

How it works ​

POST /api/v1/chat{"q": "What is entropy?"}resource: llmvalidates get('q') != ''; calls llama3.2:1bresource: responserequires: [llm]; reads get('llm').message.content{"success": true, "data": {"answer": "..."}}output stored as get('llm')

requires: [llm] means response will not run until llm has finished. This two-resource DAG is the simplest pipeline.

Next steps ​

kdeps has the Apache 2.0 License.