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 /docs/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:

Smarter API Hosting Schemes

Hosting Type

Example

Default Hosting

api.example.com

Session-Based Hosting

example.com/v1/api/

Named LLMClients

stackademy.1234-5678-9012.example.com

Custom Domains

chat.yourdomain.com

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.

  • cli/: Brokered services for CLI workflows.

  • demos/: Fictional data for the platform’s example resources, e.g. the Stackademy course catalogue.

  • mcp/: The Smarter Project MCP server, which reads the project’s documentation and code.

  • journal/: Smarter Journal entries (superusers only).

  • connections/: External connection integration endpoints.

  • 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 when

    SMARTER_ENABLE_VECTORSTORE=true).

Each included URL set uses a namespace to avoid naming collisions and to keep API components logically separated.

 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.demos import urls as demos_urls
 7from smarter.apps.api.v1.tests import urls as tests_urls
 8from smarter.apps.connection.api.v1 import urls as connection_urls
 9from smarter.apps.connection.const import namespace as connnection_namespace
10from smarter.apps.guardrail.api.v1 import urls as guardrail_urls
11from smarter.apps.guardrail.const import namespace as guardrail_namespace
12from smarter.apps.llmclient.api.v1 import urls as llmclient_urls
13from smarter.apps.llmclient.const import namespace as llmclient_namespace
14from smarter.apps.llmhost.api.v1 import urls as llmhost_urls
15from smarter.apps.llmhost.const import namespace as llmhost_namespace
16from smarter.apps.llmtool.api.v1 import urls as llmtool_urls
17from smarter.apps.llmtool.const import namespace as llmtool_namespace
18from smarter.apps.mcpclient.api.v1 import urls as mcpclient_urls
19from smarter.apps.mcpclient.const import namespace as mcpclient_namespace
20from smarter.apps.mcpserver import urls as mcpserver_urls
21from smarter.apps.mcpserver.const import namespace as mcpserver_namespace
22from smarter.apps.orchestrator.api.v1 import urls as orchestrator_urls
23from smarter.apps.orchestrator.const import namespace as orchestrator_namespace
24from smarter.apps.prompt.api.v1 import urls as prompt_urls
25from smarter.apps.prompt.const import namespace as prompt_namespace
26from smarter.apps.provider.api.v1 import urls as provider_urls
27from smarter.apps.provider.const import namespace as provider_namespace
28from smarter.apps.proxy.api.v1 import urls as proxy_urls
29from smarter.apps.proxy.const import namespace as proxy_namespace
30from smarter.apps.secret.api.v1 import urls as secret_urls
31from smarter.apps.secret.const import namespace as secret_namespace
32from smarter.apps.vectorsearch.api.v1 import urls as vectorsearch_urls
33from smarter.apps.vectorsearch.const import namespace as vectorsearch_namespace
34from smarter.apps.vectorstore.api.v1 import urls as vectorstore_urls
35from smarter.common.conf import smarter_settings
36from smarter.common.mixins.helper_mixin import SmarterReadyState
37from smarter.lib import logging
38from smarter.lib.journal.api.v1 import urls as journal_urls
39from smarter.lib.journal.const import namespace as journal_namespace
40
41from .cli.const import namespace as cli_namespace
42from .const import namespace
43from .demos.const import namespace as demos_namespace
44
45logger = logging.getLogger(__name__)
46
47app_name = namespace
48
49# /api/v1/ is the main entry point for the API
50urlpatterns = [
51    # for LLMClients of the form https://example.3141-5926-5359.alpha.api.example.com
52    # path("", include(llmclient_urls)),
53    # -------------------------------------------
54    # the main API
55    # -------------------------------------------
56    path("accounts/", include(account_urls, namespace=account_namespace)),
57    path("llm-clients/", include(llmclient_urls, namespace=llmclient_namespace)),
58    path("llmhosts/", include(llmhost_urls, namespace=llmhost_namespace)),
59    path("mcpclients/", include(mcpclient_urls, namespace=mcpclient_namespace)),
60    path("mcp/", include(mcpserver_urls, namespace=mcpserver_namespace)),
61    path("cli/", include(cli_urls, namespace=cli_namespace)),
62    path("demos/", include(demos_urls, namespace=demos_namespace)),
63    path("connections/", include(connection_urls, namespace=connnection_namespace)),
64    path("guardrails/", include(guardrail_urls, namespace=guardrail_namespace)),
65    path("journal/", include(journal_urls, namespace=journal_namespace)),
66    path("orchestrators/", include(orchestrator_urls, namespace=orchestrator_namespace)),
67    path("plugins/", include(llmtool_urls, namespace=llmtool_namespace)),
68    path("prompts/", include(prompt_urls, namespace=prompt_namespace)),
69    path("providers/", include(provider_urls, namespace=provider_namespace)),
70    path("secrets/", include(secret_urls, namespace=secret_namespace)),
71    path("tests/", include(tests_urls, namespace="tests")),
72    path("vectorsearches/", include(vectorsearch_urls, namespace=vectorsearch_namespace)),
73]
74
75if smarter_settings.enable_proxy:
76    urlpatterns += [
77        path("proxy/", include(proxy_urls, namespace=proxy_namespace)),
78    ]
79    logger.info("%s Proxy API endpoints are %s.", logging.formatted_text(__name__), SmarterReadyState.READY)
80else:
81    logger.info(
82        "%s Proxy API endpoints are %s. Set env `SMARTER_ENABLE_PROXY=true` to enable.",
83        logging.formatted_text(__name__),
84        SmarterReadyState.NOT_READY,
85    )
86if smarter_settings.enable_vectorstore:
87    urlpatterns += [
88        path("vectorstores/", include(vectorstore_urls, namespace="vectorstore")),
89    ]
90    logger.info("%s Vectorstore API endpoints are %s.", logging.formatted_text(__name__), SmarterReadyState.READY)
91else:
92    logger.info(
93        "%s Vectorstore API endpoints are %s. Set env `SMARTER_ENABLE_VECTORSTORE=true` to enable.",
94        logging.formatted_text(__name__),
95        SmarterReadyState.NOT_READY,
96    )