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.
1. Get a token
Section titled “1. Get a token”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.)
2. Install a client
Section titled “2. Install a client”Python (≥ 3.10, zero dependencies):
pip install "git+https://github.com/ferrouslabs-git/fnai-public.git#subdirectory=python"TypeScript (Node ≥ 18, zero runtime dependencies):
git clone https://github.com/ferrouslabs-git/fnai-public.gitcd fnai-public/typescript && npm install && npm run build3. The golden path
Section titled “3. The golden path”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 onceresult = 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"])) # observeNotes:
mock-smallruns 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 withc.traces.flag(trace_id).
4. Where to go next
Section titled “4. Where to go next”- API reference — every endpoint, typed.
- sdk-auth.md — which credential for which surface.
- Runnable examples:
python/examples/andtypescript/examples/in the public repo.