Client
The main client for interacting with the T2G API.
The T2GClient is the primary interface for interacting with the T2G API. It handles authentication, session management, and provides access to the various services.
Initialization
The client is best used as an asynchronous context manager.
import asyncio
from t2g_sdk import T2GClient
async def main():
async with T2GClient() as client:
# Use the client to access services
pass
if __name__ == "__main__":
asyncio.run(main())Configuration
The T2GClient utilizes Pydantic's BaseSettings for its configuration, allowing for flexible parameter management. Settings are loaded in a specific order of precedence:
- Environment variables: Values set directly in the environment take the highest precedence (e.g.,
export LETTRIA_API_KEY="your_key"). .envfile: A.envfile located in the project root (where the SDK is run) will be loaded. This is a convenient way to manage local development settings without committing them to version control.- Default values: If a setting is not found in environment variables or a
.envfile, the SDK will use its predefined default values.
Here are the available configuration parameters:
| Parameter | Type | Default Value | Description |
|---|---|---|---|
LETTRIA_API_KEY | str | (required) | Your Lettria API key for authentication. |
NEO4J_URI | str | bolt://localhost:7687 | The URI for your Neo4j database connection. |
NEO4J_USER | str | neo4j | The username for authenticating with Neo4j. |
NEO4J_PASSWORD | str | password | The password for authenticating with Neo4j. |
LOGLEVEL | str | WARNING | The logging level for the SDK (e.g., DEBUG, INFO, WARNING, ERROR). |
Services
Once the client is initialized, you can access the various services as properties of the client instance:
client.file: Access theFileService.client.job: Access theJobService.client.ontology: Access theOntologyService.client.neo4j: Access theNeo4jService.