Get Started
Use the official context212-sdk client in Python apps.
context212-sdk is the official Python client for Context212. It ships typed endpoint functions (sync and async) plus attrs request and response models.
Install
pip install context212-sdk
# or: uv add context212-sdkConfigure the client
Create an AuthenticatedClient with the base URL and your API key:
import os
from context212_sdk import AuthenticatedClient
client = AuthenticatedClient(
base_url="https://api.context212.com",
token=os.environ["CONTEXT212_API_KEY"],
)The base URL defaults to your deployment — https://api.context212.com for the hosted API.
See Authentication for how API keys work.
Call an endpoint
Each endpoint lives under context212_sdk.api and comes in four variants: sync, sync_detailed, asyncio, and asyncio_detailed. Requests are attrs models.
from context212_sdk.api.ask import ask
from context212_sdk.api.search import search
from context212_sdk.models import AskRequest, SearchRequest
answer = ask.sync(
client=client,
body=AskRequest(
query="What is the vacation policy?",
workspace_id=[42],
max_results=5,
),
)
print(answer.answer)
hits = search.sync(
client=client,
body=SearchRequest(query="vacation policy", workspace_id=[42], max_results=3),
)
for result in hits.results:
print(result.content[:120])The plain sync / asyncio variants return the parsed model; the _detailed variants return a Response with status_code, headers, and parsed.
Common methods
| Method | HTTP | Purpose |
|---|---|---|
ask.sync / ask.asyncio | POST /api/v1/ask | Grounded Q&A over your corpus |
search.sync / search.asyncio | POST /api/v1/search | Hybrid / vision search |
files_create / files_list / files_retrieve | Files API | Upload and inspect documents |
parse / parse_retrieve | POST / GET /api/v1/parse | Document parse jobs |
extract / extract_retrieve | POST / GET /api/v1/extract | Structured extraction jobs |
list_workspaces / create_workspace / get_workspace | Workspaces | Scope and manage workspaces |
tags_list / add_tags / delete_tags | Tags | Organize content with tags |
ontology_templates_list / ontology_concepts_create / ontology_relations_create | Ontology | Concepts, relations, and graph filters |
For every parameter and response field, see the API reference.