Skip to main content

universal API for JIMS application

Project description

jims-api

jims-api exposes any JIMS application as a FastAPI HTTP service.

Run

jims-api --app my_project.app:app --port 8080

Environment variables:

  • JIMS_APP - JIMS app import path (module:attr)
  • JIMS_PORT - HTTP port
  • JIMS_HOST - HTTP host
  • JIMS_API_KEY - optional static bearer token for auth
  • JIMS_AUTHENTIK_URL - Authentik instance base URL (e.g. https://authentik.epoch8.dev)
  • JIMS_AUTHENTIK_APP_SLUG - Authentik application slug to check access against

Authentication

Auth is checked in the following order:

  1. If JIMS_API_KEY is set and the provided bearer token matches — allow
  2. If JIMS_AUTHENTIK_URL and JIMS_AUTHENTIK_APP_SLUG are set — validate the bearer token against Authentik's /api/v3/core/applications/{slug}/check_access/ endpoint. If 200 — allow
  3. If no auth is configured (neither static key nor Authentik) — open access
  4. Otherwise — 401 Unauthorized

Send the token as Authorization: Bearer <token>.

Endpoints

  • GET /healthz
  • POST /api/v1/chat
  • POST /api/v1/chat/stream

POST /api/v1/chat

Request:

{
  "contact_id": "customer:42",
  "message": "Hello",
  "thread_id": null,
  "thread_config": {"interface": "api"},
  "event_type": "comm.user_message",
  "run_conversation_start_on_new_thread": false
}

Response:

{
  "thread_id": "0194f0f3-d88d-7cca-8f37-ff44f911f539",
  "created_new_thread": true,
  "assistant_messages": ["Hi! How can I help?"],
  "events": [
    {
      "event_type": "comm.assistant_message",
      "event_data": {"role": "assistant", "content": "Hi! How can I help?"}
    }
  ]
}

Send the API token as Authorization: Bearer <token> (see Authentication above).

POST /api/v1/chat/stream

Same request body as /api/v1/chat, but the response is a text/event-stream (SSE) instead of a single JSON object. Use this to show the user live progress (e.g. "Searching knowledge base...") while the pipeline is running.

Request: same as /api/v1/chat.

The stream emits the following event types:

  • status - an agent status update, emitted while the pipeline is running:
    event: status
    data: {"status": "Searching knowledge base...", "type": "searching_knowledge_base"}
    
    type is a stable identifier; status is a string that may change between releases.
  • result - the final response, with the same shape as the /api/v1/chat response body:
    event: result
    data: {"thread_id": "...", "created_new_thread": true, "assistant_messages": ["Hi!"], "events": [...]}
    
  • error - sent instead of result if the pipeline raised an exception:
    event: error
    data: {"detail": "Pipeline error: ..."}
    

A stream always ends with either a result or an error event.

Note: browsers' EventSource API cannot send custom headers, so it can't be used directly with Authorization: Bearer <token> auth. Consume this endpoint with fetch and read the response body as a stream instead.

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

jims_api-0.6.2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

jims_api-0.6.2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file jims_api-0.6.2.tar.gz.

File metadata

  • Download URL: jims_api-0.6.2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jims_api-0.6.2.tar.gz
Algorithm Hash digest
SHA256 a49f9102afc69be0bd2f2f224fea82df0e1952b943ce670ee338caaa915c6668
MD5 73b0beea8bd68ea6334751cc514f5ae9
BLAKE2b-256 5180f4b2edba69ad8a99a69a6a44419b28bb21948bebfa5b88324f16eb58e1df

See more details on using hashes here.

Provenance

The following attestation bundles were made for jims_api-0.6.2.tar.gz:

Publisher: publish-jims-api.yml on epoch8/vedana

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jims_api-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: jims_api-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jims_api-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 852ea09d3de322e275e368c9b41f8519189ec871b8cb8f0ba639139faf865685
MD5 289dba8291581c5bb19ea5cc349149d8
BLAKE2b-256 871c6a75d30a5cbd3dfe33406849e07d439da8571ce88560729a218237f283b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for jims_api-0.6.2-py3-none-any.whl:

Publisher: publish-jims-api.yml on epoch8/vedana

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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