{"id":28635545,"url":"https://github.com/comet-ml/opik-kong-plugin","last_synced_at":"2025-06-12T17:10:58.495Z","repository":{"id":270173730,"uuid":"906225086","full_name":"comet-ml/opik-kong-plugin","owner":"comet-ml","description":"Opik plugin for the Kong AI Gateway","archived":false,"fork":false,"pushed_at":"2024-12-20T12:29:43.000Z","size":11,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-06T05:46:43.734Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/comet-ml.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-20T12:28:52.000Z","updated_at":"2025-05-15T08:01:04.000Z","dependencies_parsed_at":"2024-12-29T04:08:16.879Z","dependency_job_id":"7aa2b601-4d2d-45b4-85f8-d4b19222b1a7","html_url":"https://github.com/comet-ml/opik-kong-plugin","commit_stats":null,"previous_names":["comet-ml/opik-kong-plugin"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/comet-ml/opik-kong-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comet-ml%2Fopik-kong-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comet-ml%2Fopik-kong-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comet-ml%2Fopik-kong-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comet-ml%2Fopik-kong-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/comet-ml","download_url":"https://codeload.github.com/comet-ml/opik-kong-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comet-ml%2Fopik-kong-plugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259509474,"owners_count":22868837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-12T17:10:57.229Z","updated_at":"2025-06-12T17:10:58.464Z","avatar_url":"https://github.com/comet-ml.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Opik - Kong plugin\n\n## Introduction\n[Kong](https://docs.konghq.com/gateway/latest/ai-gateway/) is an open-source API gateway that can be easily extended to act as an LLM proxy, allowing you to use AI models from the comfort of your API Gateway.\n\nThe Opik plugin allows you to log all AI Gateway requests to the Opik platform. This allows you to monitor, analyze and debug you AI Gateway requests without requiring users to manually log their requests.\n\nIt is meant to be used in conjunction with the [AI Proxy](https://docs.konghq.com/hub/kong-inc/ai-proxy/) is a Kong plugin that allows you to proxy LLM calls to multiple LLM providers using a standardized format.\n\n### How it works\n\nThe Opik plugin works by intercepting all requests made to the AI Gateway and logging them in a standardized format to the Opik platform. The pluging will automatically log the following information:\n\n- Request payload: This is the list of messages and LLM parameters submited by the user\n- Response payload: This is the response from the LLM provider\n- Model used: This is the name of the model that was used to generate the response\n- Usage payload: The number of tokens used by the LLM provider to generate the response\n\nYou can learn more about the LLM providers supported by the Kong AI proxy plugin [here](https://docs.konghq.com/hub/kong-inc/ai-proxy/).\n\n### Get started with the Opik plugin\n\nTo install the Opik plugin, you need to add it to your Kong configuration file. You can find more information on how to install plugins in the [Kong documentation](https://docs.konghq.com/gateway/3.9.x/plugin-development/distribution/#packaging-sources).\n\nThe full configuration option for this plugin can be found below.\n\n**Note:** In order to log the payload request and response, you will need to enable the [`logging.payload_logs`](https://docs.konghq.com/hub/kong-inc/ai-proxy/configuration/#config-logging-log_payloads) option in the AI Proxy plugin.\n\n## Configuration\n\nThe Opik-Log plugin has the following configuration options:\n\n- `http_endpoint`: (Required, Encrypted, Referenceable) The endpoint URL where logs will be sent. Defaults to \"https://www.comet.com/opik/\". Note: encryption is only available in Kong Enterprise.\n- `ai_proxy_name`: (Required) The name of the AI proxy. Defaults to \"proxy\".\n- `opik_api_key`: (Required, Encrypted) The Opik API key for authentication.\n- `opik_workspace`: (Required) The Opik Workspace identifier.\n- `timeout`: Timeout in milliseconds when sending data to the upstream server. Defaults to 10000ms (10 seconds).\n- `keepalive`: Duration in milliseconds that defines how long an idle connection will live before being closed. Defaults to 60000ms (60 seconds).\n\n## Using the plugin\n\nTo install the plugin, will need to clone this repository and follow the instructions in the [Kong documentation](https://docs.konghq.com/gateway/3.9.x/plugin-development/distribution/#packaging-sources).\n\nIf you are using the Kong Admin API, you can use the following command to install the plugin:\n\n```bash\ncurl -is -X POST http://localhost:8001/services/{serviceName|Id}/plugins \\\n    --header \"accept: application/json\" \\\n  --header \"Content-Type: application/json\" \\\n  --data '\n  {\n    \"name\": \"opik-log\",\n    \"config\": {\n      \"opik_api_key\": \"\u003cReplace with your Opik API key\u003e\",\n      \"opik_workspace\": \"\u003cReplace with your Opik workspace\u003e\"\n    }\n  }'\n```\n\n**Note:** This plugin is currently in public preview, if you would like us to support additional features please create an issue [here](https://github.com/comet-ml/opik/issues).\n\n## Developing the pluging\n\nYou can use the `pongo` development environment to develop the plugin. You can learn more about the pongo development environment and how to install it [here](https://github.com/Kong/kong-pongo?tab=readme-ov-file#installation).\n\nOnce you have pongo installed you can run the following command **from the opik-kong-plugin directory** to start the development environment:\n\n1. Start the pongo development environment\n```bash\npongo up\n```\n\n2. Launch the Gateway and open a shell with it:\n\n```bash\npongo shell\n```\n\n3. Once the gateway is running, you can start by checking the Opik log plugin is available:\n\n```bash\ncurl -s localhost:8001 | \\\n  jq '.plugins.available_on_server.\"opik-log\"'\n```\n\nThis should return the plugin version and priority\n\n4. You can now configure the AI gateway and Opik log plugin:\n\n```bash\ncurl -i -X POST http://localhost:8001/services/llm_service/routes \\\n  --data name=\"openai-llm\" \\\n  --data paths=\"/openai\"\n\ncurl -i -X POST http://localhost:8001/routes/openai-llm/plugins \\\n  --header \"accept: application/json\" \\\n  --header \"Content-Type: application/json\" \\\n  --data '\n  {\n    \"name\": \"ai-proxy\",\n    \"config\": {\n      \"route_type\": \"llm/v1/chat\",\n      \"model\": {\n        \"provider\": \"openai\"\n      },\n      \"logging\": {\n        \"log_payloads\": true,\n        \"log_statistics\": true\n      }\n    }\n  }'\n\ncurl -is -X POST http://localhost:8001/routes/openai-llm/plugins \\\n    --header \"accept: application/json\" \\\n  --header \"Content-Type: application/json\" \\\n  --data '\n  {\n    \"name\": \"opik-log\",\n    \"config\": {\n      \"opik_api_key\": \"\u003cReplace with your Opik API key\u003e\",\n      \"opik_workspace\": \"jacques-comet\"\n    }\n  }'\n```\n\n5. You can call the AI gateway and check the logs of the Opik log plugin:\n\n```bash\ncurl --http1.1 http://localhost:8000/openai \\\n  --header \"Content-Type: application/json\" \\\n  --header \"Authorization: Bearer \u003cOPENAI_API_KEY\u003e\" \\\n  --data '{\n     \"model\": \"gpt-4o-mini\",\n     \"messages\": [{\"role\": \"user\", \"content\": \"Say this is a test!\"}]\n   }'\n```\n\nand \n\n```bash\ncat /kong-plugin/servroot/logs/error.log\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomet-ml%2Fopik-kong-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomet-ml%2Fopik-kong-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomet-ml%2Fopik-kong-plugin/lists"}