Skip to content

Quickstart

From zero to invoking your own deployed function, in about five minutes. Everything below was validated end-to-end against https://staging.fnai.dev.

Sign in to the app → click your avatar (top right) → API tokens → name one (e.g. laptop) → Mint. Copy the fnp_… value — it is shown exactly once. (Details on what this token is: sdk-auth.md.)

Python (≥ 3.10, zero dependencies):

Terminal window
pip install "git+https://github.com/ferrouslabs-git/fnai-public.git#subdirectory=python"

TypeScript (Node ≥ 18, zero runtime dependencies):

Terminal window
git clone https://github.com/ferrouslabs-git/fnai-public.git
cd fnai-public/typescript && npm install && npm run build

Create → try → approve → deploy → invoke. Python shown; the TypeScript namespaces are identical (see typescript/examples/golden-path.mjs).

from fnai import Client
c = Client(token="fnp_…", base_url="https://staging.fnai.dev")
fn = c.functions.create(
slug="doc_summarizer", name="Doc Summarizer",
input_schema={"type": "object", "properties": {"document": {"type": "string"}}},
output_schema={"type": "object", "required": ["summary"],
"properties": {"summary": {"type": "string"}}})
v = c.functions.create_version(fn["id"], snapshot={
"sections": [{"type": "role", "title": "Role",
"content": "Summarize {document} in two sentences."}],
"impl": "prompt",
"model_binding": {"model": "mock-small", "temperature": 0.2},
"tools": []}, message="first version")
print(c.versions.playground(v["id"], input={"document": ""})["output"]) # try it
c.versions.submit(v["id"])
c.versions.approve(v["id"])
c.deployments.deploy(fn["id"], v["id"])
key = c.keys.invoke.mint(fn["id"], name="quickstart") # fnk_… shown once
result = c.function(fn["slug"], api_key=key["key"]).run(document="")
print(result.ok, result.output, result.meta["cost_usd"], result.trace_id)
print(c.functions.health(fn["id"])) # observe

Notes:

  • mock-small runs without provider credentials — perfect for a first walk. Real models (claude/nova/gpt/gemini) need a provider key in your org or space (app → API keys), added once by an admin.
  • Want types for YOUR function’s contract? c.functions.types(fn["id"], lang="typescript")["source"] returns a compilable interface/TypedDict for its input/output schemas.
  • Every invocation lands as a trace: c.traces.list(function_id=fn["id"]), and a bad production output can be flagged straight into a regression dataset with c.traces.flag(trace_id).
  • API reference — every endpoint, typed.
  • sdk-auth.md — which credential for which surface.
  • Runnable examples: python/examples/ and typescript/examples/ in the public repo.