Skip to main content

CLI + SDK for the Cogitan Surrogates API — on-demand physics-simulation surrogate models.

Project description

cogitan

CLI + Python SDK for the Cogitan Surrogates API — call on-demand physics-simulation surrogate models (heat, water, contaminant transport, materials, …) over HTTP. No models or GPUs on your machine: you send inputs, the server runs the surrogate, you get results in ms.

Install

pip install cogitan

This gives you both the cogitan command and the import cogitan SDK.

Set up your key (once)

cogitan login
# Paste your Cogitan API key: cog_sk_********
# ✓ Saved to ~/.cogitan/config.json

Your key is stored in ~/.cogitan/config.json (locked to your user) and used automatically forever. Key resolution order, first match wins:

  1. --api-key flag (one-off)
  2. COGITAN_API_KEY env var (CI / containers)
  3. ~/.cogitan/config.json (the normal case)

To point at a non-default endpoint (e.g. local testing): cogitan login --base-url http://localhost:8000, or set COGITAN_BASE_URL.

Commands

Command What it does
cogitan login Save your API key (prompts; persists forever)
cogitan logout Delete the saved key
cogitan whoami Show the active key (masked), endpoint, connection status
cogitan models List the catalog of available models
cogitan describe <model> Show a model's input schema (what fields to send)
cogitan run <model> Run a prediction (see below)
cogitan usage Current billing-period usage
cogitan config Show config file location + settings
cogitan version Print the version

Add --help to any command for details.

Running models on your own inputs

Three ways to provide inputs — mix and match:

1. From a JSON file:

cogitan run thermal --in my_case.json --out result.json

my_case.json:

{
  "grid_size": 64,
  "conductivity": 50,
  "sources": [{"x": 0.5, "y": 0.5, "amplitude": 30000, "width": 0.08}],
  "boundary": {"left": {"type": "dirichlet", "value": 300}, "right": {"type": "dirichlet", "value": 350}}
}

2. Inline params (repeatable; values are JSON-parsed, so numbers/lists/objects work):

cogitan run thermal -p conductivity=50 -p grid_size=64

3. Piped from stdin:

cat my_case.json | cogitan run thermal
echo '{"conductivity": 50}' | cogitan run thermal --out result.json

Not sure what a model wants? cogitan describe thermal prints its input schema. Without --out, the result prints to stdout (pipe it into jq, etc.).

Python SDK

import cogitan

client = cogitan.Client()                     # key from config/env automatically
print(client.models())                         # ["thermal", "groundwater", "contaminant", "mlip", ...]

# run a model
result = client.run("thermal", {
    "conductivity": 50,
    "sources": [{"x": 0.5, "y": 0.5, "amplitude": 30000, "width": 0.08}],
    "boundary": {"left": {"type": "dirichlet", "value": 300}},
})
print(result["max_temperature"])

# namespaced sugar
result = client.thermal.predict(conductivity=50, sources=[...])

# one-liner with the default client
result = cogitan.run("thermal", {"conductivity": 50})

Errors raise cogitan.APIError (with .status_code, .code, .request_id) or cogitan.NotConfigured if no key is set.

Local development

pip install -e .                               # from this directory
COGITAN_BASE_URL=http://localhost:8000 cogitan models

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cogitan-0.1.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cogitan-0.1.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file cogitan-0.1.1.tar.gz.

File metadata

  • Download URL: cogitan-0.1.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for cogitan-0.1.1.tar.gz
Algorithm Hash digest
SHA256 71eef6ec5ccdea58046da9bf08f91abfdff53844d18806a2368f30569c694d4b
MD5 a8fd2ba4d2be6632638a1528be796423
BLAKE2b-256 d8bf8dc55560df777b1f3564053fcecb77d71f9f38837ac6c47d4a8dec126988

See more details on using hashes here.

File details

Details for the file cogitan-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cogitan-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for cogitan-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 45cac2861ff3091adadef9650f657c30db55afdc87ac71cb7bd75697dececd22
MD5 3b189ad1ea595598cec1d20da790ef52
BLAKE2b-256 db07c75e5967c9b6e9dd6e849e4cbf4993081927a2cb224f6c3b7a262d40c002

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page