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 (enabled only whenSMARTER_ENABLE_VECTORSTORE=true).
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'
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.mixins.helper_mixin import SmarterReadyState
42from smarter.common.utils import to_snake_case
43from smarter.lib import logging
44from smarter.lib.journal.api.v1 import urls as journal_urls
45from smarter.lib.journal.const import namespace as journal_namespace
46
47from .cli.const import namespace as cli_namespace
48from .const import namespace
49from .demos.const import namespace as demos_namespace
50
51logger = logging.getLogger(__name__)
52
53app_name = namespace
54
55
56class ApiV1ReverseNames:
57 """
58 The names of the routes at the root of ``/api/v1/``.
59
60 e.g. ``reverse(ApiV1ReverseNames.namespace, ApiV1ReverseNames.openapi_json)``.
61 """
62
63 namespace = f"api:{namespace}"
64 openapi_json = to_snake_case(ApiV1OpenApiJsonView.__name__)
65
66
67# /api/v1/ is the main entry point for the API
68urlpatterns = [
69 # for LLMClients of the form https://example.3141-5926-5359.alpha.api.example.com
70 # path("", include(llmclient_urls)),
71 # -------------------------------------------
72 # the api's OpenAPI document
73 # -------------------------------------------
74 path("openapi.json", ApiV1OpenApiJsonView.as_view(), name=ApiV1ReverseNames.openapi_json),
75 # -------------------------------------------
76 # the main API
77 # -------------------------------------------
78 path("accounts/", include(account_urls, namespace=account_namespace)),
79 path("llm-clients/", include(llmclient_urls, namespace=llmclient_namespace)),
80 path("llmhosts/", include(llmhost_urls, namespace=llmhost_namespace)),
81 path("mcpclients/", include(mcpclient_urls, namespace=mcpclient_namespace)),
82 path("mcp/", include(mcpserver_urls, namespace=mcpserver_namespace)),
83 path("cli/", include(cli_urls, namespace=cli_namespace)),
84 path("demos/", include(demos_urls, namespace=demos_namespace)),
85 path("connections/", include(connection_urls, namespace=connnection_namespace)),
86 path("doodles/", include(doodle_urls, namespace=doodle_namespace)),
87 path("extensions/", include(extension_urls, namespace=extension_namespace)),
88 path("guardrails/", include(guardrail_urls, namespace=guardrail_namespace)),
89 path("journal/", include(journal_urls, namespace=journal_namespace)),
90 path("orchestrators/", include(orchestrator_urls, namespace=orchestrator_namespace)),
91 path("plugins/", include(llmtool_urls, namespace=llmtool_namespace)),
92 path("prompts/", include(prompt_urls, namespace=prompt_namespace)),
93 path("providers/", include(provider_urls, namespace=provider_namespace)),
94 path("secrets/", include(secret_urls, namespace=secret_namespace)),
95 path("tests/", include(tests_urls, namespace="tests")),
96 path("vectorsearches/", include(vectorsearch_urls, namespace=vectorsearch_namespace)),
97]
98
99if smarter_settings.enable_proxy:
100 urlpatterns += [
101 path("proxy/", include(proxy_urls, namespace=proxy_namespace)),
102 ]
103 logger.debug("%s Proxy API endpoints are %s.", logging.SmarterFormattedText.text(__name__), SmarterReadyState.READY)
104else:
105 logger.info(
106 "%s Proxy API endpoints are %s. Set env `SMARTER_ENABLE_PROXY=true` to enable.",
107 logging.SmarterFormattedText.text(__name__),
108 SmarterReadyState.NOT_READY,
109 )
110if smarter_settings.enable_vectorstore:
111 urlpatterns += [
112 path("vectorstores/", include(vectorstore_urls, namespace="vectorstore")),
113 ]
114 logger.debug(
115 "%s Vectorstore API endpoints are %s.", logging.SmarterFormattedText.text(__name__), SmarterReadyState.READY
116 )
117else:
118 logger.info(
119 "%s Vectorstore API endpoints are %s. Set env `SMARTER_ENABLE_VECTORSTORE=true` to enable.",
120 logging.SmarterFormattedText.text(__name__),
121 SmarterReadyState.NOT_READY,
122 )