Skip to content

Quickstart: Sypnia Cloud

Sign in, give a task its route, try it, and call it from your server under a use case.

Applies to Cloud
View as Markdown
On this page
  1. Sign in and link your project
  2. Give the task a route
  3. Try it
  4. Call it from your server
  5. See what it spent

At the end you will have a task, write, that La Espiga’s server uses every morning to write the bread of the day, with its usage shown under the use case.

  1. Terminal
    npx @sypnia/app login
    npx @sypnia/ai link --project la-espiga

    The first command is the one sign-in every Sypnia command line shares: it opens your browser to approve a code. The second writes project = "la-espiga" to sypnia.toml, the project’s one configuration file, at the root of your repository.

    You should see
    Linked to la-espiga (organization: La Espiga).
  2. Give the task a route

    Add the task to sypnia.toml:

    sypnia.toml
    [ai.tasks.write]
    model = "default"        # the model Sypnia AI picks for writing
    instructions = """
    You write for La Espiga, a neighbourhood bakery. Warm, short, in Spanish.
    Never invent prices or ingredients.
    """
    params = { max_output_tokens = 300 }
    Terminal
    npx @sypnia/ai routes apply
    You should see
    A diff of the project’s routes, a confirmation, then 1 route applied (write).
  3. Try it

    Terminal
    npx @sypnia/ai try write "Today: rye loaf and almond croissants." --case publish-bread-of-the-day
    You should see
    The message, then a line like model: … · 182 tokens in · 64 out · 0.4 s · charged to publish-bread-of-the-day.
  4. Call it from your server

    Terminal
    npx @sypnia/ai keys create la-espiga-server --scope call

    Put the key it prints in your server’s environment as SYPNIA_SECRET_KEY; it is shown once. Then:

    bread-of-the-day.ts
    import { createAI } from '@sypnia/ai/server';
    
    const ai = createAI({ apiKey: process.env.SYPNIA_SECRET_KEY! });
    
    const { text } = await ai.chat({
      task: 'write',
      case: 'publish-bread-of-the-day',
      messages: [{ role: 'user', content: 'Today: rye loaf and almond croissants.' }],
    });
  5. See what it spent

    Terminal
    npx @sypnia/ai usage --by case --since 7d
    You should see
    A table with publish-bread-of-the-day, its calls, tokens and credits.
  1. Sign in and link your project
  2. Give the task a route
  3. Try it
  4. Call it from your server
  5. See what it spent

    Search pages, sections and terms