Smarter API
The Smarter API provides support for AI text prompts, the command-line interface (CLI), as well as limited support for anciallary UI features. The API is built on Django REST Framework and includes a rich set of enterprise features for enhanced security, audit capability, and performance optimization.
Its official clients are the Smarter CLI, for people at a terminal, and the Python, Node.js and Go SDKs, for software that integrates with your platform.
The whole API is described by a typed OpenAPI 3.1 document, the
Smarter OpenAPI Contract, which every platform serves at
/api/v1/openapi.json, and from which clients in any language can be generated. See
Smarter APIs, SDKs and Integrations for the design that the API and its clients share.
The Smarter Framework supports multiple hosting naming schemes for the Smarter API. For example:
Hosting Type |
Example |
|---|---|
Default Hosting |
|
Session-Based Hosting |
|
Named LLMClients |
|
Custom Domains |
|
See Django Hosts for more details.
URL configuration for Smarter API v1.
This module defines the urlpatterns for the /api/v1/ entry point and
delegates route handling to app-specific URL modules.
Routes
accounts/: User account management endpoints.llmclients/: LLMClient CRUD and related operations.openapi.json: The api’s OpenAPI 3.1 document (public),smarter.apps.api.v1.contract.views.cli/: Brokered services for CLI workflows.demos/: Fictional data for the platform’s example resources, e.g. the Stackademy course catalogue.mcp/: The MCPServer’s two endpoints: its public tools, which read the project’s documentation and code, and its staff-only tools, which read the platform’s health, logs and users.journal/: Smarter Journal entries (superusers only).connections/: External connection integration endpoints.doodles/: The sign-in page’s doodle of the day, and its artwork (public).plugins/: Plugin management endpoints.prompts/: Prompt and interaction endpoints.providers/: Provider integration endpoints.secrets/: Secret management endpoints.tests/: Test-only endpoints.vectorstores/: Vector store endpoints.
The SAM resource apps’ endpoints (connections, guardrails, llm-clients, plugins, secrets, …) are
mounted only if the app’s SMARTER_ENABLE_<APP> flag is true, which it is by default. See
smarter.lib.manifest.sam_apps.
Each included URL set uses a namespace to avoid naming collisions and to keep API components logically separated.
See also
- class smarter.apps.api.v1.urls.ApiV1ReverseNames[source]
Bases:
objectThe names of the routes at the root of
/api/v1/.e.g.
reverse(ApiV1ReverseNames.namespace, ApiV1ReverseNames.openapi_json).- namespace = 'api:v1'
- openapi_json = 'api_v1_open_api_json_view'
- smarter.apps.api.v1.urls.SAM_APP_API_URLS: list[SamAppUrls] = [('app_connection_enable', 'Connection', 'connections/', <module 'smarter.apps.connection.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/connection/api/v1/urls.py'>, 'connection'), ('app_guardrail_enable', 'Guardrail', 'guardrails/', <module 'smarter.apps.guardrail.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/guardrail/api/v1/urls.py'>, 'guardrail'), ('app_llmclient_enable', 'LLMClient', 'llm-clients/', <module 'smarter.apps.llmclient.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/llmclient/api/v1/urls.py'>, 'llmclient'), ('app_llmhost_enable', 'LLMHost', 'llmhosts/', <module 'smarter.apps.llmhost.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/llmhost/api/v1/urls.py'>, 'llmhost'), ('app_llmtool_enable', 'LLMTool', 'plugins/', <module 'smarter.apps.llmtool.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/llmtool/api/v1/urls.py'>, 'llmtool'), ('app_llmtool_enable', 'Extension', 'extensions/', <module 'smarter.apps.llmtool.extension.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/llmtool/extension/api/v1/urls.py'>, 'extension'), ('app_mcpclient_enable', 'MCPClient', 'mcpclients/', <module 'smarter.apps.mcpclient.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/mcpclient/api/v1/urls.py'>, 'mcpclient'), ('app_orchestrator_enable', 'Orchestrator', 'orchestrators/', <module 'smarter.apps.orchestrator.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/orchestrator/api/v1/urls.py'>, 'orchestrator'), ('app_provider_enable', 'Provider', 'providers/', <module 'smarter.apps.provider.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/provider/api/v1/urls.py'>, 'provider'), ('app_proxy_enable', 'Proxy', 'proxy/', <module 'smarter.apps.proxy.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/proxy/api/v1/urls.py'>, 'proxy'), ('app_secret_enable', 'Secret', 'secrets/', <module 'smarter.apps.secret.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/secret/api/v1/urls.py'>, 'secret'), ('app_vectorsearch_enable', 'VectorSearch', 'vectorsearches/', <module 'smarter.apps.vectorsearch.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/vectorsearch/api/v1/urls.py'>, 'vectorsearch'), ('app_vectorstore_enable', 'Vectorstore', 'vectorstores/', <module 'smarter.apps.vectorstore.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/vectorstore/api/v1/urls.py'>, 'vectorstore')]
The REST api endpoints of the SAM resource apps.
Each app’s endpoints are mounted only if its
smarter_settings.enable_<app>flag is true. Seesmarter.lib.manifest.sam_apps.[ SamAppUrls(setting='app_connection_enable', label='Connection', prefix='connections/', urls=<module 'smarter.apps.connection.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/connection/api/v1/urls.py'>, namespace='connection'), SamAppUrls(setting='app_guardrail_enable', label='Guardrail', prefix='guardrails/', urls=<module 'smarter.apps.guardrail.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/guardrail/api/v1/urls.py'>, namespace='guardrail'), SamAppUrls(setting='app_llmclient_enable', label='LLMClient', prefix='llm-clients/', urls=<module 'smarter.apps.llmclient.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/llmclient/api/v1/urls.py'>, namespace='llmclient'), SamAppUrls(setting='app_llmhost_enable', label='LLMHost', prefix='llmhosts/', urls=<module 'smarter.apps.llmhost.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/llmhost/api/v1/urls.py'>, namespace='llmhost'), SamAppUrls(setting='app_llmtool_enable', label='LLMTool', prefix='plugins/', urls=<module 'smarter.apps.llmtool.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/llmtool/api/v1/urls.py'>, namespace='llmtool'), SamAppUrls(setting='app_llmtool_enable', label='Extension', prefix='extensions/', urls=<module 'smarter.apps.llmtool.extension.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/llmtool/extension/api/v1/urls.py'>, namespace='extension'), SamAppUrls(setting='app_mcpclient_enable', label='MCPClient', prefix='mcpclients/', urls=<module 'smarter.apps.mcpclient.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/mcpclient/api/v1/urls.py'>, namespace='mcpclient'), SamAppUrls(setting='app_orchestrator_enable', label='Orchestrator', prefix='orchestrators/', urls=<module 'smarter.apps.orchestrator.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/orchestrator/api/v1/urls.py'>, namespace='orchestrator'), SamAppUrls(setting='app_provider_enable', label='Provider', prefix='providers/', urls=<module 'smarter.apps.provider.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/provider/api/v1/urls.py'>, namespace='provider'), SamAppUrls(setting='app_proxy_enable', label='Proxy', prefix='proxy/', urls=<module 'smarter.apps.proxy.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/proxy/api/v1/urls.py'>, namespace='proxy'), SamAppUrls(setting='app_secret_enable', label='Secret', prefix='secrets/', urls=<module 'smarter.apps.secret.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/secret/api/v1/urls.py'>, namespace='secret'), SamAppUrls(setting='app_vectorsearch_enable', label='VectorSearch', prefix='vectorsearches/', urls=<module 'smarter.apps.vectorsearch.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/vectorsearch/api/v1/urls.py'>, namespace='vectorsearch'), SamAppUrls(setting='app_vectorstore_enable', label='Vectorstore', prefix='vectorstores/', urls=<module 'smarter.apps.vectorstore.api.v1.urls' from '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/vectorstore/api/v1/urls.py'>, namespace='vectorstore'), ]
1from django.urls import include, path
2
3from smarter.apps.account.api.v1 import urls as account_urls
4from smarter.apps.account.const import namespace as account_namespace
5from smarter.apps.api.v1.cli import urls as cli_urls
6from smarter.apps.api.v1.contract.views import ApiV1OpenApiJsonView
7from smarter.apps.api.v1.demos import urls as demos_urls
8from smarter.apps.api.v1.tests import urls as tests_urls
9from smarter.apps.connection.api.v1 import urls as connection_urls
10from smarter.apps.connection.const import namespace as connnection_namespace
11from smarter.apps.doodle.api.v1 import urls as doodle_urls
12from smarter.apps.doodle.const import namespace as doodle_namespace
13from smarter.apps.guardrail.api.v1 import urls as guardrail_urls
14from smarter.apps.guardrail.const import namespace as guardrail_namespace
15from smarter.apps.llmclient.api.v1 import urls as llmclient_urls
16from smarter.apps.llmclient.const import namespace as llmclient_namespace
17from smarter.apps.llmhost.api.v1 import urls as llmhost_urls
18from smarter.apps.llmhost.const import namespace as llmhost_namespace
19from smarter.apps.llmtool.api.v1 import urls as llmtool_urls
20from smarter.apps.llmtool.const import namespace as llmtool_namespace
21from smarter.apps.llmtool.extension.api.v1 import urls as extension_urls
22from smarter.apps.llmtool.extension.urls import namespace as extension_namespace
23from smarter.apps.mcpclient.api.v1 import urls as mcpclient_urls
24from smarter.apps.mcpclient.const import namespace as mcpclient_namespace
25from smarter.apps.mcpserver import urls as mcpserver_urls
26from smarter.apps.mcpserver.const import namespace as mcpserver_namespace
27from smarter.apps.orchestrator.api.v1 import urls as orchestrator_urls
28from smarter.apps.orchestrator.const import namespace as orchestrator_namespace
29from smarter.apps.prompt.api.v1 import urls as prompt_urls
30from smarter.apps.prompt.const import namespace as prompt_namespace
31from smarter.apps.provider.api.v1 import urls as provider_urls
32from smarter.apps.provider.const import namespace as provider_namespace
33from smarter.apps.proxy.api.v1 import urls as proxy_urls
34from smarter.apps.proxy.const import namespace as proxy_namespace
35from smarter.apps.secret.api.v1 import urls as secret_urls
36from smarter.apps.secret.const import namespace as secret_namespace
37from smarter.apps.vectorsearch.api.v1 import urls as vectorsearch_urls
38from smarter.apps.vectorsearch.const import namespace as vectorsearch_namespace
39from smarter.apps.vectorstore.api.v1 import urls as vectorstore_urls
40from smarter.common.conf import smarter_settings
41from smarter.common.utils import to_snake_case
42from smarter.lib.journal.api.v1 import urls as journal_urls
43from smarter.lib.journal.const import namespace as journal_namespace
44from smarter.lib.manifest.sam_apps import SamAppUrls, sam_app_urlpatterns
45
46from .cli.const import namespace as cli_namespace
47from .const import namespace
48from .demos.const import namespace as demos_namespace
49
50app_name = namespace
51
52
53class ApiV1ReverseNames:
54 """
55 The names of the routes at the root of ``/api/v1/``.
56
57 e.g. ``reverse(ApiV1ReverseNames.namespace, ApiV1ReverseNames.openapi_json)``.
58 """
59
60 namespace = f"api:{namespace}"
61 openapi_json = to_snake_case(ApiV1OpenApiJsonView.__name__)
62
63
64# /api/v1/ is the main entry point for the API
65urlpatterns = [
66 # for LLMClients of the form https://example.3141-5926-5359.alpha.api.example.com
67 # path("", include(llmclient_urls)),
68 # -------------------------------------------
69 # the api's OpenAPI document
70 # -------------------------------------------
71 path("openapi.json", ApiV1OpenApiJsonView.as_view(), name=ApiV1ReverseNames.openapi_json),
72 # -------------------------------------------
73 # the main API
74 # -------------------------------------------
75 path("accounts/", include(account_urls, namespace=account_namespace)),
76 path("mcp/", include(mcpserver_urls, namespace=mcpserver_namespace)),
77 path("cli/", include(cli_urls, namespace=cli_namespace)),
78 path("demos/", include(demos_urls, namespace=demos_namespace)),
79 path("doodles/", include(doodle_urls, namespace=doodle_namespace)),
80 path("journal/", include(journal_urls, namespace=journal_namespace)),
81 path("prompts/", include(prompt_urls, namespace=prompt_namespace)),
82 path("tests/", include(tests_urls, namespace="tests")),
83]
84
85SAM_APP_API_URLS: list[SamAppUrls] = [
86 SamAppUrls("app_connection_enable", "Connection", "connections/", connection_urls, connnection_namespace),
87 SamAppUrls("app_guardrail_enable", "Guardrail", "guardrails/", guardrail_urls, guardrail_namespace),
88 SamAppUrls("app_llmclient_enable", "LLMClient", "llm-clients/", llmclient_urls, llmclient_namespace),
89 SamAppUrls("app_llmhost_enable", "LLMHost", "llmhosts/", llmhost_urls, llmhost_namespace),
90 SamAppUrls("app_llmtool_enable", "LLMTool", "plugins/", llmtool_urls, llmtool_namespace),
91 SamAppUrls("app_llmtool_enable", "Extension", "extensions/", extension_urls, extension_namespace),
92 SamAppUrls("app_mcpclient_enable", "MCPClient", "mcpclients/", mcpclient_urls, mcpclient_namespace),
93 SamAppUrls("app_orchestrator_enable", "Orchestrator", "orchestrators/", orchestrator_urls, orchestrator_namespace),
94 SamAppUrls("app_provider_enable", "Provider", "providers/", provider_urls, provider_namespace),
95 SamAppUrls("app_proxy_enable", "Proxy", "proxy/", proxy_urls, proxy_namespace),
96 SamAppUrls("app_secret_enable", "Secret", "secrets/", secret_urls, secret_namespace),
97 SamAppUrls("app_vectorsearch_enable", "VectorSearch", "vectorsearches/", vectorsearch_urls, vectorsearch_namespace),
98 SamAppUrls("app_vectorstore_enable", "Vectorstore", "vectorstores/", vectorstore_urls, "vectorstore"),
99]
100"""
101The REST api endpoints of the SAM resource apps.
102
103Each app's endpoints are mounted only if its ``smarter_settings.enable_<app>`` flag is true. See
104:mod:`smarter.lib.manifest.sam_apps`.
105"""
106
107urlpatterns += sam_app_urlpatterns(smarter_settings, SAM_APP_API_URLS, "API")