### Setup Environment and Install Dependencies Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-azure-openai/README.md Copy the example environment file and fill in your API keys. Then, synchronize dependencies using uv. ```bash cp .env.example .env # Fill in your API keys in .env uv sync ``` -------------------------------- ### Quick Start: Setup and Run FastAPI App Source: https://github.com/posthog/posthog-python/blob/main/playgrounds/fastapi-exception-capture/USAGE.md Follow these steps to set up the environment, configure the API key, and run the FastAPI application. Ensure you are in the correct directory and have the necessary dependencies installed. ```bash cd posthog-python/playgrounds/fastapi-exception-capture export POSTHOG_API_KEY="your_key" uv sync uv run python app.py ``` -------------------------------- ### Install Dependencies and Setup Environment Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-claude-agent-sdk/README.md Install necessary Python packages and copy the environment file. Remember to fill in your API keys in the .env file. ```bash pip install -r requirements.txt cp .env.example .env # Fill in your API keys in .env ``` -------------------------------- ### Setup Development Environment with uv Source: https://github.com/posthog/posthog-python/blob/main/CONTRIBUTING.md Use uv to create a virtual environment, activate it, and install development and test dependencies. ```bash uv venv source .venv/bin/activate uv sync --extra dev --extra test ``` -------------------------------- ### Run Python Examples with uv Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-openai/README.md Source your environment variables and then run the desired Python example script using uv. ```bash source .env uv run python chat_completions.py uv run python chat_completions_streaming.py uv run python responses.py uv run python responses_streaming.py uv run python embeddings.py uv run python transcription.py uv run python image_generation.py ``` -------------------------------- ### Running Example Scripts Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-anthropic/README.md Commands to execute the provided Python example scripts after setting up the environment and sourcing the .env file. ```bash source .env uv run python chat.py uv run python streaming.py uv run python extended_thinking.py ``` -------------------------------- ### Run Chat Example Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-cohere/README.md Command to run the chat completion example script after setting up the environment variables. ```bash source .env uv run python chat.py ``` -------------------------------- ### Run Example Scripts Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-langchain/README.md Source your environment variables and run the example Python scripts using uv. These scripts demonstrate PostHog callback handler and OpenTelemetry instrumentation. ```bash source .env uv run python callback_handler.py uv run python otel.py ``` -------------------------------- ### Install posthoganalytics Package Source: https://github.com/posthog/posthog-python/blob/main/README_ANALYTICS.md Use this command to install the posthoganalytics package. This package is intended for internal use only. ```bash pip install posthog ``` -------------------------------- ### Setup Instructions Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-cohere/README.md Instructions for setting up the environment, including copying a .env file, filling in API keys, and installing/syncing dependencies with uv. ```bash cp .env.example .env # Fill in your API keys in .env # Install uv if you haven't already: https://docs.astral.sh/uv/getting-started/installation/ uv sync ``` -------------------------------- ### Run OpenAI Agents SDK Examples Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-openai-agents/README.md Execute the provided Python agent examples using uv run after sourcing your environment variables. ```bash source .env uv run python multi_agent.py uv run python single_agent.py uv run python guardrails.py uv run python custom_spans.py ``` -------------------------------- ### Run Examples Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-litellm/README.md Source your environment variables and then run the chat or streaming Python scripts using uv. ```bash source .env uv run python chat.py uv run python streaming.py ``` -------------------------------- ### Setup Ollama and PostHog Integration Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-ollama/README.md Copy the environment file, fill in API keys, and ensure Ollama is running. Use `uv sync` to synchronize dependencies. ```bash cp .env.example .env # Fill in your API keys in .env # Make sure Ollama is running locally: ollama serve uv sync ``` -------------------------------- ### posthog.poller.Poller.run Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Starts the poller. This method continuously fetches updates. ```APIDOC ## method posthog.poller.Poller.run() ### Description Starts the poller. This method continuously fetches updates. ### Method `None` ### Endpoint `None` ### Parameters None ### Request Example None ### Response #### Success Response `None` #### Response Example None ``` -------------------------------- ### Run Instructor Extraction Example Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-instructor/README.md Source your environment variables and then run the Python script that demonstrates Instructor extraction with PostHog tracking. ```bash source .env uv run python extract.py ``` -------------------------------- ### Run PostHog AI Examples Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-gemini/README.md Source the environment variables and run the Python scripts for Gemini API integration. ```bash source .env uv run python chat.py uv run python streaming.py uv run python image_generation.py ``` -------------------------------- ### posthog.consumer.Consumer.run Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Starts the consumer's main loop. This method continuously processes items. ```APIDOC ## method posthog.consumer.Consumer.run() ### Description Starts the consumer's main loop. This method continuously processes items. ### Method `None` ### Endpoint `None` ### Parameters None ### Request Example None ### Response #### Success Response `None` #### Response Example None ``` -------------------------------- ### Run Example Scripts Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-claude-agent-sdk/README.md Source your environment variables and run the provided Python scripts to test different functionalities of the Claude Agent SDK with PostHog AI. ```bash source .env python simple_query.py python instrument_reuse.py python multi_turn.py ``` -------------------------------- ### handle_anthropic_content_block_start Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Handles the start of a content block in Anthropic streaming. ```APIDOC ## Function: handle_anthropic_content_block_start ### Description Processes the start event of a content block in an Anthropic streaming response, identifying new content blocks and tool progress. ### Parameters * `event` (Any): The event data indicating the start of a content block. ### Returns * `Tuple[Optional[StreamingContentBlock], Optional[ToolInProgress]]`: A tuple containing the new streaming content block and any associated tool in progress, or None for each if not applicable. ``` -------------------------------- ### posthog.client.Client.set_once Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Sets user properties only if they have not been set before. Useful for initial user property setup. ```APIDOC ## method posthog.client.Client.set_once(**kwargs: Unpack[OptionalSetArgs]) -> Optional[str] ### Description Sets user properties only if they have not been set before. Useful for initial user property setup. ### Method `None` ### Endpoint `None` ### Parameters #### Request Body - **kwargs** (OptionalSetArgs) - Required - A dictionary of properties to set for the user. ### Request Example None ### Response #### Success Response (200) Returns an optional string, possibly an identifier or status. #### Response Example None ``` -------------------------------- ### posthog.request.get Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Performs a GET request to a specified URL. Used for fetching data from an endpoint. ```APIDOC ## posthog.request.get ### Description Performs a GET request to a specified URL. ### Method GET ### Endpoint [URL provided as parameter] ### Parameters #### Query Parameters - **api_key** (str) - Required - Your PostHog API key. - **url** (str) - Required - The URL to fetch. - **host** (str) - Optional - The PostHog host to send the request to. - **timeout** (Optional[int]) - Optional - Request timeout in seconds. - **etag** (Optional[str]) - Optional - ETag for conditional requests. ``` -------------------------------- ### CallbackHandler Methods Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Methods for handling callbacks within Langchain integrations, including starting and error events. ```APIDOC ## method posthog.ai.langchain.callbacks.CallbackHandler.on_tool_error ### Description Handles errors that occur during tool execution in Langchain. ### Method POST (inferred) ### Endpoint /tool_error (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **error** (BaseException) - Required - The exception that occurred. - **run_id** (UUID) - Required - The unique identifier for the current run. - **parent_run_id** (Optional[UUID]) - Optional - The identifier for the parent run, if any. - **tags** (Optional[list[str]]) - Optional - A list of tags associated with the run. ### Request Example ```json { "error": "An example error message", "run_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "parent_run_id": null, "tags": ["example_tag"] } ``` ### Response #### Success Response (200) - **result** (Any) - The result of the operation. #### Response Example ```json { "result": "Success" } ``` ## method posthog.ai.langchain.callbacks.CallbackHandler.on_tool_start ### Description Handles the start of a tool execution in Langchain. ### Method POST (inferred) ### Endpoint /tool_start (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **serialized** (Optional[Dict[str, Any]]) - Optional - Serialized information about the tool. - **input_str** (str) - Required - The input string provided to the tool. - **run_id** (UUID) - Required - The unique identifier for the current run. - **parent_run_id** (Optional[UUID]) - Optional - The identifier for the parent run, if any. - **metadata** (Optional[Dict[str, Any]]) - Optional - Metadata associated with the tool start. ### Request Example ```json { "serialized": {"name": "example_tool"}, "input_str": "User query", "run_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "parent_run_id": null, "metadata": {"key": "value"} } ``` ### Response #### Success Response (200) - **result** (Any) - The result of the operation. #### Response Example ```json { "result": "Started" } ``` ``` -------------------------------- ### posthog.exception_utils.get_lines_from_file Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Retrieves a specified number of lines from a file, starting at a given line number. Used for fetching source code context. ```APIDOC ## posthog.exception_utils.get_lines_from_file ### Description Retrieves a specified number of lines from a file, starting at a given line number. Used for fetching source code context. ### Parameters - **filename** (str) - The path to the file. - **lineno** (int) - The starting line number. - **max_length** (Optional[int]) - The maximum number of lines to retrieve. - **loader** (Optional[Any]) - A loader object. - **module** (Optional[Any]) - The module object. ``` -------------------------------- ### posthog.setup Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Initializes and sets up the PostHog client. This is typically the first step before using other PostHog functionalities. ```APIDOC ## posthog.setup ### Description Initializes and sets up the PostHog client. ### Method Not applicable (function call) ### Parameters None ### Returns Client - The initialized PostHog client instance. ``` -------------------------------- ### GetResponse Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Represents a response from an HTTP GET request. ```APIDOC ## Class: GetResponse ### Description Encapsulates the data and metadata from an HTTP GET request response. ### Parameters * `data` (Any): The response data. * `etag` (Optional[str]): The ETag header value. * `not_modified` (bool): Indicates if the response was not modified. ``` -------------------------------- ### Run AutoGen Agent with PostHog Tracking Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-autogen/README.md Source your environment variables and then run the agent script using uv. ```bash source .env uv run python agent.py ``` -------------------------------- ### Manually Run Compliance Tests with Docker Source: https://github.com/posthog/posthog-python/blob/main/sdk_compliance_adapter/CONTRIBUTING.md Set up and run the compliance tests manually using Docker. This involves creating a network, building and running the adapter, executing the test harness, and cleaning up resources. ```bash # Create network docker network create test-network # Build and run adapter docker build -f sdk_compliance_adapter/Dockerfile -t posthog-python-adapter . docker run -d --name sdk-adapter --network test-network -p 8080:8080 posthog-python-adapter # Run test harness docker run --rm \ --name test-harness \ --network test-network \ ghcr.io/posthog/sdk-test-harness:latest \ run --adapter-url http://sdk-adapter:8080 --mock-url http://test-harness:8081 # Cleanup docker stop sdk-adapter && docker rm sdk-adapter docker network rm test-network ``` -------------------------------- ### posthog.exception_utils.get_error_message Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Extracts the error message from an exception value. Provides a standardized way to get the human-readable error description. ```APIDOC ## posthog.exception_utils.get_error_message ### Description Extracts the error message from an exception value. Provides a standardized way to get the human-readable error description. ### Parameters - **exc_value** (Any) - The exception value. ### Returns - **str** - The error message. ``` -------------------------------- ### posthog.ai.claude_agent_sdk.client.PostHogClaudeSDKClient.connect Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Connects to the Claude Agent SDK client. Initializes the connection for agent interactions. ```APIDOC ## posthog.ai.claude_agent_sdk.client.PostHogClaudeSDKClient.connect ### Description Connects to the Claude Agent SDK client. ### Method Not applicable (method call) ### Parameters - **prompt** (Any) - Optional - The initial prompt to send upon connection. ### Returns None ``` -------------------------------- ### posthog.exception_utils.event_hint_with_exc_info Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Creates an event hint dictionary that includes exception information. This is used to enrich event data with error details. ```APIDOC ## posthog.exception_utils.event_hint_with_exc_info ### Description Creates an event hint dictionary that includes exception information. This is used to enrich event data with error details. ### Parameters - **exc_info** (Optional[tuple]) - Exception information tuple (type, value, traceback). ``` -------------------------------- ### Prompts Methods Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Methods for interacting with PostHog's AI prompt features, including cache management and prompt compilation. ```APIDOC ## Prompts.clear_cache ### Description Clears the cache for prompts. You can optionally specify a name and version to clear a specific cached prompt. ### Method `clear_cache` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **name** (Optional[str]) - The name of the prompt to clear from the cache. * **version** (Optional[int]) - The version of the prompt to clear from the cache. ### Response #### Success Response (None) This method does not return a value. ### Response Example ``` None ``` ``` ```APIDOC ## Prompts.compile ### Description Compiles a given prompt string by substituting variables. ### Method `compile` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **prompt** (str) - The prompt string to compile. * **variables** (PromptVariables) - A dictionary or object containing the variables to substitute into the prompt. ### Response #### Success Response (str) Returns the compiled prompt string with variables substituted. ### Response Example ``` "Hello, {{name}}!" ``` ``` ```APIDOC ## Prompts.get ### Description Retrieves a prompt by its name, with options for metadata, cache TTL, fallback, and version. ### Method `get` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **name** (str) - The name of the prompt to retrieve. * **with_metadata** (Optional[bool]) - Whether to include metadata with the prompt result. * **cache_ttl_seconds** (Optional[int]) - The time-to-live for the cache in seconds. * **fallback** (Optional[str]) - A fallback prompt to return if the requested prompt is not found. * **version** (Optional[int]) - The specific version of the prompt to retrieve. ### Response #### Success Response (Union[str, PromptResult]) Returns the prompt as a string or a `PromptResult` object if `with_metadata` is true. ### Response Example ``` "This is the prompt content." ``` ``` -------------------------------- ### Run DSPy Prediction with PostHog Tracking Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-dspy/README.md Source the environment variables and run the predict.py script using uv. ```bash source .env uv run python predict.py ``` -------------------------------- ### posthog.request.HTTPAdapterWithSocketOptions.init_poolmanager Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Initializes the pool manager with socket options. ```APIDOC ## method posthog.request.HTTPAdapterWithSocketOptions.init_poolmanager(*args, **kwargs) ### Description Initializes the pool manager with socket options. ### Method `None` ### Endpoint `None` ### Parameters #### Request Body - **args** - Required - Positional arguments for initialization. - **kwargs** - Required - Keyword arguments for initialization. ### Request Example None ### Response #### Success Response `None` #### Response Example None ``` -------------------------------- ### HTTPAdapterWithSocketOptions Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt HTTP adapter with support for custom socket options. ```APIDOC ## Class: HTTPAdapterWithSocketOptions ### Description An HTTP adapter that allows configuring custom socket options for connections. ### Parameters * `*args`: Positional arguments for the base adapter. * `socket_options` (Optional[SocketOptions]): Custom socket options to apply. * `**kwargs`: Keyword arguments for the base adapter. ``` -------------------------------- ### Run Full Compliance Suite with Docker Compose Source: https://github.com/posthog/posthog-python/blob/main/sdk_compliance_adapter/CONTRIBUTING.md Execute all compliance tests locally using Docker Compose. This command builds the adapter, pulls the test harness, runs tests, and displays results. ```bash docker-compose up --build --abort-on-container-exit ``` -------------------------------- ### Run Instrumented Agent Source: https://github.com/posthog/posthog-python/blob/main/examples/example-ai-pydantic-ai/README.md Source your environment variables and run the Python agent script using uv. This script includes tool calling and is instrumented via OpenTelemetry. ```bash source .env uv run python agent_with_otel.py ``` -------------------------------- ### OpenAI Wrapper Utilities Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Utilities for managing fallback warnings in OpenAI integrations. ```APIDOC ## OpenAI Wrapper Utilities Utilities for managing OpenAI wrapper behavior. ### `reset_fallback_warnings() -> None` Resets fallback warnings for OpenAI wrappers. ### `warn_on_fallback(wrapper_name: str, name: str) -> None` Logs a warning when a fallback is used in an OpenAI wrapper. ``` -------------------------------- ### instrument Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Instruments the Claude Agent SDK for PostHog integration. ```APIDOC ## Function: instrument ### Description Initializes and instruments the Claude Agent SDK to integrate with PostHog for tracking and analytics. ### Parameters * `client` (Optional[Client]): An optional PostHog client instance. * `distinct_id` (Optional[Union[str, Callable[[ResultMessage], Optional[str]]]]): A distinct ID for tracking or a function to generate it. * `privacy_mode` (bool): Enables privacy mode for tracking. Defaults to False. * `groups` (Optional[Dict[str, Any]]): Optional group properties for PostHog. * `properties` (Optional[Dict[str, Any]]): Optional user properties for PostHog. ``` -------------------------------- ### query Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Queries the Claude Agent SDK with specified options. ```APIDOC ## Function: query ### Description Sends a query to the Claude Agent SDK, allowing for detailed configuration of the prompt, agent options, and PostHog integration. ### Parameters * `prompt` (Any): The prompt to send to the agent. * `options` (Optional[ClaudeAgentOptions]): Options for the Claude agent. * `transport` (Any): The transport layer to use. * `posthog_client` (Optional[Client]): An optional PostHog client instance. * `posthog_distinct_id` (Optional[Union[str, Callable[[ResultMessage], Optional[str]]]]): Distinct ID for PostHog tracking. * `posthog_trace_id` (Optional[str]): Trace ID for PostHog. * `posthog_properties` (Optional[Dict[str, Any]]): Additional properties for PostHog events. * `posthog_privacy_mode` (bool): Enables privacy mode for PostHog tracking. Defaults to False. * `posthog_groups` (Optional[Dict[str, Any]]): Optional group properties for PostHog. ``` -------------------------------- ### PostHogTracingProcessor Methods Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Methods for processing traces within the PostHog tracing system. ```APIDOC ## method posthog.ai.openai_agents.processor.PostHogTracingProcessor.force_flush ### Description Forces a flush of any buffered trace data. ### Method POST (inferred) ### Endpoint /processor/force_flush (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **result** (None) - Indicates the operation completed. #### Response Example ```json { "result": null } ``` ## method posthog.ai.openai_agents.processor.PostHogTracingProcessor.on_span_end ### Description Callback executed when a trace span ends. ### Method POST (inferred) ### Endpoint /processor/on_span_end (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **span** (Span[Any]) - Required - The span that has ended. ### Request Example ```json { "span": {"name": "example_span", "duration": 100} } ``` ### Response #### Success Response (200) - **result** (None) - Indicates the operation completed. #### Response Example ```json { "result": null } ``` ## method posthog.ai.openai_agents.processor.PostHogTracingProcessor.on_span_start ### Description Callback executed when a trace span starts. ### Method POST (inferred) ### Endpoint /processor/on_span_start (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **span** (Span[Any]) - Required - The span that is starting. ### Request Example ```json { "span": {"name": "example_span", "start_time": "2023-10-27T10:00:00Z"} } ``` ### Response #### Success Response (200) - **result** (None) - Indicates the operation completed. #### Response Example ```json { "result": null } ``` ## method posthog.ai.openai_agents.processor.PostHogTracingProcessor.on_trace_end ### Description Callback executed when a trace ends. ### Method POST (inferred) ### Endpoint /processor/on_trace_end (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **trace** (Trace) - Required - The trace that has ended. ### Request Example ```json { "trace": {"trace_id": "trace123", "status": "COMPLETED"} } ``` ### Response #### Success Response (200) - **result** (None) - Indicates the operation completed. #### Response Example ```json { "result": null } ``` ## method posthog.ai.openai_agents.processor.PostHogTracingProcessor.on_trace_start ### Description Callback executed when a trace starts. ### Method POST (inferred) ### Endpoint /processor/on_trace_start (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **trace** (Trace) - Required - The trace that is starting. ### Request Example ```json { "trace": {"trace_id": "trace123", "start_time": "2023-10-27T10:00:00Z"} } ``` ### Response #### Success Response (200) - **result** (None) - Indicates the operation completed. #### Response Example ```json { "result": null } ``` ## method posthog.ai.openai_agents.processor.PostHogTracingProcessor.shutdown ### Description Shuts down the tracing processor. ### Method POST (inferred) ### Endpoint /processor/shutdown (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **result** (None) - Indicates the operation completed. #### Response Example ```json { "result": null } ``` ``` -------------------------------- ### Async OpenAI Wrapped Methods Source: https://github.com/posthog/posthog-python/blob/main/references/public_api_snapshot.txt Asynchronous methods for wrapping OpenAI API calls to enable PostHog tracking. ```APIDOC ## method posthog.ai.openai.openai_async.WrappedBetaCompletions.parse ### Description Asynchronously parses responses from OpenAI Beta Completions, enabling PostHog tracking. ### Method POST (inferred) ### Endpoint /openai_async/beta_completions/parse (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **posthog_distinct_id** (Optional[str]) - Optional - PostHog distinct ID for tracking. - **posthog_trace_id** (Optional[str]) - Optional - PostHog trace ID for correlation. - **posthog_properties** (Optional[Dict[str, Any]]) - Optional - Additional properties to send with the event. - **posthog_privacy_mode** (bool) - Optional - Enables privacy mode for tracking. - **posthog_groups** (Optional[Dict[str, Any]]) - Optional - Groups to associate with the event. - **kwargs** (Any) - Additional keyword arguments. ### Request Example ```json { "posthog_distinct_id": "user123", "posthog_trace_id": "trace456", "posthog_properties": {"model": "gpt-4"}, "posthog_privacy_mode": false, "posthog_groups": {"company": "posthog"} } ``` ### Response #### Success Response (200) - **result** (Any) - The parsed result. #### Response Example ```json { "result": "Parsed data" } ``` ## method posthog.ai.openai.openai_async.WrappedCompletions.create ### Description Asynchronously creates completions using OpenAI, with PostHog tracking capabilities. ### Method POST (inferred) ### Endpoint /openai_async/completions/create (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **posthog_distinct_id** (Optional[str]) - Optional - PostHog distinct ID for tracking. - **posthog_trace_id** (Optional[str]) - Optional - PostHog trace ID for correlation. - **posthog_properties** (Optional[Dict[str, Any]]) - Optional - Additional properties to send with the event. - **posthog_privacy_mode** (bool) - Optional - Enables privacy mode for tracking. - **posthog_groups** (Optional[Dict[str, Any]]) - Optional - Groups to associate with the event. - **kwargs** (Any) - Additional keyword arguments. ### Request Example ```json { "posthog_distinct_id": "user123", "posthog_trace_id": "trace456", "posthog_properties": {"model": "gpt-3.5-turbo"}, "posthog_privacy_mode": false, "posthog_groups": {"company": "posthog"} } ``` ### Response #### Success Response (200) - **result** (Any) - The created completion. #### Response Example ```json { "result": "Completion text" } ``` ## method posthog.ai.openai.openai_async.WrappedCompletions.parse ### Description Asynchronously parses responses from OpenAI Completions, enabling PostHog tracking. ### Method POST (inferred) ### Endpoint /openai_async/completions/parse (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **posthog_distinct_id** (Optional[str]) - Optional - PostHog distinct ID for tracking. - **posthog_trace_id** (Optional[str]) - Optional - PostHog trace ID for correlation. - **posthog_properties** (Optional[Dict[str, Any]]) - Optional - Additional properties to send with the event. - **posthog_privacy_mode** (bool) - Optional - Enables privacy mode for tracking. - **posthog_groups** (Optional[Dict[str, Any]]) - Optional - Groups to associate with the event. - **kwargs** (Any) - Additional keyword arguments. ### Request Example ```json { "posthog_distinct_id": "user123", "posthog_trace_id": "trace456", "posthog_properties": {"model": "gpt-3.5-turbo"}, "posthog_privacy_mode": false, "posthog_groups": {"company": "posthog"} } ``` ### Response #### Success Response (200) - **result** (Any) - The parsed result. #### Response Example ```json { "result": "Parsed data" } ``` ## method posthog.ai.openai.openai_async.WrappedEmbeddings.create ### Description Asynchronously creates embeddings using OpenAI, with PostHog tracking capabilities. ### Method POST (inferred) ### Endpoint /openai_async/embeddings/create (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **posthog_distinct_id** (Optional[str]) - Optional - PostHog distinct ID for tracking. - **posthog_trace_id** (Optional[str]) - Optional - PostHog trace ID for correlation. - **posthog_properties** (Optional[Dict[str, Any]]) - Optional - Additional properties to send with the event. - **posthog_privacy_mode** (bool) - Optional - Enables privacy mode for tracking. - **posthog_groups** (Optional[Dict[str, Any]]) - Optional - Groups to associate with the event. - **kwargs** (Any) - Additional keyword arguments. ### Request Example ```json { "posthog_distinct_id": "user123", "posthog_trace_id": "trace456", "posthog_properties": {"model": "text-embedding-ada-002"}, "posthog_privacy_mode": false, "posthog_groups": {"company": "posthog"} } ``` ### Response #### Success Response (200) - **result** (Any) - The created embeddings. #### Response Example ```json { "result": [0.1, 0.2, 0.3] } ``` ## method posthog.ai.openai.openai_async.WrappedResponses.create ### Description Asynchronously creates responses using OpenAI, with PostHog tracking capabilities. ### Method POST (inferred) ### Endpoint /openai_async/responses/create (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **posthog_distinct_id** (Optional[str]) - Optional - PostHog distinct ID for tracking. - **posthog_trace_id** (Optional[str]) - Optional - PostHog trace ID for correlation. - **posthog_properties** (Optional[Dict[str, Any]]) - Optional - Additional properties to send with the event. - **posthog_privacy_mode** (bool) - Optional - Enables privacy mode for tracking. - **posthog_groups** (Optional[Dict[str, Any]]) - Optional - Groups to associate with the event. - **kwargs** (Any) - Additional keyword arguments. ### Request Example ```json { "posthog_distinct_id": "user123", "posthog_trace_id": "trace456", "posthog_properties": {"model": "gpt-4"}, "posthog_privacy_mode": false, "posthog_groups": {"company": "posthog"} } ``` ### Response #### Success Response (200) - **result** (Any) - The created response. #### Response Example ```json { "result": "Response text" } ``` ## method posthog.ai.openai.openai_async.WrappedResponses.parse ### Description Asynchronously parses responses from OpenAI, enabling PostHog tracking. ### Method POST (inferred) ### Endpoint /openai_async/responses/parse (inferred) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **posthog_distinct_id** (Optional[str]) - Optional - PostHog distinct ID for tracking. - **posthog_trace_id** (Optional[str]) - Optional - PostHog trace ID for correlation. - **posthog_properties** (Optional[Dict[str, Any]]) - Optional - Additional properties to send with the event. - **posthog_privacy_mode** (bool) - Optional - Enables privacy mode for tracking. - **posthog_groups** (Optional[Dict[str, Any]]) - Optional - Groups to associate with the event. - **kwargs** (Any) - Additional keyword arguments. ### Request Example ```json { "posthog_distinct_id": "user123", "posthog_trace_id": "trace456", "posthog_properties": {"model": "gpt-4"}, "posthog_privacy_mode": false, "posthog_groups": {"company": "posthog"} } ``` ### Response #### Success Response (200) - **result** (Any) - The parsed result. #### Response Example ```json { "result": "Parsed data" } ``` ```