From a5b677befb55f860dfad013c3123220304e3f3f0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 02:08:55 +0000 Subject: [PATCH 01/36] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 3d19128a..1ee5069c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-70c42eda2bee929830b2537f758400a58dded1f1ef5686a286e2469c35a041a0.yml openapi_spec_hash: cdaeed824e91657b45092765cf55eb42 -config_hash: e3c2679d25f6235381dfb11962fbf3d9 +config_hash: 83967503e501e4199b4042d0d0f2b615 From 352ec15b82f69fa56005e12eb53af84e6397d12e Mon Sep 17 00:00:00 2001 From: Manu Chaudhary Date: Mon, 13 Apr 2026 08:04:23 +0530 Subject: [PATCH 02/36] chore: remove webhook signature verification example from README --- README.md | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/README.md b/README.md index fd8899f7..76bb808c 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,6 @@ If you are looking to integrate file uploads in browsers, use one of our [fronte - [Using Raw parameter for custom transformations](#using-raw-parameter-for-custom-transformations) - [Authentication parameters for client-side uploads](#authentication-parameters-for-client-side-uploads) - [Webhook verification](#webhook-verification) - - [Verifying webhook signatures](#verifying-webhook-signatures) - [Handling errors](#handling-errors) - [Retries](#retries) - [Timeouts](#timeouts) @@ -353,35 +352,6 @@ These authentication parameters can be used in client-side upload forms to secur The ImageKit SDK provides utilities to verify webhook signatures for secure event handling. This ensures that webhook requests are actually coming from ImageKit and haven't been tampered with. -### Verifying webhook signatures - -```ts -import ImageKit from '@imagekit/nodejs'; - -const client = new ImageKit({ - privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], - webhookSecret: process.env['IMAGEKIT_WEBHOOK_SECRET'], // Required for webhook verification -}); - -try { - // Verify and unwrap webhook payload - const event = client.webhooks.unwrap( - webhookBody, // Raw webhook payload (string) - { - headers: webhookHeaders, // Request headers containing signature - }, - ); - - console.log('Webhook signature is valid'); - console.log('Event type:', event.type); - console.log('Event data:', event.data); - // Process the webhook event -} catch (error) { - console.log('Invalid webhook signature or malformed payload'); - // Reject the request -} -``` - For detailed information about webhook setup, signature verification, and handling different webhook events, refer to the [ImageKit webhook documentation](https://imagekit.io/docs/webhooks#verify-webhook-signature). ## Handling errors From c424b949a56ff4b4486cd694c073615e5293bcc3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 15:23:57 +0000 Subject: [PATCH 03/36] chore: fix example snippet imports --- packages/mcp-server/src/local-docs-search.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 5388085b..a838265b 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -381,7 +381,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ typescript: { method: 'client.files.upload', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);", + "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);", }, }, }, @@ -2955,7 +2955,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ typescript: { method: 'client.beta.v2.files.upload', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.beta.v2.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);", + "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.beta.v2.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);", }, }, }, From 1967acf48ab8aae241680a623fc311da6c2cfd6a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 17:46:34 +0000 Subject: [PATCH 04/36] chore: update CLI documentation --- packages/mcp-server/src/local-docs-search.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index a838265b..4db1f540 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -3095,7 +3095,7 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'cli', content: - "# Image Kit CLI\n\nThe official CLI for the [Image Kit REST API](https://imagekit.io/docs/api-reference).\n\n## Installation\n\n### Installing with Go\n\nTo test or install the CLI locally, you need [Go](https://go.dev/doc/install) version 1.22 or later installed.\n\n~~~sh\ngo install 'github.com/stainless-sdks/imagekit-cli/cmd/imagekit@latest'\n~~~\n\nOnce you have run `go install`, the binary is placed in your Go bin directory:\n\n- **Default location**: `$HOME/go/bin` (or `$GOPATH/bin` if GOPATH is set)\n- **Check your path**: Run `go env GOPATH` to see the base directory\n\nIf commands aren't found after installation, add the Go bin directory to your PATH:\n\n~~~sh\n# Add to your shell profile (.zshrc, .bashrc, etc.)\nexport PATH=\"$PATH:$(go env GOPATH)/bin\"\n~~~\n\n### Running Locally\n\nAfter cloning the git repository for this project, you can use the\n`scripts/run` script to run the tool locally:\n\n~~~sh\n./scripts/run args...\n~~~\n\n## Usage\n\nThe CLI follows a resource-based command structure:\n\n~~~sh\nimagekit [resource] [flags...]\n~~~\n\n~~~sh\nimagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name file-name.jpg\n~~~\n\nFor details about specific commands, use the `--help` flag.\n\n### Environment variables\n\n| Environment variable | Description | Required | Default value |\n| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------- |\n| `IMAGEKIT_PRIVATE_KEY` | Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n | yes | |\n| `OPTIONAL_IMAGEKIT_IGNORES_THIS` | ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n | no | `\"do_not_set\"` |\n| `IMAGEKIT_WEBHOOK_SECRET` | Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n | no | `null` |\n\n### Global flags\n\n- `--private-key` - Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n (can also be set with `IMAGEKIT_PRIVATE_KEY` env var)\n- `--password` - ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n (can also be set with `OPTIONAL_IMAGEKIT_IGNORES_THIS` env var)\n- `--webhook-secret` - Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n (can also be set with `IMAGEKIT_WEBHOOK_SECRET` env var)\n- `--help` - Show command line usage\n- `--debug` - Enable debug logging (includes HTTP request/response details)\n- `--version`, `-v` - Show the CLI version\n- `--base-url` - Use a custom API backend URL\n- `--format` - Change the output format (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--format-error` - Change the output format for errors (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--transform` - Transform the data output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n- `--transform-error` - Transform the error output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n\n### Passing files as arguments\n\nTo pass files to your API, you can use the `@myfile.ext` syntax:\n\n~~~bash\nimagekit --arg @abe.jpg\n~~~\n\nFiles can also be passed inside JSON or YAML blobs:\n\n~~~bash\nimagekit --arg '{image: \"@abe.jpg\"}'\n# Equivalent:\nimagekit < --username '\\@abe'\n~~~\n\n#### Explicit encoding\n\nFor JSON endpoints, the CLI tool does filetype sniffing to determine whether the\nfile contents should be sent as a string literal (for plain text files) or as a\nbase64-encoded string literal (for binary files). If you need to explicitly send\nthe file as either plain text or base64-encoded data, you can use\n`@file://myfile.txt` (for string encoding) or `@data://myfile.dat` (for\nbase64-encoding). Note that absolute paths will begin with `@file://` or\n`@data://`, followed by a third `/` (for example, `@file:///tmp/file.txt`).\n\n~~~bash\nimagekit --arg @data://file.txt\n~~~\n", + "# Image Kit CLI\n\nThe official CLI for the [Image Kit REST API](https://imagekit.io/docs/api-reference).\n\n## Installation\n\n### Installing with Go\n\nTo test or install the CLI locally, you need [Go](https://go.dev/doc/install) version 1.22 or later installed.\n\n~~~sh\ngo install 'github.com/stainless-sdks/imagekit-cli/cmd/imagekit@latest'\n~~~\n\nOnce you have run `go install`, the binary is placed in your Go bin directory:\n\n- **Default location**: `$HOME/go/bin` (or `$GOPATH/bin` if GOPATH is set)\n- **Check your path**: Run `go env GOPATH` to see the base directory\n\nIf commands aren't found after installation, add the Go bin directory to your PATH:\n\n~~~sh\n# Add to your shell profile (.zshrc, .bashrc, etc.)\nexport PATH=\"$PATH:$(go env GOPATH)/bin\"\n~~~\n\n### Running Locally\n\nAfter cloning the git repository for this project, you can use the\n`scripts/run` script to run the tool locally:\n\n~~~sh\n./scripts/run args...\n~~~\n\n## Usage\n\nThe CLI follows a resource-based command structure:\n\n~~~sh\nimagekit [resource] [flags...]\n~~~\n\n~~~sh\nimagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name file-name.jpg\n~~~\n\nFor details about specific commands, use the `--help` flag.\n\n### Environment variables\n\n| Environment variable | Description | Required | Default value |\n| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------- |\n| `IMAGEKIT_PRIVATE_KEY` | Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n | yes | |\n| `OPTIONAL_IMAGEKIT_IGNORES_THIS` | ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n | no | `\"do_not_set\"` |\n| `IMAGEKIT_WEBHOOK_SECRET` | Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n | no | `null` |\n\n### Global flags\n\n- `--private-key` - Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n (can also be set with `IMAGEKIT_PRIVATE_KEY` env var)\n- `--password` - ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n (can also be set with `OPTIONAL_IMAGEKIT_IGNORES_THIS` env var)\n- `--webhook-secret` - Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n (can also be set with `IMAGEKIT_WEBHOOK_SECRET` env var)\n- `--help` - Show command line usage\n- `--debug` - Enable debug logging (includes HTTP request/response details)\n- `--version`, `-v` - Show the CLI version\n- `--base-url` - Use a custom API backend URL\n- `--format` - Change the output format (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--format-error` - Change the output format for errors (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--transform` - Transform the data output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n- `--transform-error` - Transform the error output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n\n### Passing files as arguments\n\nTo pass files to your API, you can use the `@myfile.ext` syntax:\n\n~~~bash\nimagekit --arg @abe.jpg\n~~~\n\nFiles can also be passed inside JSON or YAML blobs:\n\n~~~bash\nimagekit --arg '{image: \"@abe.jpg\"}'\n# Equivalent:\nimagekit < --username '\\@abe'\n~~~\n\n#### Explicit encoding\n\nFor JSON endpoints, the CLI tool does filetype sniffing to determine whether the\nfile contents should be sent as a string literal (for plain text files) or as a\nbase64-encoded string literal (for binary files). If you need to explicitly send\nthe file as either plain text or base64-encoded data, you can use\n`@file://myfile.txt` (for string encoding) or `@data://myfile.dat` (for\nbase64-encoding). Note that absolute paths will begin with `@file://` or\n`@data://`, followed by a third `/` (for example, `@file:///tmp/file.txt`).\n\n~~~bash\nimagekit --arg @data://file.txt\n~~~\n\n## Linking different Go SDK versions\n\nYou can link the CLI against a different version of the Image Kit Go SDK\nfor development purposes using the `./scripts/link` script.\n\nTo link to a specific version from a repository (version can be a branch,\ngit tag, or commit hash):\n\n~~~bash\n./scripts/link github.com/org/repo@version\n~~~\n\nTo link to a local copy of the SDK:\n\n~~~bash\n./scripts/link ../path/to/imagekit-go\n~~~\n\nIf you run the link script without any arguments, it will default to `../imagekit-go`.\n", }, { language: 'php', From a3427fef3d71bbe5e1717e362d4654d4942d8df9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 03:53:04 +0000 Subject: [PATCH 05/36] chore: configure new SDK language --- .stats.yml | 2 +- packages/mcp-server/Dockerfile | 6 +- packages/mcp-server/README.md | 10 +- packages/mcp-server/build | 2 +- .../mcp-server/cloudflare-worker/package.json | 2 +- .../mcp-server/cloudflare-worker/src/index.ts | 2 +- packages/mcp-server/jest.config.ts | 4 +- packages/mcp-server/manifest.json | 2 +- packages/mcp-server/package.json | 6 +- packages/mcp-server/src/local-docs-search.ts | 258 +++++++++++++++++- packages/mcp-server/tsconfig.build.json | 4 +- packages/mcp-server/tsconfig.json | 4 +- 12 files changed, 275 insertions(+), 27 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1ee5069c..3aa7595d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-70c42eda2bee929830b2537f758400a58dded1f1ef5686a286e2469c35a041a0.yml openapi_spec_hash: cdaeed824e91657b45092765cf55eb42 -config_hash: 83967503e501e4199b4042d0d0f2b615 +config_hash: 2a6f67c966b8b3db6f986be4ac23a507 diff --git a/packages/mcp-server/Dockerfile b/packages/mcp-server/Dockerfile index 591955c5..c45b8e10 100644 --- a/packages/mcp-server/Dockerfile +++ b/packages/mcp-server/Dockerfile @@ -3,10 +3,10 @@ # This Dockerfile builds a Docker image for the MCP Server. # # To build the image locally: -# docker build -f packages/mcp-server/Dockerfile -t @imagekit/api-mcp:local . +# docker build -f packages/mcp-server/Dockerfile -t @imagekit/nodejs-mcp:local . # # To run the image: -# docker run -i @imagekit/api-mcp:local [OPTIONS] +# docker run -i @imagekit/nodejs-mcp:local [OPTIONS] # # Common options: # --tool= Include specific tools @@ -16,7 +16,7 @@ # --transport= Set transport type (stdio or http) # # For a full list of options: -# docker run -i @imagekit/api-mcp:local --help +# docker run -i @imagekit/nodejs-mcp:local --help # # Note: The MCP server uses stdio transport by default. Docker's -i flag # enables interactive mode, allowing the container to communicate over stdin/stdout. diff --git a/packages/mcp-server/README.md b/packages/mcp-server/README.md index 2fe6b778..74900266 100644 --- a/packages/mcp-server/README.md +++ b/packages/mcp-server/README.md @@ -10,7 +10,7 @@ You can run the MCP Server directly via `npx`: export IMAGEKIT_PRIVATE_KEY="My Private Key" export OPTIONAL_IMAGEKIT_IGNORES_THIS="My Password" export IMAGEKIT_WEBHOOK_SECRET="My Webhook Secret" -npx -y @imagekit/api-mcp@latest +npx -y @imagekit/nodejs-mcp@latest ``` ### Via MCP Client @@ -25,7 +25,7 @@ For clients with a configuration JSON, it might look something like this: "mcpServers": { "imagekit_nodejs_api": { "command": "npx", - "args": ["-y", "@imagekit/api-mcp"], + "args": ["-y", "@imagekit/nodejs-mcp"], "env": { "IMAGEKIT_PRIVATE_KEY": "My Private Key", "OPTIONAL_IMAGEKIT_IGNORES_THIS": "My Password", @@ -41,14 +41,14 @@ For clients with a configuration JSON, it might look something like this: If you use Cursor, you can install the MCP server by using the button below. You will need to set your environment variables in Cursor's `mcp.json`, which can be found in Cursor Settings > Tools & MCP > New MCP Server. -[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19) +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19) ### VS Code If you use MCP, you can install the MCP server by clicking the link below. You will need to set your environment variables in VS Code's `mcp.json`, which can be found via Command Palette > MCP: Open User Configuration. -[Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D) +[Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D) ### Claude Code @@ -56,7 +56,7 @@ If you use Claude Code, you can install the MCP server by running the command be environment variables in Claude Code's `.claude.json`, which can be found in your home directory. ``` -claude mcp add imagekit_api_mcp_api --env IMAGEKIT_PRIVATE_KEY="My Private Key" OPTIONAL_IMAGEKIT_IGNORES_THIS="My Password" IMAGEKIT_WEBHOOK_SECRET="My Webhook Secret" -- npx -y @imagekit/api-mcp +claude mcp add imagekit_nodejs_mcp_api --env IMAGEKIT_PRIVATE_KEY="My Private Key" OPTIONAL_IMAGEKIT_IGNORES_THIS="My Password" IMAGEKIT_WEBHOOK_SECRET="My Webhook Secret" -- npx -y @imagekit/nodejs-mcp ``` ## Code Mode diff --git a/packages/mcp-server/build b/packages/mcp-server/build index 90381d31..e1ea7a1c 100644 --- a/packages/mcp-server/build +++ b/packages/mcp-server/build @@ -29,7 +29,7 @@ cp tsconfig.dist-src.json dist/src/tsconfig.json chmod +x dist/index.js -DIST_PATH=./dist PKG_IMPORT_PATH=@imagekit/api-mcp/ node ../../scripts/utils/postprocess-files.cjs +DIST_PATH=./dist PKG_IMPORT_PATH=@imagekit/nodejs-mcp/ node ../../scripts/utils/postprocess-files.cjs # mcp bundle rm -rf dist-bundle imagekit_nodejs_api.mcpb; mkdir dist-bundle diff --git a/packages/mcp-server/cloudflare-worker/package.json b/packages/mcp-server/cloudflare-worker/package.json index 84c0823b..311b9a35 100644 --- a/packages/mcp-server/cloudflare-worker/package.json +++ b/packages/mcp-server/cloudflare-worker/package.json @@ -21,7 +21,7 @@ "@modelcontextprotocol/sdk": "^1.27.1", "agents": "^0.8.5", "hono": "^4.12.4", - "@imagekit/api-mcp": "latest", + "@imagekit/nodejs-mcp": "latest", "zod": "^3.24.4" } } diff --git a/packages/mcp-server/cloudflare-worker/src/index.ts b/packages/mcp-server/cloudflare-worker/src/index.ts index 18cc7802..59c12b47 100644 --- a/packages/mcp-server/cloudflare-worker/src/index.ts +++ b/packages/mcp-server/cloudflare-worker/src/index.ts @@ -1,7 +1,7 @@ import { makeOAuthConsent } from './app'; import { McpAgent } from 'agents/mcp'; import OAuthProvider from '@cloudflare/workers-oauth-provider'; -import { McpOptions, initMcpServer, server, ClientOptions } from '@imagekit/api-mcp/server'; +import { McpOptions, initMcpServer, server, ClientOptions } from '@imagekit/nodejs-mcp/server'; import type { ExportedHandler } from '@cloudflare/workers-types'; type MCPProps = { diff --git a/packages/mcp-server/jest.config.ts b/packages/mcp-server/jest.config.ts index c1a41722..6c2868f4 100644 --- a/packages/mcp-server/jest.config.ts +++ b/packages/mcp-server/jest.config.ts @@ -7,8 +7,8 @@ const config: JestConfigWithTsJest = { '^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }], }, moduleNameMapper: { - '^@imagekit/api-mcp$': '/src/index.ts', - '^@imagekit/api-mcp/(.*)$': '/src/$1', + '^@imagekit/nodejs-mcp$': '/src/index.ts', + '^@imagekit/nodejs-mcp/(.*)$': '/src/$1', }, modulePathIgnorePatterns: ['/dist/'], testPathIgnorePatterns: ['scripts'], diff --git a/packages/mcp-server/manifest.json b/packages/mcp-server/manifest.json index c9dbefa4..ca446e07 100644 --- a/packages/mcp-server/manifest.json +++ b/packages/mcp-server/manifest.json @@ -1,6 +1,6 @@ { "dxt_version": "0.2", - "name": "@imagekit/api-mcp", + "name": "@imagekit/nodejs-mcp", "version": "7.5.0", "description": "The official MCP Server for the Image Kit API", "author": { diff --git a/packages/mcp-server/package.json b/packages/mcp-server/package.json index d3b791d3..a9abcc04 100644 --- a/packages/mcp-server/package.json +++ b/packages/mcp-server/package.json @@ -1,5 +1,5 @@ { - "name": "@imagekit/api-mcp", + "name": "@imagekit/nodejs-mcp", "version": "7.5.0", "description": "The official MCP Server for the Image Kit API", "author": "Image Kit ", @@ -78,8 +78,8 @@ "tsconfig-paths": "^4.0.0" }, "imports": { - "@imagekit/api-mcp": ".", - "@imagekit/api-mcp/*": "./src/*" + "@imagekit/nodejs-mcp": ".", + "@imagekit/nodejs-mcp/*": "./src/*" }, "exports": { ".": { diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 4db1f540..8dee61ba 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -93,6 +93,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build();\n CustomMetadataField customMetadataField = client.customMetadataFields().create(params);\n }\n}', }, + kotlin: { + method: 'customMetadataFields().create', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: CustomMetadataFieldCreateParams = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build()\n val customMetadataField: CustomMetadataField = client.customMetadataFields().create(params)\n}', + }, php: { method: 'customMetadataFields->create', example: @@ -154,6 +159,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List customMetadataFields = client.customMetadataFields().list();\n }\n}', }, + kotlin: { + method: 'customMetadataFields().list', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataFields: List = client.customMetadataFields().list()\n}', + }, php: { method: 'customMetadataFields->list', example: @@ -218,6 +228,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataField customMetadataField = client.customMetadataFields().update("id");\n }\n}', }, + kotlin: { + method: 'customMetadataFields().update', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataField: CustomMetadataField = client.customMetadataFields().update("id")\n}', + }, php: { method: 'customMetadataFields->update', example: @@ -278,6 +293,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldDeleteResponse customMetadataField = client.customMetadataFields().delete("id");\n }\n}', }, + kotlin: { + method: 'customMetadataFields().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataField: CustomMetadataFieldDeleteResponse = client.customMetadataFields().delete("id")\n}', + }, php: { method: 'customMetadataFields->delete', example: @@ -363,6 +383,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.files().upload(params);\n }\n}', }, + kotlin: { + method: 'files().upload', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUploadParams = FileUploadParams.builder()\n .file("Example data".byteInputStream())\n .fileName("fileName")\n .build()\n val response: FileUploadResponse = client.files().upload(params)\n}', + }, php: { method: 'files->upload', example: @@ -424,6 +449,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.FileGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n File file = client.files().get("fileId");\n }\n}', }, + kotlin: { + method: 'files().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.FileGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val file: File = client.files().get("fileId")\n}', + }, php: { method: 'files->get', example: @@ -486,6 +516,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUpdateParams;\nimport com.imagekit.api.models.files.FileUpdateResponse;\nimport com.imagekit.api.models.files.UpdateFileRequest;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUpdateParams params = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build();\n FileUpdateResponse file = client.files().update(params);\n }\n}', }, + kotlin: { + method: 'files().update', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUpdateParams\nimport com.imagekit.api.models.files.FileUpdateResponse\nimport com.imagekit.api.models.files.UpdateFileRequest\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUpdateParams = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build()\n val file: FileUpdateResponse = client.files().update(params)\n}', + }, php: { method: 'files->update', example: @@ -545,6 +580,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.files().delete("fileId");\n }\n}', }, + kotlin: { + method: 'files().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.files().delete("fileId")\n}', + }, php: { method: 'files->delete', example: @@ -605,6 +645,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileCopyParams;\nimport com.imagekit.api.models.files.FileCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileCopyParams params = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileCopyResponse response = client.files().copy(params);\n }\n}', }, + kotlin: { + method: 'files().copy', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileCopyParams\nimport com.imagekit.api.models.files.FileCopyResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileCopyParams = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build()\n val response: FileCopyResponse = client.files().copy(params)\n}', + }, php: { method: 'files->copy', example: @@ -665,6 +710,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileMoveParams;\nimport com.imagekit.api.models.files.FileMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileMoveParams params = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileMoveResponse response = client.files().move(params);\n }\n}', }, + kotlin: { + method: 'files().move', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileMoveParams\nimport com.imagekit.api.models.files.FileMoveResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileMoveParams = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build()\n val response: FileMoveResponse = client.files().move(params)\n}', + }, php: { method: 'files->move', example: @@ -725,6 +775,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileRenameParams;\nimport com.imagekit.api.models.files.FileRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileRenameParams params = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build();\n FileRenameResponse response = client.files().rename(params);\n }\n}', }, + kotlin: { + method: 'files().rename', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileRenameParams\nimport com.imagekit.api.models.files.FileRenameResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileRenameParams = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build()\n val response: FileRenameResponse = client.files().rename(params)\n}', + }, php: { method: 'files->rename', example: @@ -785,6 +840,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkDeleteParams;\nimport com.imagekit.api.models.files.bulk.BulkDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkDeleteParams params = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkDeleteResponse bulk = client.files().bulk().delete(params);\n }\n}', }, + kotlin: { + method: 'files().bulk().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkDeleteParams\nimport com.imagekit.api.models.files.bulk.BulkDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkDeleteParams = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build()\n val bulk: BulkDeleteResponse = client.files().bulk().delete(params)\n}', + }, php: { method: 'files->bulk->delete', example: @@ -845,6 +905,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkAddTagsParams;\nimport com.imagekit.api.models.files.bulk.BulkAddTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkAddTagsParams params = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkAddTagsResponse response = client.files().bulk().addTags(params);\n }\n}', }, + kotlin: { + method: 'files().bulk().addTags', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkAddTagsParams\nimport com.imagekit.api.models.files.bulk.BulkAddTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkAddTagsParams = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(listOf(\n "t-shirt",\n "round-neck",\n "sale2019",\n ))\n .build()\n val response: BulkAddTagsResponse = client.files().bulk().addTags(params)\n}', + }, php: { method: 'files->bulk->addTags', example: @@ -905,6 +970,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsParams;\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveTagsParams params = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkRemoveTagsResponse response = client.files().bulk().removeTags(params);\n }\n}', }, + kotlin: { + method: 'files().bulk().removeTags', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsParams\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkRemoveTagsParams = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(listOf(\n "t-shirt",\n "round-neck",\n "sale2019",\n ))\n .build()\n val response: BulkRemoveTagsResponse = client.files().bulk().removeTags(params)\n}', + }, php: { method: 'files->bulk->removeTags', example: @@ -965,6 +1035,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams;\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveAiTagsParams params = BulkRemoveAiTagsParams.builder()\n .aiTags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkRemoveAiTagsResponse response = client.files().bulk().removeAiTags(params);\n }\n}', }, + kotlin: { + method: 'files().bulk().removeAiTags', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkRemoveAiTagsParams = BulkRemoveAiTagsParams.builder()\n .aiTags(listOf(\n "t-shirt",\n "round-neck",\n "sale2019",\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build()\n val response: BulkRemoveAiTagsResponse = client.files().bulk().removeAiTags(params)\n}', + }, php: { method: 'files->bulk->removeAITags', example: @@ -1025,6 +1100,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.versions.VersionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List files = client.files().versions().list("fileId");\n }\n}', }, + kotlin: { + method: 'files().versions().list', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val files: List = client.files().versions().list("fileId")\n}', + }, php: { method: 'files->versions->list', example: @@ -1085,6 +1165,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.versions.VersionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionGetParams params = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().get(params);\n }\n}', }, + kotlin: { + method: 'files().versions().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionGetParams = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build()\n val file: File = client.files().versions().get(params)\n}', + }, php: { method: 'files->versions->get', example: @@ -1145,6 +1230,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.versions.VersionDeleteParams;\nimport com.imagekit.api.models.files.versions.VersionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionDeleteParams params = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n VersionDeleteResponse version = client.files().versions().delete(params);\n }\n}', }, + kotlin: { + method: 'files().versions().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.versions.VersionDeleteParams\nimport com.imagekit.api.models.files.versions.VersionDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionDeleteParams = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build()\n val version: VersionDeleteResponse = client.files().versions().delete(params)\n}', + }, php: { method: 'files->versions->delete', example: @@ -1205,6 +1295,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.versions.VersionRestoreParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionRestoreParams params = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().restore(params);\n }\n}', }, + kotlin: { + method: 'files().versions().restore', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionRestoreParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionRestoreParams = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build()\n val file: File = client.files().versions().restore(params)\n}', + }, php: { method: 'files->versions->restore', example: @@ -1266,6 +1361,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.Metadata;\nimport com.imagekit.api.models.files.metadata.MetadataGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n Metadata metadata = client.files().metadata().get("fileId");\n }\n}', }, + kotlin: { + method: 'files().metadata().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.Metadata\nimport com.imagekit.api.models.files.metadata.MetadataGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val metadata: Metadata = client.files().metadata().get("fileId")\n}', + }, php: { method: 'files->metadata->get', example: @@ -1327,6 +1427,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.Metadata;\nimport com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n MetadataGetFromUrlParams params = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build();\n Metadata metadata = client.files().metadata().getFromUrl(params);\n }\n}', }, + kotlin: { + method: 'files().metadata().getFromUrl', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.Metadata\nimport com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: MetadataGetFromUrlParams = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build()\n val metadata: Metadata = client.files().metadata().getFromUrl(params)\n}', + }, php: { method: 'files->metadata->getFromURL', example: @@ -1387,6 +1492,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List savedExtensions = client.savedExtensions().list();\n }\n}', }, + kotlin: { + method: 'savedExtensions().list', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtensions: List = client.savedExtensions().list()\n}', + }, php: { method: 'savedExtensions->list', example: @@ -1452,6 +1562,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.ExtensionConfig;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtensionCreateParams params = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build();\n SavedExtension savedExtension = client.savedExtensions().create(params);\n }\n}', }, + kotlin: { + method: 'savedExtensions().create', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.ExtensionConfig\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionCreateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: SavedExtensionCreateParams = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build()\n val savedExtension: SavedExtension = client.savedExtensions().create(params)\n}', + }, php: { method: 'savedExtensions->create', example: @@ -1512,6 +1627,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().get("id");\n }\n}', }, + kotlin: { + method: 'savedExtensions().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtension: SavedExtension = client.savedExtensions().get("id")\n}', + }, php: { method: 'savedExtensions->get', example: @@ -1578,6 +1698,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().update("id");\n }\n}', }, + kotlin: { + method: 'savedExtensions().update', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtension: SavedExtension = client.savedExtensions().update("id")\n}', + }, php: { method: 'savedExtensions->update', example: @@ -1636,6 +1761,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.savedExtensions().delete("id");\n }\n}', }, + kotlin: { + method: 'savedExtensions().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.savedExtensions().delete("id")\n}', + }, php: { method: 'savedExtensions->delete', example: @@ -1704,6 +1834,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.assets.AssetListParams;\nimport com.imagekit.api.models.assets.AssetListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List assets = client.assets().list();\n }\n}', }, + kotlin: { + method: 'assets().list', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.assets.AssetListParams\nimport com.imagekit.api.models.assets.AssetListResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val assets: List = client.assets().list()\n}', + }, php: { method: 'assets->list', example: @@ -1764,6 +1899,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateParams;\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationCreateParams params = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build();\n InvalidationCreateResponse invalidation = client.cache().invalidation().create(params);\n }\n}', }, + kotlin: { + method: 'cache().invalidation().create', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateParams\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: InvalidationCreateParams = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build()\n val invalidation: InvalidationCreateResponse = client.cache().invalidation().create(params)\n}', + }, php: { method: 'cache->invalidation->create', example: @@ -1823,6 +1963,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetParams;\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationGetResponse invalidation = client.cache().invalidation().get("requestId");\n }\n}', }, + kotlin: { + method: 'cache().invalidation().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetParams\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val invalidation: InvalidationGetResponse = client.cache().invalidation().get("requestId")\n}', + }, php: { method: 'cache->invalidation->get', example: @@ -1883,6 +2028,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderCreateParams;\nimport com.imagekit.api.models.folders.FolderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCreateParams params = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build();\n FolderCreateResponse folder = client.folders().create(params);\n }\n}', }, + kotlin: { + method: 'folders().create', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderCreateParams\nimport com.imagekit.api.models.folders.FolderCreateResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderCreateParams = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build()\n val folder: FolderCreateResponse = client.folders().create(params)\n}', + }, php: { method: 'folders->create', example: @@ -1943,6 +2093,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderDeleteParams;\nimport com.imagekit.api.models.folders.FolderDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderDeleteParams params = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build();\n FolderDeleteResponse folder = client.folders().delete(params);\n }\n}', }, + kotlin: { + method: 'folders().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderDeleteParams\nimport com.imagekit.api.models.folders.FolderDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderDeleteParams = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build()\n val folder: FolderDeleteResponse = client.folders().delete(params)\n}', + }, php: { method: 'folders->delete', example: @@ -2003,6 +2158,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderCopyParams;\nimport com.imagekit.api.models.folders.FolderCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCopyParams params = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderCopyResponse response = client.folders().copy(params);\n }\n}', }, + kotlin: { + method: 'folders().copy', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderCopyParams\nimport com.imagekit.api.models.folders.FolderCopyResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderCopyParams = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build()\n val response: FolderCopyResponse = client.folders().copy(params)\n}', + }, php: { method: 'folders->copy', example: @@ -2063,6 +2223,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderMoveParams;\nimport com.imagekit.api.models.folders.FolderMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderMoveParams params = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderMoveResponse response = client.folders().move(params);\n }\n}', }, + kotlin: { + method: 'folders().move', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderMoveParams\nimport com.imagekit.api.models.folders.FolderMoveResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderMoveParams = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build()\n val response: FolderMoveResponse = client.folders().move(params)\n}', + }, php: { method: 'folders->move', example: @@ -2123,6 +2288,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderRenameParams;\nimport com.imagekit.api.models.folders.FolderRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderRenameParams params = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build();\n FolderRenameResponse response = client.folders().rename(params);\n }\n}', }, + kotlin: { + method: 'folders().rename', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderRenameParams\nimport com.imagekit.api.models.folders.FolderRenameResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderRenameParams = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build()\n val response: FolderRenameResponse = client.folders().rename(params)\n}', + }, php: { method: 'folders->rename', example: @@ -2183,6 +2353,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.job.JobGetParams;\nimport com.imagekit.api.models.folders.job.JobGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n JobGetResponse job = client.folders().job().get("jobId");\n }\n}', }, + kotlin: { + method: 'folders().job().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.job.JobGetParams\nimport com.imagekit.api.models.folders.job.JobGetResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val job: JobGetResponse = client.folders().job().get("jobId")\n}', + }, php: { method: 'folders->job->get', example: @@ -2244,6 +2419,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.usage.UsageGetParams;\nimport com.imagekit.api.models.accounts.usage.UsageGetResponse;\nimport java.time.LocalDate;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UsageGetParams params = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build();\n UsageGetResponse usage = client.accounts().usage().get(params);\n }\n}', }, + kotlin: { + method: 'accounts().usage().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.usage.UsageGetParams\nimport com.imagekit.api.models.accounts.usage.UsageGetResponse\nimport java.time.LocalDate\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UsageGetParams = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build()\n val usage: UsageGetResponse = client.accounts().usage().get(params)\n}', + }, php: { method: 'accounts->usage->get', example: @@ -2303,6 +2483,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginListParams;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List originResponses = client.accounts().origins().list();\n }\n}', }, + kotlin: { + method: 'accounts().origins().list', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginListParams\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val originResponses: List = client.accounts().origins().list()\n}', + }, php: { method: 'accounts->origins->list', example: @@ -2363,6 +2548,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginCreateParams;\nimport com.imagekit.api.models.accounts.origins.OriginRequest;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}', }, + kotlin: { + method: 'accounts().origins().create', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginCreateParams\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginRequest.S3 = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build()\n val originResponse: OriginResponse = client.accounts().origins().create(params)\n}', + }, php: { method: 'accounts->origins->create', example: @@ -2422,6 +2612,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginGetParams;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginResponse originResponse = client.accounts().origins().get("id");\n }\n}', }, + kotlin: { + method: 'accounts().origins().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginGetParams\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val originResponse: OriginResponse = client.accounts().origins().get("id")\n}', + }, php: { method: 'accounts->origins->get', example: @@ -2483,6 +2678,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginRequest;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\nimport com.imagekit.api.models.accounts.origins.OriginUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginUpdateParams params = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build();\n OriginResponse originResponse = client.accounts().origins().update(params);\n }\n}', }, + kotlin: { + method: 'accounts().origins().update', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\nimport com.imagekit.api.models.accounts.origins.OriginUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginUpdateParams = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build()\n val originResponse: OriginResponse = client.accounts().origins().update(params)\n}', + }, php: { method: 'accounts->origins->update', example: @@ -2542,6 +2742,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().origins().delete("id");\n }\n}', }, + kotlin: { + method: 'accounts().origins().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.accounts().origins().delete("id")\n}', + }, php: { method: 'accounts->origins->delete', example: @@ -2602,6 +2807,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List urlEndpointResponses = client.accounts().urlEndpoints().list();\n }\n}', }, + kotlin: { + method: 'accounts().urlEndpoints().list', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val urlEndpointResponses: List = client.accounts().urlEndpoints().list()\n}', + }, php: { method: 'accounts->urlEndpoints->list', example: @@ -2668,6 +2878,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}', }, + kotlin: { + method: 'accounts().urlEndpoints().create', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointRequest = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().create(params)\n}', + }, php: { method: 'accounts->urlEndpoints->create', example: @@ -2729,6 +2944,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get("id");\n }\n}', }, + kotlin: { + method: 'accounts().urlEndpoints().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().get("id")\n}', + }, php: { method: 'accounts->urlEndpoints->get', example: @@ -2796,6 +3016,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointUpdateParams params = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().update(params);\n }\n}', }, + kotlin: { + method: 'accounts().urlEndpoints().update', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointUpdateParams = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().update(params)\n}', + }, php: { method: 'accounts->urlEndpoints->update', example: @@ -2855,6 +3080,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().urlEndpoints().delete("id");\n }\n}', }, + kotlin: { + method: 'accounts().urlEndpoints().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.accounts().urlEndpoints().delete("id")\n}', + }, php: { method: 'accounts->urlEndpoints->delete', example: @@ -2937,6 +3167,11 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.beta.v2.files.FileUploadParams;\nimport com.imagekit.api.models.beta.v2.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.beta().v2().files().upload(params);\n }\n}', }, + kotlin: { + method: 'beta().v2().files().upload', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.beta.v2.files.FileUploadParams\nimport com.imagekit.api.models.beta.v2.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUploadParams = FileUploadParams.builder()\n .file("Example data".byteInputStream())\n .fileName("fileName")\n .build()\n val response: FileUploadResponse = client.beta().v2().files().upload(params)\n}', + }, php: { method: 'beta->v2->files->upload', example: @@ -2984,6 +3219,10 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.webhooks.WebhookUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unwrap();\n }\n}', }, + kotlin: { + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.webhooks.WebhookUnwrapParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.webhooks().unwrap()\n}', + }, php: { method: 'webhooks->unwrap', example: @@ -3032,6 +3271,10 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.webhooks.WebhookUnsafeUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unsafeUnwrap();\n }\n}', }, + kotlin: { + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.webhooks.WebhookUnsafeUnwrapParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.webhooks().unsafeUnwrap()\n}', + }, php: { method: 'webhooks->unsafeUnwrap', example: @@ -3060,12 +3303,12 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'python', content: - '# Image Kit Python API library\n\n\n[![PyPI version](https://img.shields.io/pypi/v/imagekitio.svg?label=pypi%20(stable))](https://pypi.org/project/imagekitio/)\n\nThe Image Kit Python library provides convenient access to the Image Kit REST API from any Python 3.9+\napplication. The library includes type definitions for all request params and response fields,\nand offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n## Installation\n\n```sh\n# install from PyPI\npip install imagekitio\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nresponse = client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.video_codec)\n```\n\nWhile you can provide a `private_key` keyword argument,\nwe recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nto add `IMAGEKIT_PRIVATE_KEY="My Private Key"` to your `.env` file\nso that your Private Key is not stored in source control.\n\n## Async usage\n\nSimply import `AsyncImageKit` instead of `ImageKit` and use `await` with each API call:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import AsyncImageKit\n\nclient = AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nasync def main() -> None:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n### With aiohttp\n\nBy default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.\n\nYou can enable this by installing `aiohttp`:\n\n```sh\n# install from PyPI\npip install imagekitio[aiohttp]\n```\n\nThen you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import DefaultAioHttpClient\nfrom imagekitio import AsyncImageKit\n\nasync def main() -> None:\n async with AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n http_client=DefaultAioHttpClient(),\n) as client:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\n\n\n## Using types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:\n\n- Serializing back into JSON, `model.to_json()`\n- Converting to a dictionary, `model.to_dict()`\n\nTyped requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.\n\n\n\n## Nested params\n\nNested parameters are dictionaries, typed using `TypedDict`, for example:\n\n```python\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nresponse = client.files.upload(\n file=b"Example data",\n file_name="fileName",\n transformation={\n "post": [{\n "type": "thumbnail",\n "value": "w-150,h-150",\n }, {\n "protocol": "dash",\n "type": "abs",\n "value": "sr-240_360_480_720_1080",\n }]\n },\n)\nprint(response.transformation)\n```\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.\n\n```python\nfrom pathlib import Path\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nclient.files.upload(\n file=Path("/path/to/file"),\n file_name="fileName",\n)\n```\n\nThe async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.\n\n## Handling errors\n\nWhen the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `imagekitio.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (that is, 4xx or 5xx\nresponse), a subclass of `imagekitio.APIStatusError` is raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `imagekitio.APIError`.\n\n```python\nimport imagekitio\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\ntry:\n client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\nexcept imagekitio.APIConnectionError as e:\n print("The server could not be reached")\n print(e.__cause__) # an underlying Exception, likely raised within httpx.\nexcept imagekitio.RateLimitError as e:\n print("A 429 status code was received; we should back off a bit.")\nexcept imagekitio.APIStatusError as e:\n print("Another non-200-range status code was received")\n print(e.status_code)\n print(e.response)\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors are automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors are all retried by default.\n\nYou can use the `max_retries` option to configure or disable retry settings:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # default is 2\n max_retries=0,\n)\n\n# Or, configure per-request:\nclient.with_options(max_retries = 5).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\n### Timeouts\n\nBy default requests time out after 1 minute. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # 20 seconds (default is 1 minute)\n timeout=20.0,\n)\n\n# More granular control:\nclient = ImageKit(\n timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n)\n\n# Override per-request:\nclient.with_options(timeout = 5.0).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests that time out are [retried twice by default](#retries).\n\n\n\n## Advanced\n\n### Logging\n\nWe use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.\n\nYou can enable logging by setting the environment variable `IMAGE_KIT_LOG` to `info`.\n\n```shell\n$ export IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging.\n\n### How to tell whether `None` means `null` or missing\n\nIn an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:\n\n```py\nif response.my_field is None:\n if \'my_field\' not in response.model_fields_set:\n print(\'Got json like {}, without a "my_field" key present at all.\')\n else:\n print(\'Got json like {"my_field": null}.\')\n```\n\n### Accessing raw response data (e.g. headers)\n\nThe "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,\n\n```py\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\nresponse = client.files.with_raw_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.headers.get(\'X-My-Header\'))\n\nfile = response.parse() # get the object that `files.upload()` would have returned\nprint(file.video_codec)\n```\n\nThese methods return an [`APIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) object.\n\nThe async client returns an [`AsyncAPIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.\n\n#### `.with_streaming_response`\n\nThe above interface eagerly reads the full response body when you make the request, which may not always be what you want.\n\nTo stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.\n\n```python\nwith client.files.with_streaming_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n) as response :\n print(response.headers.get(\'X-My-Header\'))\n\n for line in response.iter_lines():\n print(line)\n```\n\nThe context manager is required so that the response will reliably be closed.\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API.\n\nIf you need to access undocumented endpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other\nhttp verbs. Options on the client will be respected (such as retries) when making this request.\n\n```py\nimport httpx\n\nresponse = client.post(\n "/foo",\n cast_to=httpx.Response,\n body={"my_param": True},\n)\n\nprint(response.headers.get("x-foo"))\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You\ncan also get all the extra fields on the Pydantic model as a dict with\n[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).\n\n### Configuring the HTTP client\n\nYou can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:\n\n- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)\n- Custom [transports](https://www.python-httpx.org/advanced/transports/)\n- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality\n\n```python\nimport httpx\nfrom imagekitio import ImageKit, DefaultHttpxClient\n\nclient = ImageKit(\n # Or use the `IMAGE_KIT_BASE_URL` env var\n base_url="http://my.test.server.example.com:8083",\n http_client=DefaultHttpxClient(proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),\n)\n```\n\nYou can also customize the client on a per-request basis by using `with_options()`:\n\n```python\nclient.with_options(http_client=DefaultHttpxClient(...))\n```\n\n### Managing HTTP resources\n\nBy default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.\n\n```py\nfrom imagekitio import ImageKit\n\nwith ImageKit() as client:\n # make requests here\n ...\n\n# HTTP client is now closed\n```\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you\'ve upgraded to the latest version but aren\'t seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport imagekitio\nprint(imagekitio.__version__)\n```\n\n## Requirements\n\nPython 3.9 or higher.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', + '# Image Kit Python API library\n\n\n[![PyPI version](https://img.shields.io/pypi/v/imagekitio.svg?label=pypi%20(stable))](https://pypi.org/project/imagekitio/)\n\nThe Image Kit Python library provides convenient access to the Image Kit REST API from any Python 3.9+\napplication. The library includes type definitions for all request params and response fields,\nand offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n## Installation\n\n```sh\n# install from PyPI\npip install imagekitio\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nresponse = client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.video_codec)\n```\n\nWhile you can provide a `private_key` keyword argument,\nwe recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nto add `IMAGEKIT_PRIVATE_KEY="My Private Key"` to your `.env` file\nso that your Private Key is not stored in source control.\n\n## Async usage\n\nSimply import `AsyncImageKit` instead of `ImageKit` and use `await` with each API call:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import AsyncImageKit\n\nclient = AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nasync def main() -> None:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n### With aiohttp\n\nBy default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.\n\nYou can enable this by installing `aiohttp`:\n\n```sh\n# install from PyPI\npip install imagekitio[aiohttp]\n```\n\nThen you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import DefaultAioHttpClient\nfrom imagekitio import AsyncImageKit\n\nasync def main() -> None:\n async with AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n http_client=DefaultAioHttpClient(),\n) as client:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\n\n\n## Using types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:\n\n- Serializing back into JSON, `model.to_json()`\n- Converting to a dictionary, `model.to_dict()`\n\nTyped requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.\n\n\n\n## Nested params\n\nNested parameters are dictionaries, typed using `TypedDict`, for example:\n\n```python\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nresponse = client.files.upload(\n file=b"Example data",\n file_name="fileName",\n transformation={\n "post": [{\n "type": "thumbnail",\n "value": "w-150,h-150",\n }, {\n "protocol": "dash",\n "type": "abs",\n "value": "sr-240_360_480_720_1080",\n }]\n },\n)\nprint(response.transformation)\n```\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.\n\n```python\nfrom pathlib import Path\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nclient.files.upload(\n file=Path("/path/to/file"),\n file_name="fileName",\n)\n```\n\nThe async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.\n\n## Handling errors\n\nWhen the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `imagekitio.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (that is, 4xx or 5xx\nresponse), a subclass of `imagekitio.APIStatusError` is raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `imagekitio.APIError`.\n\n```python\nimport imagekitio\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\ntry:\n client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\nexcept imagekitio.APIConnectionError as e:\n print("The server could not be reached")\n print(e.__cause__) # an underlying Exception, likely raised within httpx.\nexcept imagekitio.RateLimitError as e:\n print("A 429 status code was received; we should back off a bit.")\nexcept imagekitio.APIStatusError as e:\n print("Another non-200-range status code was received")\n print(e.status_code)\n print(e.response)\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors are automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors are all retried by default.\n\nYou can use the `max_retries` option to configure or disable retry settings:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # default is 2\n max_retries=0,\n)\n\n# Or, configure per-request:\nclient.with_options(max_retries = 5).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\n### Timeouts\n\nBy default requests time out after 1 minute. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # 20 seconds (default is 1 minute)\n timeout=20.0,\n)\n\n# More granular control:\nclient = ImageKit(\n timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n)\n\n# Override per-request:\nclient.with_options(timeout = 5.0).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests that time out are [retried twice by default](#retries).\n\n\n\n## Advanced\n\n### Logging\n\nWe use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.\n\nYou can enable logging by setting the environment variable `IMAGE_KIT_LOG` to `info`.\n\n```shell\n$ export IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging.\n\n### How to tell whether `None` means `null` or missing\n\nIn an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:\n\n```py\nif response.my_field is None:\n if \'my_field\' not in response.model_fields_set:\n print(\'Got json like {}, without a "my_field" key present at all.\')\n else:\n print(\'Got json like {"my_field": null}.\')\n```\n\n### Accessing raw response data (e.g. headers)\n\nThe "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,\n\n```py\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\nresponse = client.files.with_raw_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.headers.get(\'X-My-Header\'))\n\nfile = response.parse() # get the object that `files.upload()` would have returned\nprint(file.video_codec)\n```\n\nThese methods return an [`APIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) object.\n\nThe async client returns an [`AsyncAPIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.\n\n#### `.with_streaming_response`\n\nThe above interface eagerly reads the full response body when you make the request, which may not always be what you want.\n\nTo stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.\n\n```python\nwith client.files.with_streaming_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n) as response :\n print(response.headers.get(\'X-My-Header\'))\n\n for line in response.iter_lines():\n print(line)\n```\n\nThe context manager is required so that the response will reliably be closed.\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API.\n\nIf you need to access undocumented endpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other\nhttp verbs. Options on the client will be respected (such as retries) when making this request.\n\n```py\nimport httpx\n\nresponse = client.post(\n "/foo",\n cast_to=httpx.Response,\n body={"my_param": True},\n)\n\nprint(response.headers.get("x-foo"))\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You\ncan also get all the extra fields on the Pydantic model as a dict with\n[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).\n\n### Configuring the HTTP client\n\nYou can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:\n\n- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)\n- Custom [transports](https://www.python-httpx.org/advanced/transports/)\n- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality\n\n```python\nimport httpx\nfrom imagekitio import ImageKit, DefaultHttpxClient\n\nclient = ImageKit(\n # Or use the `IMAGE_KIT_BASE_URL` env var\n base_url="http://my.test.server.example.com:8083",\n http_client=DefaultHttpxClient(proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),\n)\n```\n\nYou can also customize the client on a per-request basis by using `with_options()`:\n\n```python\nclient.with_options(http_client=DefaultHttpxClient(...))\n```\n\n### Managing HTTP resources\n\nBy default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.\n\n```py\nfrom imagekitio import ImageKit\n\nwith ImageKit() as client:\n # make requests here\n ...\n\n# HTTP client is now closed\n```\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you\'ve upgraded to the latest version but aren\'t seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport imagekitio\nprint(imagekitio.__version__)\n```\n\n## Requirements\n\nPython 3.9 or higher.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', }, { language: 'go', content: - '# Image Kit Go API Library\n\nGo Reference\n\nThe Image Kit Go library provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference)\nfrom applications written in Go.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n\n\n```go\nimport (\n\t"github.com/imagekit-developer/imagekit-go" // imported as SDK_PackageName\n)\n```\n\n\n\nOr to pin the version:\n\n\n\n```sh\ngo get -u \'github.com/imagekit-developer/imagekit-go@v0.0.1\'\n```\n\n\n\n## Requirements\n\nThis library requires Go 1.22+.\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```go\npackage main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"), // defaults to os.LookupEnv("IMAGEKIT_PRIVATE_KEY")\n\t\toption.WithPassword("My Password"), // defaults to os.LookupEnv("OPTIONAL_IMAGEKIT_IGNORES_THIS")\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n\n```\n\n### Request fields\n\nAll request parameters are wrapped in a generic `Field` type,\nwhich we use to distinguish zero values from null or omitted fields.\n\nThis prevents accidentally sending a zero value if you forget a required parameter,\nand enables explicitly sending `null`, `false`, `\'\'`, or `0` on optional parameters.\nAny field not specified is not sent.\n\nTo construct fields with values, use the helpers `String()`, `Int()`, `Float()`, or most commonly, the generic `F[T]()`.\nTo send a null, use `Null[T]()`, and to send a nonconforming value, use `Raw[T](any)`. For example:\n\n```go\nparams := FooParams{\n\tName: SDK_PackageName.F("hello"),\n\n\t// Explicitly send `"description": null`\n\tDescription: SDK_PackageName.Null[string](),\n\n\tPoint: SDK_PackageName.F(SDK_PackageName.Point{\n\t\tX: SDK_PackageName.Int(0),\n\t\tY: SDK_PackageName.Int(1),\n\n\t\t// In cases where the API specifies a given type,\n\t\t// but you want to send something else, use `Raw`:\n\t\tZ: SDK_PackageName.Raw[int64](0.01), // sends a float\n\t}),\n}\n```\n\n### Response objects\n\nAll fields in response structs are value types (not pointers or wrappers).\n\nIf a given field is `null`, not present, or invalid, the corresponding field\nwill simply be its zero value.\n\nAll response structs also include a special `JSON` field, containing more detailed\ninformation about each property, which you can use like so:\n\n```go\nif res.Name == "" {\n\t// true if `"name"` is either not present or explicitly null\n\tres.JSON.Name.IsNull()\n\n\t// true if the `"name"` key was not present in the response JSON at all\n\tres.JSON.Name.IsMissing()\n\n\t// When the API returns data that cannot be coerced to the expected type:\n\tif res.JSON.Name.IsInvalid() {\n\t\traw := res.JSON.Name.Raw()\n\n\t\tlegacyName := struct{\n\t\t\tFirst string `json:"first"`\n\t\t\tLast string `json:"last"`\n\t\t}{}\n\t\tjson.Unmarshal([]byte(raw), &legacyName)\n\t\tname = legacyName.First + " " + legacyName.Last\n\t}\n}\n```\n\nThese `.JSON` structs also include an `Extras` map containing\nany properties in the json response that were not specified\nin the struct. This can be useful for API features not yet\npresent in the SDK.\n\n```go\nbody := res.JSON.ExtraFields["my_unexpected_field"].Raw()\n```\n\n### RequestOptions\n\nThis library uses the functional options pattern. Functions defined in the\n`SDK_PackageOptionName` package return a `RequestOption`, which is a closure that mutates a\n`RequestConfig`. These options can be supplied to the client or at individual\nrequests. For example:\n\n```go\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\t// Adds a header to every request made by the client\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "custom_header_info"),\n)\n\nclient.Files.Upload(context.TODO(), ...,\n\t// Override the header\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "some_other_custom_header_info"),\n\t// Add an undocumented field to the request body, using sjson syntax\n\tSDK_PackageOptionName.WithJSONSet("some.json.path", map[string]string{"my": "object"}),\n)\n```\n\nSee the [full list of request options](https://pkg.go.dev/github.com/imagekit-developer/imagekit-go/SDK_PackageOptionName).\n\n### Pagination\n\nThis library provides some conveniences for working with paginated list endpoints.\n\nYou can use `.ListAutoPaging()` methods to iterate through items across all pages:\n\n\n\nOr you can use simple `.List()` methods to fetch a single page and receive a standard response object\nwith additional helper methods like `.GetNextPage()`, e.g.:\n\n\n\n### Errors\n\nWhen the API returns a non-success status code, we return an error with type\n`*SDK_PackageName.Error`. This contains the `StatusCode`, `*http.Request`, and\n`*http.Response` values of the request, as well as the JSON of the error body\n(much like other response objects in the SDK).\n\nTo handle errors, we recommend that you use the `errors.As` pattern:\n\n```go\n_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\tFileName: "file-name.jpg",\n})\nif err != nil {\n\tvar apierr *imagekit.Error\n\tif errors.As(err, &apierr) {\n\t\tprintln(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request\n\t\tprintln(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response\n\t}\n\tpanic(err.Error()) // GET "/api/v1/files/upload": 400 Bad Request { ... }\n}\n```\n\nWhen other errors occur, they are returned unwrapped; for example,\nif HTTP transport fails, you might receive `*url.Error` wrapping `*net.OpError`.\n\n### Timeouts\n\nRequests do not time out by default; use context to configure a timeout for a request lifecycle.\n\nNote that if a request is [retried](#retries), the context timeout does not start over.\nTo set a per-retry timeout, use `SDK_PackageOptionName.WithRequestTimeout()`.\n\n```go\n// This sets the timeout for the request, including all the retries.\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\nclient.Files.Upload(\n\tctx,\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\t// This sets the per-retry timeout\n\toption.WithRequestTimeout(20*time.Second),\n)\n```\n\n### File uploads\n\nRequest parameters that correspond to file uploads in multipart requests are typed as\n`param.Field[io.Reader]`. The contents of the `io.Reader` will by default be sent as a multipart form\npart with the file name of "anonymous_file" and content-type of "application/octet-stream".\n\nThe file name and content-type can be customized by implementing `Name() string` or `ContentType()\nstring` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a\nfile returned by `os.Open` will be sent with the file name on disk.\n\nWe also provide a helper `SDK_PackageName.FileParam(reader io.Reader, filename string, contentType string)`\nwhich can be used to wrap any `io.Reader` with the appropriate file name and content type.\n\n```go\n// A file from the file system\nfile, err := os.Open("/path/to/file")\nimagekit.FileUploadParams{\n\tFile: file,\n\tFileName: "fileName",\n}\n\n// A file from a string\nimagekit.FileUploadParams{\n\tFile: strings.NewReader("my file contents"),\n\tFileName: "fileName",\n}\n\n// With a custom filename and contentType\nimagekit.FileUploadParams{\n\tFile: imagekit.NewFile(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"),\n\tFileName: "fileName",\n}\n```\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nWe retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit,\nand >=500 Internal errors.\n\nYou can use the `WithMaxRetries` option to configure or disable this:\n\n```go\n// Configure the default for all requests:\nclient := imagekit.NewClient(\n\toption.WithMaxRetries(0), // default is 2\n)\n\n// Override per-request:\nclient.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithMaxRetries(5),\n)\n```\n\n\n### Accessing raw response data (e.g. response headers)\n\nYou can access the raw HTTP response data by using the `option.WithResponseInto()` request option. This is useful when\nyou need to examine response headers, status codes, or other details.\n\n```go\n// Create a variable to store the HTTP response\nvar response *http.Response\nresponse, err := client.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithResponseInto(&response),\n)\nif err != nil {\n\t// handle error\n}\nfmt.Printf("%+v\\n", response)\n\nfmt.Printf("Status Code: %d\\n", response.StatusCode)\nfmt.Printf("Headers: %+#v\\n", response.Header)\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.Get`, `client.Post`, and other HTTP verbs.\n`RequestOptions` on the client, such as retries, will be respected when making these requests.\n\n```go\nvar (\n // params can be an io.Reader, a []byte, an encoding/json serializable object,\n // or a "…Params" struct defined in this library.\n params map[string]interface{}\n\n // result can be an []byte, *http.Response, a encoding/json deserializable object,\n // or a model defined in this library.\n result *http.Response\n)\nerr := client.Post(context.Background(), "/unspecified", params, &result)\nif err != nil {\n …\n}\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use either the `SDK_PackageOptionName.WithQuerySet()`\nor the `SDK_PackageOptionName.WithJSONSet()` methods.\n\n```go\nparams := FooNewParams{\n ID: SDK_PackageName.F("id_xxxx"),\n Data: SDK_PackageName.F(FooNewParamsData{\n FirstName: SDK_PackageName.F("John"),\n }),\n}\nclient.Foo.New(context.Background(), params, SDK_PackageOptionName.WithJSONSet("data.last_name", "Doe"))\n```\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may either access the raw JSON of the response as a string\nwith `result.JSON.RawJSON()`, or get the raw JSON of a particular field on the result with\n`result.JSON.Foo.Raw()`.\n\nAny fields that are not present on the response struct will be saved and can be accessed by `result.JSON.ExtraFields()` which returns the extra fields as a `map[string]Field`.\n\n### Middleware\n\nWe provide `SDK_PackageOptionName.WithMiddleware` which applies the given\nmiddleware to requests.\n\n```go\nfunc Logger(req *http.Request, next SDK_PackageOptionName.MiddlewareNext) (res *http.Response, err error) {\n\t// Before the request\n\tstart := time.Now()\n\tLogReq(req)\n\n\t// Forward the request to the next handler\n\tres, err = next(req)\n\n\t// Handle stuff after the request\n\tend := time.Now()\n\tLogRes(res, err, start - end)\n\n return res, err\n}\n\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\tSDK_PackageOptionName.WithMiddleware(Logger),\n)\n```\n\nWhen multiple middlewares are provided as variadic arguments, the middlewares\nare applied left to right. If `SDK_PackageOptionName.WithMiddleware` is given\nmultiple times, for example first in the client then the method, the\nmiddleware in the client will run first and the middleware given in the method\nwill run next.\n\nYou may also replace the default `http.Client` with\n`SDK_PackageOptionName.WithHTTPClient(client)`. Only one http client is\naccepted (this overwrites any previous client) and receives requests after any\nmiddleware has been applied.\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-go/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', + '# Image Kit Go API Library\n\nGo Reference\n\nThe Image Kit Go library provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference)\nfrom applications written in Go.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n\n\n```go\nimport (\n\t"github.com/imagekit-developer/imagekit-go" // imported as SDK_PackageName\n)\n```\n\n\n\nOr to pin the version:\n\n\n\n```sh\ngo get -u \'github.com/imagekit-developer/imagekit-go@v0.0.1\'\n```\n\n\n\n## Requirements\n\nThis library requires Go 1.22+.\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```go\npackage main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"), // defaults to os.LookupEnv("IMAGEKIT_PRIVATE_KEY")\n\t\toption.WithPassword("My Password"), // defaults to os.LookupEnv("OPTIONAL_IMAGEKIT_IGNORES_THIS")\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n\n```\n\n### Request fields\n\nAll request parameters are wrapped in a generic `Field` type,\nwhich we use to distinguish zero values from null or omitted fields.\n\nThis prevents accidentally sending a zero value if you forget a required parameter,\nand enables explicitly sending `null`, `false`, `\'\'`, or `0` on optional parameters.\nAny field not specified is not sent.\n\nTo construct fields with values, use the helpers `String()`, `Int()`, `Float()`, or most commonly, the generic `F[T]()`.\nTo send a null, use `Null[T]()`, and to send a nonconforming value, use `Raw[T](any)`. For example:\n\n```go\nparams := FooParams{\n\tName: SDK_PackageName.F("hello"),\n\n\t// Explicitly send `"description": null`\n\tDescription: SDK_PackageName.Null[string](),\n\n\tPoint: SDK_PackageName.F(SDK_PackageName.Point{\n\t\tX: SDK_PackageName.Int(0),\n\t\tY: SDK_PackageName.Int(1),\n\n\t\t// In cases where the API specifies a given type,\n\t\t// but you want to send something else, use `Raw`:\n\t\tZ: SDK_PackageName.Raw[int64](0.01), // sends a float\n\t}),\n}\n```\n\n### Response objects\n\nAll fields in response structs are value types (not pointers or wrappers).\n\nIf a given field is `null`, not present, or invalid, the corresponding field\nwill simply be its zero value.\n\nAll response structs also include a special `JSON` field, containing more detailed\ninformation about each property, which you can use like so:\n\n```go\nif res.Name == "" {\n\t// true if `"name"` is either not present or explicitly null\n\tres.JSON.Name.IsNull()\n\n\t// true if the `"name"` key was not present in the response JSON at all\n\tres.JSON.Name.IsMissing()\n\n\t// When the API returns data that cannot be coerced to the expected type:\n\tif res.JSON.Name.IsInvalid() {\n\t\traw := res.JSON.Name.Raw()\n\n\t\tlegacyName := struct{\n\t\t\tFirst string `json:"first"`\n\t\t\tLast string `json:"last"`\n\t\t}{}\n\t\tjson.Unmarshal([]byte(raw), &legacyName)\n\t\tname = legacyName.First + " " + legacyName.Last\n\t}\n}\n```\n\nThese `.JSON` structs also include an `Extras` map containing\nany properties in the json response that were not specified\nin the struct. This can be useful for API features not yet\npresent in the SDK.\n\n```go\nbody := res.JSON.ExtraFields["my_unexpected_field"].Raw()\n```\n\n### RequestOptions\n\nThis library uses the functional options pattern. Functions defined in the\n`SDK_PackageOptionName` package return a `RequestOption`, which is a closure that mutates a\n`RequestConfig`. These options can be supplied to the client or at individual\nrequests. For example:\n\n```go\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\t// Adds a header to every request made by the client\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "custom_header_info"),\n)\n\nclient.Files.Upload(context.TODO(), ...,\n\t// Override the header\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "some_other_custom_header_info"),\n\t// Add an undocumented field to the request body, using sjson syntax\n\tSDK_PackageOptionName.WithJSONSet("some.json.path", map[string]string{"my": "object"}),\n)\n```\n\nSee the [full list of request options](https://pkg.go.dev/github.com/imagekit-developer/imagekit-go/SDK_PackageOptionName).\n\n### Pagination\n\nThis library provides some conveniences for working with paginated list endpoints.\n\nYou can use `.ListAutoPaging()` methods to iterate through items across all pages:\n\n\n\nOr you can use simple `.List()` methods to fetch a single page and receive a standard response object\nwith additional helper methods like `.GetNextPage()`, e.g.:\n\n\n\n### Errors\n\nWhen the API returns a non-success status code, we return an error with type\n`*SDK_PackageName.Error`. This contains the `StatusCode`, `*http.Request`, and\n`*http.Response` values of the request, as well as the JSON of the error body\n(much like other response objects in the SDK).\n\nTo handle errors, we recommend that you use the `errors.As` pattern:\n\n```go\n_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\tFileName: "file-name.jpg",\n})\nif err != nil {\n\tvar apierr *imagekit.Error\n\tif errors.As(err, &apierr) {\n\t\tprintln(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request\n\t\tprintln(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response\n\t}\n\tpanic(err.Error()) // GET "/api/v1/files/upload": 400 Bad Request { ... }\n}\n```\n\nWhen other errors occur, they are returned unwrapped; for example,\nif HTTP transport fails, you might receive `*url.Error` wrapping `*net.OpError`.\n\n### Timeouts\n\nRequests do not time out by default; use context to configure a timeout for a request lifecycle.\n\nNote that if a request is [retried](#retries), the context timeout does not start over.\nTo set a per-retry timeout, use `SDK_PackageOptionName.WithRequestTimeout()`.\n\n```go\n// This sets the timeout for the request, including all the retries.\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\nclient.Files.Upload(\n\tctx,\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\t// This sets the per-retry timeout\n\toption.WithRequestTimeout(20*time.Second),\n)\n```\n\n### File uploads\n\nRequest parameters that correspond to file uploads in multipart requests are typed as\n`param.Field[io.Reader]`. The contents of the `io.Reader` will by default be sent as a multipart form\npart with the file name of "anonymous_file" and content-type of "application/octet-stream".\n\nThe file name and content-type can be customized by implementing `Name() string` or `ContentType()\nstring` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a\nfile returned by `os.Open` will be sent with the file name on disk.\n\nWe also provide a helper `SDK_PackageName.FileParam(reader io.Reader, filename string, contentType string)`\nwhich can be used to wrap any `io.Reader` with the appropriate file name and content type.\n\n```go\n// A file from the file system\nfile, err := os.Open("/path/to/file")\nimagekit.FileUploadParams{\n\tFile: file,\n\tFileName: "fileName",\n}\n\n// A file from a string\nimagekit.FileUploadParams{\n\tFile: strings.NewReader("my file contents"),\n\tFileName: "fileName",\n}\n\n// With a custom filename and contentType\nimagekit.FileUploadParams{\n\tFile: imagekit.NewFile(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"),\n\tFileName: "fileName",\n}\n```\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nWe retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit,\nand >=500 Internal errors.\n\nYou can use the `WithMaxRetries` option to configure or disable this:\n\n```go\n// Configure the default for all requests:\nclient := imagekit.NewClient(\n\toption.WithMaxRetries(0), // default is 2\n)\n\n// Override per-request:\nclient.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithMaxRetries(5),\n)\n```\n\n\n### Accessing raw response data (e.g. response headers)\n\nYou can access the raw HTTP response data by using the `option.WithResponseInto()` request option. This is useful when\nyou need to examine response headers, status codes, or other details.\n\n```go\n// Create a variable to store the HTTP response\nvar response *http.Response\nresponse, err := client.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithResponseInto(&response),\n)\nif err != nil {\n\t// handle error\n}\nfmt.Printf("%+v\\n", response)\n\nfmt.Printf("Status Code: %d\\n", response.StatusCode)\nfmt.Printf("Headers: %+#v\\n", response.Header)\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.Get`, `client.Post`, and other HTTP verbs.\n`RequestOptions` on the client, such as retries, will be respected when making these requests.\n\n```go\nvar (\n // params can be an io.Reader, a []byte, an encoding/json serializable object,\n // or a "…Params" struct defined in this library.\n params map[string]interface{}\n\n // result can be an []byte, *http.Response, a encoding/json deserializable object,\n // or a model defined in this library.\n result *http.Response\n)\nerr := client.Post(context.Background(), "/unspecified", params, &result)\nif err != nil {\n …\n}\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use either the `SDK_PackageOptionName.WithQuerySet()`\nor the `SDK_PackageOptionName.WithJSONSet()` methods.\n\n```go\nparams := FooNewParams{\n ID: SDK_PackageName.F("id_xxxx"),\n Data: SDK_PackageName.F(FooNewParamsData{\n FirstName: SDK_PackageName.F("John"),\n }),\n}\nclient.Foo.New(context.Background(), params, SDK_PackageOptionName.WithJSONSet("data.last_name", "Doe"))\n```\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may either access the raw JSON of the response as a string\nwith `result.JSON.RawJSON()`, or get the raw JSON of a particular field on the result with\n`result.JSON.Foo.Raw()`.\n\nAny fields that are not present on the response struct will be saved and can be accessed by `result.JSON.ExtraFields()` which returns the extra fields as a `map[string]Field`.\n\n### Middleware\n\nWe provide `SDK_PackageOptionName.WithMiddleware` which applies the given\nmiddleware to requests.\n\n```go\nfunc Logger(req *http.Request, next SDK_PackageOptionName.MiddlewareNext) (res *http.Response, err error) {\n\t// Before the request\n\tstart := time.Now()\n\tLogReq(req)\n\n\t// Forward the request to the next handler\n\tres, err = next(req)\n\n\t// Handle stuff after the request\n\tend := time.Now()\n\tLogRes(res, err, start - end)\n\n return res, err\n}\n\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\tSDK_PackageOptionName.WithMiddleware(Logger),\n)\n```\n\nWhen multiple middlewares are provided as variadic arguments, the middlewares\nare applied left to right. If `SDK_PackageOptionName.WithMiddleware` is given\nmultiple times, for example first in the client then the method, the\nmiddleware in the client will run first and the middleware given in the method\nwill run next.\n\nYou may also replace the default `http.Client` with\n`SDK_PackageOptionName.WithHTTPClient(client)`. Only one http client is\naccepted (this overwrites any previous client) and receives requests after any\nmiddleware has been applied.\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-go/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', }, { language: 'terraform', @@ -3075,17 +3318,22 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'typescript', content: - "# Image Kit TypeScript API Library\n\n[![NPM version](https://img.shields.io/npm/v/@imagekit/nodejs.svg?label=npm%20(stable))](https://npmjs.org/package/@imagekit/nodejs) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@imagekit/nodejs)\n\nThis library provides convenient access to the Image Kit REST API from server-side TypeScript or JavaScript.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n```sh\nnpm install @imagekit/nodejs\n```\n\n\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n\n```js\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n});\n\nconsole.log(response.videoCodec);\n```\n\n\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst params: ImageKit.FileUploadParams = {\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n};\nconst response: ImageKit.FileUploadResponse = await client.files.upload(params);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed in many different forms:\n- `File` (or an object with the same structure)\n- a `fetch` `Response` (or an object with the same structure)\n- an `fs.ReadStream`\n- the return value of our `toFile` helper\n\n```ts\nimport fs from 'fs';\nimport ImageKit, { toFile } from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\n// If you have access to Node `fs` we recommend using `fs.createReadStream()`:\nawait client.files.upload({ file: fs.createReadStream('/path/to/file'), fileName: 'fileName' });\n\n// Or if you have the web `File` API you can pass a `File` instance:\nawait client.files.upload({ file: new File(['my bytes'], 'file'), fileName: 'fileName' });\n\n// You can also pass a `fetch` `Response`:\nawait client.files.upload({ file: await fetch('https://somesite/file'), fileName: 'fileName' });\n\n// Finally, if none of the above are convenient, you can use our `toFile` helper:\nawait client.files.upload({\n file: await toFile(Buffer.from('my bytes'), 'file'),\n fileName: 'fileName',\n});\nawait client.files.upload({\n file: await toFile(new Uint8Array([0, 1, 2]), 'file'),\n fileName: 'fileName',\n});\n```\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n\n```ts\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .catch(async (err) => {\n if (err instanceof ImageKit.APIError) {\n console.log(err.status); // 400\n console.log(err.name); // BadRequestError\n console.log(err.headers); // {server: 'nginx', ...}\n } else {\n throw err;\n }\n });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n\n```js\n// Configure the default for all requests:\nconst client = new ImageKit({\n maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n\n```ts\n// Configure the default for all requests:\nconst client = new ImageKit({\n timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n\n\n\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n\n```ts\nconst client = new ImageKit();\n\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: response, response: raw } = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(response.videoCodec);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `IMAGE_KIT_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new ImageKit({\n logger: logger.child({ name: 'ImageKit' }),\n logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.\nOptions on the client, such as retries, will be respected when making these requests.\n\n```ts\nawait client.post('/some/path', {\n body: { some_prop: 'foo' },\n query: { some_query_arg: 'bar' },\n});\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented\nparameter. This library doesn't validate at runtime that the request matches the type, so any extra values you\nsend will be sent as-is.\n\n```ts\nclient.files.upload({\n // ...\n // @ts-expect-error baz is not yet public\n baz: 'undocumented option',\n});\n```\n\nFor requests with the `GET` verb, any extra params will be in the query, all other requests will send the\nextra param in the body.\n\nIf you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may access the response object with `// @ts-expect-error` on\nthe response object, or cast the response object to the requisite type. Like the request params, we do not\nvalidate or strip extra properties from the response from the API.\n\n### Customizing the fetch client\n\nBy default, this library expects a global `fetch` function is defined.\n\nIf you want to use a different `fetch` function, you can either polyfill the global:\n\n```ts\nimport fetch from 'my-fetch';\n\nglobalThis.fetch = fetch;\n```\n\nOr pass it to the client:\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport fetch from 'my-fetch';\n\nconst client = new ImageKit({ fetch });\n```\n\n### Fetch options\n\nIf you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n // `RequestInit` options\n },\n});\n```\n\n#### Configuring proxies\n\nTo modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy\noptions to requests:\n\n **Node** [[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport * as undici from 'undici';\n\nconst proxyAgent = new undici.ProxyAgent('http://localhost:8888');\nconst client = new ImageKit({\n fetchOptions: {\n dispatcher: proxyAgent,\n },\n});\n```\n\n **Bun** [[docs](https://bun.sh/guides/http/proxy)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n proxy: 'http://localhost:8888',\n },\n});\n```\n\n **Deno** [[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]\n\n```ts\nimport ImageKit from 'npm:@imagekit/nodejs';\n\nconst httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });\nconst client = new ImageKit({\n fetchOptions: {\n client: httpClient,\n },\n});\n```\n\n## Frequently Asked Questions\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-nodejs/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n", + "# Image Kit TypeScript API Library\n\n[![NPM version](https://img.shields.io/npm/v/@imagekit/nodejs.svg?label=npm%20(stable))](https://npmjs.org/package/@imagekit/nodejs) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@imagekit/nodejs)\n\nThis library provides convenient access to the Image Kit REST API from server-side TypeScript or JavaScript.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n```sh\nnpm install @imagekit/nodejs\n```\n\n\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n\n```js\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n});\n\nconsole.log(response.videoCodec);\n```\n\n\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst params: ImageKit.FileUploadParams = {\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n};\nconst response: ImageKit.FileUploadResponse = await client.files.upload(params);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed in many different forms:\n- `File` (or an object with the same structure)\n- a `fetch` `Response` (or an object with the same structure)\n- an `fs.ReadStream`\n- the return value of our `toFile` helper\n\n```ts\nimport fs from 'fs';\nimport ImageKit, { toFile } from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\n// If you have access to Node `fs` we recommend using `fs.createReadStream()`:\nawait client.files.upload({ file: fs.createReadStream('/path/to/file'), fileName: 'fileName' });\n\n// Or if you have the web `File` API you can pass a `File` instance:\nawait client.files.upload({ file: new File(['my bytes'], 'file'), fileName: 'fileName' });\n\n// You can also pass a `fetch` `Response`:\nawait client.files.upload({ file: await fetch('https://somesite/file'), fileName: 'fileName' });\n\n// Finally, if none of the above are convenient, you can use our `toFile` helper:\nawait client.files.upload({\n file: await toFile(Buffer.from('my bytes'), 'file'),\n fileName: 'fileName',\n});\nawait client.files.upload({\n file: await toFile(new Uint8Array([0, 1, 2]), 'file'),\n fileName: 'fileName',\n});\n```\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n\n```ts\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .catch(async (err) => {\n if (err instanceof ImageKit.APIError) {\n console.log(err.status); // 400\n console.log(err.name); // BadRequestError\n console.log(err.headers); // {server: 'nginx', ...}\n } else {\n throw err;\n }\n });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n\n```js\n// Configure the default for all requests:\nconst client = new ImageKit({\n maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n\n```ts\n// Configure the default for all requests:\nconst client = new ImageKit({\n timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n\n\n\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n\n```ts\nconst client = new ImageKit();\n\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: response, response: raw } = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(response.videoCodec);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `IMAGE_KIT_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new ImageKit({\n logger: logger.child({ name: 'ImageKit' }),\n logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.\nOptions on the client, such as retries, will be respected when making these requests.\n\n```ts\nawait client.post('/some/path', {\n body: { some_prop: 'foo' },\n query: { some_query_arg: 'bar' },\n});\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented\nparameter. This library doesn't validate at runtime that the request matches the type, so any extra values you\nsend will be sent as-is.\n\n```ts\nclient.files.upload({\n // ...\n // @ts-expect-error baz is not yet public\n baz: 'undocumented option',\n});\n```\n\nFor requests with the `GET` verb, any extra params will be in the query, all other requests will send the\nextra param in the body.\n\nIf you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may access the response object with `// @ts-expect-error` on\nthe response object, or cast the response object to the requisite type. Like the request params, we do not\nvalidate or strip extra properties from the response from the API.\n\n### Customizing the fetch client\n\nBy default, this library expects a global `fetch` function is defined.\n\nIf you want to use a different `fetch` function, you can either polyfill the global:\n\n```ts\nimport fetch from 'my-fetch';\n\nglobalThis.fetch = fetch;\n```\n\nOr pass it to the client:\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport fetch from 'my-fetch';\n\nconst client = new ImageKit({ fetch });\n```\n\n### Fetch options\n\nIf you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n // `RequestInit` options\n },\n});\n```\n\n#### Configuring proxies\n\nTo modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy\noptions to requests:\n\n **Node** [[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport * as undici from 'undici';\n\nconst proxyAgent = new undici.ProxyAgent('http://localhost:8888');\nconst client = new ImageKit({\n fetchOptions: {\n dispatcher: proxyAgent,\n },\n});\n```\n\n **Bun** [[docs](https://bun.sh/guides/http/proxy)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n proxy: 'http://localhost:8888',\n },\n});\n```\n\n **Deno** [[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]\n\n```ts\nimport ImageKit from 'npm:@imagekit/nodejs';\n\nconst httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });\nconst client = new ImageKit({\n fetchOptions: {\n client: httpClient,\n },\n});\n```\n\n## Frequently Asked Questions\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-nodejs/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n", }, { language: 'ruby', content: - '# Image Kit Ruby API library\n\nThe Image Kit Ruby library provides convenient access to the Image Kit REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/imagekit-developer/imagekit-ruby#Sorbet) for usage with Sorbet. The standard library\'s `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nDocumentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/imagekitio).\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference).\n\n## Installation\n\nTo use this gem, install via Bundler by adding the following to your application\'s `Gemfile`:\n\n\n\n```ruby\ngem "imagekitio", "~> 0.0.1"\n```\n\n\n\n## Usage\n\n```ruby\nrequire "bundler/setup"\nrequire "imagekitio"\n\nimage_kit = Imagekitio::Client.new(\n private_key: ENV["IMAGEKIT_PRIVATE_KEY"], # This is the default and can be omitted\n password: ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"] # This is the default and can be omitted\n)\n\nresponse = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\nputs(response.videoCodec)\n```\n\n\n\n\n\n### File uploads\n\nRequest parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, [`StringIO`](https://rubyapi.org/3.2/o/stringio), or more.\n\n```ruby\nrequire "pathname"\n\n# Use `Pathname` to send the filename and/or avoid paging a large file into memory:\nresponse = image_kit.files.upload(file: Pathname("/path/to/file"))\n\n# Alternatively, pass file contents or a `StringIO` directly:\nresponse = image_kit.files.upload(file: File.read("/path/to/file"))\n\n# Or, to control the filename and/or content type:\nfile = Imagekitio::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…")\nresponse = image_kit.files.upload(file: file)\n\nputs(response.videoCodec)\n```\n\nNote that you can also pass a raw `IO` descriptor, but this disables retries, as the library can\'t be sure if the descriptor is a file or pipe (which cannot be rewound).\n\n### Handling errors\n\nWhen the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Imagekitio::Errors::APIError` will be thrown:\n\n```ruby\nbegin\n file = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n )\nrescue Imagekitio::Errors::APIConnectionError => e\n puts("The server could not be reached")\n puts(e.cause) # an underlying Exception, likely raised within `net/http`\nrescue Imagekitio::Errors::RateLimitError => e\n puts("A 429 status code was received; we should back off a bit.")\nrescue Imagekitio::Errors::APIStatusError => e\n puts("Another non-200-range status code was received")\n puts(e.status)\nend\n```\n\nError codes are as follows:\n\n| Cause | Error Type |\n| ---------------- | -------------------------- |\n| HTTP 400 | `BadRequestError` |\n| HTTP 401 | `AuthenticationError` |\n| HTTP 403 | `PermissionDeniedError` |\n| HTTP 404 | `NotFoundError` |\n| HTTP 409 | `ConflictError` |\n| HTTP 422 | `UnprocessableEntityError` |\n| HTTP 429 | `RateLimitError` |\n| HTTP >= 500 | `InternalServerError` |\n| Other HTTP error | `APIStatusError` |\n| Timeout | `APITimeoutError` |\n| Network error | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\n\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.\n\nYou can use the `max_retries` option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n max_retries: 0 # default is 2\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {max_retries: 5}\n)\n```\n\n### Timeouts\n\nBy default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n timeout: nil # default is 60\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {timeout: 5}\n)\n```\n\nOn timeout, `Imagekitio::Errors::APITimeoutError` is raised.\n\nNote that requests that time out are retried by default.\n\n## Advanced concepts\n\n### BaseModel\n\nAll parameter and response objects inherit from `Imagekitio::Internal::Type::BaseModel`, which provides several conveniences, including:\n\n1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.\n\n2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.\n\n3. Both instances and the classes themselves can be pretty-printed.\n\n4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.\n\n### Making custom or undocumented requests\n\n#### Undocumented properties\n\nYou can send undocumented parameters to any endpoint, and read undocumented response properties, like so:\n\nNote: the `extra_` parameters of the same name overrides the documented parameters.\n\n```ruby\nresponse =\n image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {\n extra_query: {my_query_parameter: value},\n extra_body: {my_body_parameter: value},\n extra_headers: {"my-header": value}\n }\n )\n\nputs(response[:my_undocumented_property])\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:\n\n```ruby\nresponse = client.request(\n method: :post,\n path: \'/undocumented/endpoint\',\n query: {"dog": "woof"},\n headers: {"useful-header": "interesting-value"},\n body: {"hello": "world"}\n)\n```\n\n### Concurrency & connection pooling\n\nThe `Imagekitio::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.\n\nEach instance of `Imagekitio::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.\n\nWhen all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.\n\nUnless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.\n\n## Sorbet\n\nThis library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.\n\nYou can provide typesafe request parameters like so:\n\n```ruby\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n```\n\nOr, equivalently:\n\n```ruby\n# Hashes work, but are not typesafe:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\n# You can also splat a full Params class:\nparams = Imagekitio::FileUploadParams.new(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\nimage_kit.files.upload(**params)\n```\n\n### Enums\n\nSince this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:\n\n```ruby\n# :all\nputs(Imagekitio::AssetListParams::FileType::ALL)\n\n# Revealed type: `T.all(Imagekitio::AssetListParams::FileType, Symbol)`\nT.reveal_type(Imagekitio::AssetListParams::FileType::ALL)\n```\n\nEnum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:\n\n```ruby\n# Using the enum constants preserves the tagged type information:\nimage_kit.assets.list(\n file_type: Imagekitio::AssetListParams::FileType::ALL,\n # …\n)\n\n# Literal values are also permissible:\nimage_kit.assets.list(\n file_type: :all,\n # …\n)\n```\n\n## Versioning\n\nThis package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.\n\nThis package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.\n\n## Requirements\n\nRuby 3.2.0 or higher.\n\n## Contributing\n\nSee [the contributing documentation](https://github.com/imagekit-developer/imagekit-ruby/tree/master/CONTRIBUTING.md).\n', + '# Image Kit Ruby API library\n\nThe Image Kit Ruby library provides convenient access to the Image Kit REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/imagekit-developer/imagekit-ruby#Sorbet) for usage with Sorbet. The standard library\'s `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nDocumentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/imagekitio).\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference).\n\n## Installation\n\nTo use this gem, install via Bundler by adding the following to your application\'s `Gemfile`:\n\n\n\n```ruby\ngem "imagekitio", "~> 0.0.1"\n```\n\n\n\n## Usage\n\n```ruby\nrequire "bundler/setup"\nrequire "imagekitio"\n\nimage_kit = Imagekitio::Client.new(\n private_key: ENV["IMAGEKIT_PRIVATE_KEY"], # This is the default and can be omitted\n password: ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"] # This is the default and can be omitted\n)\n\nresponse = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\nputs(response.videoCodec)\n```\n\n\n\n\n\n### File uploads\n\nRequest parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, [`StringIO`](https://rubyapi.org/3.2/o/stringio), or more.\n\n```ruby\nrequire "pathname"\n\n# Use `Pathname` to send the filename and/or avoid paging a large file into memory:\nresponse = image_kit.files.upload(file: Pathname("/path/to/file"))\n\n# Alternatively, pass file contents or a `StringIO` directly:\nresponse = image_kit.files.upload(file: File.read("/path/to/file"))\n\n# Or, to control the filename and/or content type:\nfile = Imagekitio::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…")\nresponse = image_kit.files.upload(file: file)\n\nputs(response.videoCodec)\n```\n\nNote that you can also pass a raw `IO` descriptor, but this disables retries, as the library can\'t be sure if the descriptor is a file or pipe (which cannot be rewound).\n\n### Handling errors\n\nWhen the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Imagekitio::Errors::APIError` will be thrown:\n\n```ruby\nbegin\n file = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n )\nrescue Imagekitio::Errors::APIConnectionError => e\n puts("The server could not be reached")\n puts(e.cause) # an underlying Exception, likely raised within `net/http`\nrescue Imagekitio::Errors::RateLimitError => e\n puts("A 429 status code was received; we should back off a bit.")\nrescue Imagekitio::Errors::APIStatusError => e\n puts("Another non-200-range status code was received")\n puts(e.status)\nend\n```\n\nError codes are as follows:\n\n| Cause | Error Type |\n| ---------------- | -------------------------- |\n| HTTP 400 | `BadRequestError` |\n| HTTP 401 | `AuthenticationError` |\n| HTTP 403 | `PermissionDeniedError` |\n| HTTP 404 | `NotFoundError` |\n| HTTP 409 | `ConflictError` |\n| HTTP 422 | `UnprocessableEntityError` |\n| HTTP 429 | `RateLimitError` |\n| HTTP >= 500 | `InternalServerError` |\n| Other HTTP error | `APIStatusError` |\n| Timeout | `APITimeoutError` |\n| Network error | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\n\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.\n\nYou can use the `max_retries` option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n max_retries: 0 # default is 2\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {max_retries: 5}\n)\n```\n\n### Timeouts\n\nBy default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n timeout: nil # default is 60\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {timeout: 5}\n)\n```\n\nOn timeout, `Imagekitio::Errors::APITimeoutError` is raised.\n\nNote that requests that time out are retried by default.\n\n## Advanced concepts\n\n### BaseModel\n\nAll parameter and response objects inherit from `Imagekitio::Internal::Type::BaseModel`, which provides several conveniences, including:\n\n1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.\n\n2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.\n\n3. Both instances and the classes themselves can be pretty-printed.\n\n4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.\n\n### Making custom or undocumented requests\n\n#### Undocumented properties\n\nYou can send undocumented parameters to any endpoint, and read undocumented response properties, like so:\n\nNote: the `extra_` parameters of the same name overrides the documented parameters.\n\n```ruby\nresponse =\n image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {\n extra_query: {my_query_parameter: value},\n extra_body: {my_body_parameter: value},\n extra_headers: {"my-header": value}\n }\n )\n\nputs(response[:my_undocumented_property])\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:\n\n```ruby\nresponse = client.request(\n method: :post,\n path: \'/undocumented/endpoint\',\n query: {"dog": "woof"},\n headers: {"useful-header": "interesting-value"},\n body: {"hello": "world"}\n)\n```\n\n### Concurrency & connection pooling\n\nThe `Imagekitio::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.\n\nEach instance of `Imagekitio::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.\n\nWhen all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.\n\nUnless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.\n\n## Sorbet\n\nThis library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.\n\nYou can provide typesafe request parameters like so:\n\n```ruby\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n```\n\nOr, equivalently:\n\n```ruby\n# Hashes work, but are not typesafe:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\n# You can also splat a full Params class:\nparams = Imagekitio::FileUploadParams.new(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\nimage_kit.files.upload(**params)\n```\n\n### Enums\n\nSince this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:\n\n```ruby\n# :all\nputs(Imagekitio::AssetListParams::FileType::ALL)\n\n# Revealed type: `T.all(Imagekitio::AssetListParams::FileType, Symbol)`\nT.reveal_type(Imagekitio::AssetListParams::FileType::ALL)\n```\n\nEnum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:\n\n```ruby\n# Using the enum constants preserves the tagged type information:\nimage_kit.assets.list(\n file_type: Imagekitio::AssetListParams::FileType::ALL,\n # …\n)\n\n# Literal values are also permissible:\nimage_kit.assets.list(\n file_type: :all,\n # …\n)\n```\n\n## Versioning\n\nThis package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.\n\nThis package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.\n\n## Requirements\n\nRuby 3.2.0 or higher.\n\n## Contributing\n\nSee [the contributing documentation](https://github.com/imagekit-developer/imagekit-ruby/tree/master/CONTRIBUTING.md).\n', }, { language: 'java', content: - '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-java\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport com.imagekit.api.client.ImageKitClientAsync;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.MultipartField;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport com.imagekit.api.core.http.Headers;\nimport com.imagekit.api.core.http.HttpResponseFor;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.Transformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.JsonMissing;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport com.imagekit.api.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-java/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-java\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport com.imagekit.api.client.ImageKitClientAsync;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.MultipartField;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport com.imagekit.api.core.http.Headers;\nimport com.imagekit.api.core.http.HttpResponseFor;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.Transformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.JsonMissing;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport com.imagekit.api.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-java/issues) with questions, bugs, or suggestions.\n', + }, + { + language: 'kotlin', + content: + '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.Transformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', }, { language: 'csharp', diff --git a/packages/mcp-server/tsconfig.build.json b/packages/mcp-server/tsconfig.build.json index 1b954538..97a7682a 100644 --- a/packages/mcp-server/tsconfig.build.json +++ b/packages/mcp-server/tsconfig.build.json @@ -5,8 +5,8 @@ "compilerOptions": { "rootDir": "./dist/src", "paths": { - "@imagekit/api-mcp/*": ["./dist/src/*"], - "@imagekit/api-mcp": ["./dist/src/index.ts"] + "@imagekit/nodejs-mcp/*": ["./dist/src/*"], + "@imagekit/nodejs-mcp": ["./dist/src/index.ts"] }, "noEmit": false, "declaration": true, diff --git a/packages/mcp-server/tsconfig.json b/packages/mcp-server/tsconfig.json index d39971cc..d189e6f9 100644 --- a/packages/mcp-server/tsconfig.json +++ b/packages/mcp-server/tsconfig.json @@ -8,8 +8,8 @@ "moduleResolution": "node", "esModuleInterop": true, "paths": { - "@imagekit/api-mcp/*": ["./src/*"], - "@imagekit/api-mcp": ["./src/index.ts"] + "@imagekit/nodejs-mcp/*": ["./src/*"], + "@imagekit/nodejs-mcp": ["./src/index.ts"] }, "noEmit": true, From c56e5822277cbd8ec1fce6a4cbf62f12aac97472 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 04:52:23 +0000 Subject: [PATCH 06/36] Java dev --- .stats.yml | 6 +++--- packages/mcp-server/src/local-docs-search.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3aa7595d..c9a36176 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-70c42eda2bee929830b2537f758400a58dded1f1ef5686a286e2469c35a041a0.yml -openapi_spec_hash: cdaeed824e91657b45092765cf55eb42 -config_hash: 2a6f67c966b8b3db6f986be4ac23a507 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml +openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 +config_hash: cc8ab8a2b72639af4d57e4e268ed3f73 diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 8dee61ba..641dcdbc 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -77,7 +77,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ csharp: { method: 'CustomMetadataFields.Create', example: - 'CustomMetadataFieldCreateParams parameters = new()\n{\n Label = "price",\n Name = "price",\n Schema = new()\n {\n Type = Type.Number,\n DefaultValue = new(\n\n [\n new UnnamedSchemaWithArrayParent1(true),\n new UnnamedSchemaWithArrayParent1(10),\n new UnnamedSchemaWithArrayParent1("Hello"),\n ]\n ),\n IsValueRequired = true,\n MaxLength = 0,\n MaxValue = 3000,\n MinLength = 0,\n MinValue = 1000,\n SelectOptions =\n [\n "small", "medium", "large", 30, 40, true\n ],\n },\n};\n\nvar customMetadataField = await client.CustomMetadataFields.Create(parameters);\n\nConsole.WriteLine(customMetadataField);', + 'CustomMetadataFieldCreateParams parameters = new()\n{\n Label = "price",\n Name = "price",\n Schema = new()\n {\n Type = Type.Number,\n DefaultValue = new(\n\n [\n new DefaultValueItem(true),\n new DefaultValueItem(10),\n new DefaultValueItem("Hello"),\n ]\n ),\n IsValueRequired = true,\n MaxLength = 0,\n MaxValue = 3000,\n MinLength = 0,\n MinValue = 1000,\n SelectOptions =\n [\n "small", "medium", "large", 30, 40, true\n ],\n },\n};\n\nvar customMetadataField = await client.CustomMetadataFields.Create(parameters);\n\nConsole.WriteLine(customMetadataField);', }, go: { method: 'client.CustomMetadataFields.New', @@ -3328,12 +3328,12 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'java', content: - '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-java\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport com.imagekit.api.client.ImageKitClientAsync;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.MultipartField;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport com.imagekit.api.core.http.Headers;\nimport com.imagekit.api.core.http.HttpResponseFor;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.Transformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.JsonMissing;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport com.imagekit.api.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-java/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-java\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport com.imagekit.api.client.ImageKitClientAsync;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.MultipartField;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport com.imagekit.api.core.http.Headers;\nimport com.imagekit.api.core.http.HttpResponseFor;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.JsonMissing;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport com.imagekit.api.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-java/issues) with questions, bugs, or suggestions.\n', }, { language: 'kotlin', content: - '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.Transformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', }, { language: 'csharp', From 8ad5efdd55d6d24310c7d8155de4ae85071d9540 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 05:08:29 +0000 Subject: [PATCH 07/36] feat(api): manual updates --- .stats.yml | 2 +- packages/mcp-server/Dockerfile | 6 +++--- packages/mcp-server/README.md | 10 +++++----- packages/mcp-server/build | 2 +- packages/mcp-server/cloudflare-worker/package.json | 2 +- packages/mcp-server/cloudflare-worker/src/index.ts | 2 +- packages/mcp-server/jest.config.ts | 4 ++-- packages/mcp-server/manifest.json | 2 +- packages/mcp-server/package.json | 6 +++--- packages/mcp-server/src/local-docs-search.ts | 12 ++++++------ packages/mcp-server/tsconfig.build.json | 4 ++-- packages/mcp-server/tsconfig.json | 4 ++-- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.stats.yml b/.stats.yml index c9a36176..669269dd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: cc8ab8a2b72639af4d57e4e268ed3f73 +config_hash: d886c9d8ebe60aa25c77553dba16d410 diff --git a/packages/mcp-server/Dockerfile b/packages/mcp-server/Dockerfile index c45b8e10..591955c5 100644 --- a/packages/mcp-server/Dockerfile +++ b/packages/mcp-server/Dockerfile @@ -3,10 +3,10 @@ # This Dockerfile builds a Docker image for the MCP Server. # # To build the image locally: -# docker build -f packages/mcp-server/Dockerfile -t @imagekit/nodejs-mcp:local . +# docker build -f packages/mcp-server/Dockerfile -t @imagekit/api-mcp:local . # # To run the image: -# docker run -i @imagekit/nodejs-mcp:local [OPTIONS] +# docker run -i @imagekit/api-mcp:local [OPTIONS] # # Common options: # --tool= Include specific tools @@ -16,7 +16,7 @@ # --transport= Set transport type (stdio or http) # # For a full list of options: -# docker run -i @imagekit/nodejs-mcp:local --help +# docker run -i @imagekit/api-mcp:local --help # # Note: The MCP server uses stdio transport by default. Docker's -i flag # enables interactive mode, allowing the container to communicate over stdin/stdout. diff --git a/packages/mcp-server/README.md b/packages/mcp-server/README.md index 74900266..2fe6b778 100644 --- a/packages/mcp-server/README.md +++ b/packages/mcp-server/README.md @@ -10,7 +10,7 @@ You can run the MCP Server directly via `npx`: export IMAGEKIT_PRIVATE_KEY="My Private Key" export OPTIONAL_IMAGEKIT_IGNORES_THIS="My Password" export IMAGEKIT_WEBHOOK_SECRET="My Webhook Secret" -npx -y @imagekit/nodejs-mcp@latest +npx -y @imagekit/api-mcp@latest ``` ### Via MCP Client @@ -25,7 +25,7 @@ For clients with a configuration JSON, it might look something like this: "mcpServers": { "imagekit_nodejs_api": { "command": "npx", - "args": ["-y", "@imagekit/nodejs-mcp"], + "args": ["-y", "@imagekit/api-mcp"], "env": { "IMAGEKIT_PRIVATE_KEY": "My Private Key", "OPTIONAL_IMAGEKIT_IGNORES_THIS": "My Password", @@ -41,14 +41,14 @@ For clients with a configuration JSON, it might look something like this: If you use Cursor, you can install the MCP server by using the button below. You will need to set your environment variables in Cursor's `mcp.json`, which can be found in Cursor Settings > Tools & MCP > New MCP Server. -[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19) +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19) ### VS Code If you use MCP, you can install the MCP server by clicking the link below. You will need to set your environment variables in VS Code's `mcp.json`, which can be found via Command Palette > MCP: Open User Configuration. -[Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D) +[Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D) ### Claude Code @@ -56,7 +56,7 @@ If you use Claude Code, you can install the MCP server by running the command be environment variables in Claude Code's `.claude.json`, which can be found in your home directory. ``` -claude mcp add imagekit_nodejs_mcp_api --env IMAGEKIT_PRIVATE_KEY="My Private Key" OPTIONAL_IMAGEKIT_IGNORES_THIS="My Password" IMAGEKIT_WEBHOOK_SECRET="My Webhook Secret" -- npx -y @imagekit/nodejs-mcp +claude mcp add imagekit_api_mcp_api --env IMAGEKIT_PRIVATE_KEY="My Private Key" OPTIONAL_IMAGEKIT_IGNORES_THIS="My Password" IMAGEKIT_WEBHOOK_SECRET="My Webhook Secret" -- npx -y @imagekit/api-mcp ``` ## Code Mode diff --git a/packages/mcp-server/build b/packages/mcp-server/build index e1ea7a1c..90381d31 100644 --- a/packages/mcp-server/build +++ b/packages/mcp-server/build @@ -29,7 +29,7 @@ cp tsconfig.dist-src.json dist/src/tsconfig.json chmod +x dist/index.js -DIST_PATH=./dist PKG_IMPORT_PATH=@imagekit/nodejs-mcp/ node ../../scripts/utils/postprocess-files.cjs +DIST_PATH=./dist PKG_IMPORT_PATH=@imagekit/api-mcp/ node ../../scripts/utils/postprocess-files.cjs # mcp bundle rm -rf dist-bundle imagekit_nodejs_api.mcpb; mkdir dist-bundle diff --git a/packages/mcp-server/cloudflare-worker/package.json b/packages/mcp-server/cloudflare-worker/package.json index 311b9a35..84c0823b 100644 --- a/packages/mcp-server/cloudflare-worker/package.json +++ b/packages/mcp-server/cloudflare-worker/package.json @@ -21,7 +21,7 @@ "@modelcontextprotocol/sdk": "^1.27.1", "agents": "^0.8.5", "hono": "^4.12.4", - "@imagekit/nodejs-mcp": "latest", + "@imagekit/api-mcp": "latest", "zod": "^3.24.4" } } diff --git a/packages/mcp-server/cloudflare-worker/src/index.ts b/packages/mcp-server/cloudflare-worker/src/index.ts index 59c12b47..18cc7802 100644 --- a/packages/mcp-server/cloudflare-worker/src/index.ts +++ b/packages/mcp-server/cloudflare-worker/src/index.ts @@ -1,7 +1,7 @@ import { makeOAuthConsent } from './app'; import { McpAgent } from 'agents/mcp'; import OAuthProvider from '@cloudflare/workers-oauth-provider'; -import { McpOptions, initMcpServer, server, ClientOptions } from '@imagekit/nodejs-mcp/server'; +import { McpOptions, initMcpServer, server, ClientOptions } from '@imagekit/api-mcp/server'; import type { ExportedHandler } from '@cloudflare/workers-types'; type MCPProps = { diff --git a/packages/mcp-server/jest.config.ts b/packages/mcp-server/jest.config.ts index 6c2868f4..c1a41722 100644 --- a/packages/mcp-server/jest.config.ts +++ b/packages/mcp-server/jest.config.ts @@ -7,8 +7,8 @@ const config: JestConfigWithTsJest = { '^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }], }, moduleNameMapper: { - '^@imagekit/nodejs-mcp$': '/src/index.ts', - '^@imagekit/nodejs-mcp/(.*)$': '/src/$1', + '^@imagekit/api-mcp$': '/src/index.ts', + '^@imagekit/api-mcp/(.*)$': '/src/$1', }, modulePathIgnorePatterns: ['/dist/'], testPathIgnorePatterns: ['scripts'], diff --git a/packages/mcp-server/manifest.json b/packages/mcp-server/manifest.json index ca446e07..c9dbefa4 100644 --- a/packages/mcp-server/manifest.json +++ b/packages/mcp-server/manifest.json @@ -1,6 +1,6 @@ { "dxt_version": "0.2", - "name": "@imagekit/nodejs-mcp", + "name": "@imagekit/api-mcp", "version": "7.5.0", "description": "The official MCP Server for the Image Kit API", "author": { diff --git a/packages/mcp-server/package.json b/packages/mcp-server/package.json index a9abcc04..d3b791d3 100644 --- a/packages/mcp-server/package.json +++ b/packages/mcp-server/package.json @@ -1,5 +1,5 @@ { - "name": "@imagekit/nodejs-mcp", + "name": "@imagekit/api-mcp", "version": "7.5.0", "description": "The official MCP Server for the Image Kit API", "author": "Image Kit ", @@ -78,8 +78,8 @@ "tsconfig-paths": "^4.0.0" }, "imports": { - "@imagekit/nodejs-mcp": ".", - "@imagekit/nodejs-mcp/*": "./src/*" + "@imagekit/api-mcp": ".", + "@imagekit/api-mcp/*": "./src/*" }, "exports": { ".": { diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 641dcdbc..17af4877 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -3303,12 +3303,12 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'python', content: - '# Image Kit Python API library\n\n\n[![PyPI version](https://img.shields.io/pypi/v/imagekitio.svg?label=pypi%20(stable))](https://pypi.org/project/imagekitio/)\n\nThe Image Kit Python library provides convenient access to the Image Kit REST API from any Python 3.9+\napplication. The library includes type definitions for all request params and response fields,\nand offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n## Installation\n\n```sh\n# install from PyPI\npip install imagekitio\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nresponse = client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.video_codec)\n```\n\nWhile you can provide a `private_key` keyword argument,\nwe recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nto add `IMAGEKIT_PRIVATE_KEY="My Private Key"` to your `.env` file\nso that your Private Key is not stored in source control.\n\n## Async usage\n\nSimply import `AsyncImageKit` instead of `ImageKit` and use `await` with each API call:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import AsyncImageKit\n\nclient = AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nasync def main() -> None:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n### With aiohttp\n\nBy default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.\n\nYou can enable this by installing `aiohttp`:\n\n```sh\n# install from PyPI\npip install imagekitio[aiohttp]\n```\n\nThen you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import DefaultAioHttpClient\nfrom imagekitio import AsyncImageKit\n\nasync def main() -> None:\n async with AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n http_client=DefaultAioHttpClient(),\n) as client:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\n\n\n## Using types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:\n\n- Serializing back into JSON, `model.to_json()`\n- Converting to a dictionary, `model.to_dict()`\n\nTyped requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.\n\n\n\n## Nested params\n\nNested parameters are dictionaries, typed using `TypedDict`, for example:\n\n```python\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nresponse = client.files.upload(\n file=b"Example data",\n file_name="fileName",\n transformation={\n "post": [{\n "type": "thumbnail",\n "value": "w-150,h-150",\n }, {\n "protocol": "dash",\n "type": "abs",\n "value": "sr-240_360_480_720_1080",\n }]\n },\n)\nprint(response.transformation)\n```\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.\n\n```python\nfrom pathlib import Path\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nclient.files.upload(\n file=Path("/path/to/file"),\n file_name="fileName",\n)\n```\n\nThe async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.\n\n## Handling errors\n\nWhen the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `imagekitio.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (that is, 4xx or 5xx\nresponse), a subclass of `imagekitio.APIStatusError` is raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `imagekitio.APIError`.\n\n```python\nimport imagekitio\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\ntry:\n client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\nexcept imagekitio.APIConnectionError as e:\n print("The server could not be reached")\n print(e.__cause__) # an underlying Exception, likely raised within httpx.\nexcept imagekitio.RateLimitError as e:\n print("A 429 status code was received; we should back off a bit.")\nexcept imagekitio.APIStatusError as e:\n print("Another non-200-range status code was received")\n print(e.status_code)\n print(e.response)\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors are automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors are all retried by default.\n\nYou can use the `max_retries` option to configure or disable retry settings:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # default is 2\n max_retries=0,\n)\n\n# Or, configure per-request:\nclient.with_options(max_retries = 5).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\n### Timeouts\n\nBy default requests time out after 1 minute. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # 20 seconds (default is 1 minute)\n timeout=20.0,\n)\n\n# More granular control:\nclient = ImageKit(\n timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n)\n\n# Override per-request:\nclient.with_options(timeout = 5.0).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests that time out are [retried twice by default](#retries).\n\n\n\n## Advanced\n\n### Logging\n\nWe use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.\n\nYou can enable logging by setting the environment variable `IMAGE_KIT_LOG` to `info`.\n\n```shell\n$ export IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging.\n\n### How to tell whether `None` means `null` or missing\n\nIn an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:\n\n```py\nif response.my_field is None:\n if \'my_field\' not in response.model_fields_set:\n print(\'Got json like {}, without a "my_field" key present at all.\')\n else:\n print(\'Got json like {"my_field": null}.\')\n```\n\n### Accessing raw response data (e.g. headers)\n\nThe "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,\n\n```py\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\nresponse = client.files.with_raw_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.headers.get(\'X-My-Header\'))\n\nfile = response.parse() # get the object that `files.upload()` would have returned\nprint(file.video_codec)\n```\n\nThese methods return an [`APIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) object.\n\nThe async client returns an [`AsyncAPIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.\n\n#### `.with_streaming_response`\n\nThe above interface eagerly reads the full response body when you make the request, which may not always be what you want.\n\nTo stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.\n\n```python\nwith client.files.with_streaming_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n) as response :\n print(response.headers.get(\'X-My-Header\'))\n\n for line in response.iter_lines():\n print(line)\n```\n\nThe context manager is required so that the response will reliably be closed.\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API.\n\nIf you need to access undocumented endpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other\nhttp verbs. Options on the client will be respected (such as retries) when making this request.\n\n```py\nimport httpx\n\nresponse = client.post(\n "/foo",\n cast_to=httpx.Response,\n body={"my_param": True},\n)\n\nprint(response.headers.get("x-foo"))\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You\ncan also get all the extra fields on the Pydantic model as a dict with\n[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).\n\n### Configuring the HTTP client\n\nYou can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:\n\n- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)\n- Custom [transports](https://www.python-httpx.org/advanced/transports/)\n- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality\n\n```python\nimport httpx\nfrom imagekitio import ImageKit, DefaultHttpxClient\n\nclient = ImageKit(\n # Or use the `IMAGE_KIT_BASE_URL` env var\n base_url="http://my.test.server.example.com:8083",\n http_client=DefaultHttpxClient(proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),\n)\n```\n\nYou can also customize the client on a per-request basis by using `with_options()`:\n\n```python\nclient.with_options(http_client=DefaultHttpxClient(...))\n```\n\n### Managing HTTP resources\n\nBy default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.\n\n```py\nfrom imagekitio import ImageKit\n\nwith ImageKit() as client:\n # make requests here\n ...\n\n# HTTP client is now closed\n```\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you\'ve upgraded to the latest version but aren\'t seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport imagekitio\nprint(imagekitio.__version__)\n```\n\n## Requirements\n\nPython 3.9 or higher.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', + '# Image Kit Python API library\n\n\n[![PyPI version](https://img.shields.io/pypi/v/imagekitio.svg?label=pypi%20(stable))](https://pypi.org/project/imagekitio/)\n\nThe Image Kit Python library provides convenient access to the Image Kit REST API from any Python 3.9+\napplication. The library includes type definitions for all request params and response fields,\nand offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n## Installation\n\n```sh\n# install from PyPI\npip install imagekitio\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nresponse = client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.video_codec)\n```\n\nWhile you can provide a `private_key` keyword argument,\nwe recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nto add `IMAGEKIT_PRIVATE_KEY="My Private Key"` to your `.env` file\nso that your Private Key is not stored in source control.\n\n## Async usage\n\nSimply import `AsyncImageKit` instead of `ImageKit` and use `await` with each API call:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import AsyncImageKit\n\nclient = AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nasync def main() -> None:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n### With aiohttp\n\nBy default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.\n\nYou can enable this by installing `aiohttp`:\n\n```sh\n# install from PyPI\npip install imagekitio[aiohttp]\n```\n\nThen you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import DefaultAioHttpClient\nfrom imagekitio import AsyncImageKit\n\nasync def main() -> None:\n async with AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n http_client=DefaultAioHttpClient(),\n) as client:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\n\n\n## Using types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:\n\n- Serializing back into JSON, `model.to_json()`\n- Converting to a dictionary, `model.to_dict()`\n\nTyped requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.\n\n\n\n## Nested params\n\nNested parameters are dictionaries, typed using `TypedDict`, for example:\n\n```python\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nresponse = client.files.upload(\n file=b"Example data",\n file_name="fileName",\n transformation={\n "post": [{\n "type": "thumbnail",\n "value": "w-150,h-150",\n }, {\n "protocol": "dash",\n "type": "abs",\n "value": "sr-240_360_480_720_1080",\n }]\n },\n)\nprint(response.transformation)\n```\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.\n\n```python\nfrom pathlib import Path\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nclient.files.upload(\n file=Path("/path/to/file"),\n file_name="fileName",\n)\n```\n\nThe async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.\n\n## Handling errors\n\nWhen the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `imagekitio.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (that is, 4xx or 5xx\nresponse), a subclass of `imagekitio.APIStatusError` is raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `imagekitio.APIError`.\n\n```python\nimport imagekitio\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\ntry:\n client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\nexcept imagekitio.APIConnectionError as e:\n print("The server could not be reached")\n print(e.__cause__) # an underlying Exception, likely raised within httpx.\nexcept imagekitio.RateLimitError as e:\n print("A 429 status code was received; we should back off a bit.")\nexcept imagekitio.APIStatusError as e:\n print("Another non-200-range status code was received")\n print(e.status_code)\n print(e.response)\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors are automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors are all retried by default.\n\nYou can use the `max_retries` option to configure or disable retry settings:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # default is 2\n max_retries=0,\n)\n\n# Or, configure per-request:\nclient.with_options(max_retries = 5).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\n### Timeouts\n\nBy default requests time out after 1 minute. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # 20 seconds (default is 1 minute)\n timeout=20.0,\n)\n\n# More granular control:\nclient = ImageKit(\n timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n)\n\n# Override per-request:\nclient.with_options(timeout = 5.0).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests that time out are [retried twice by default](#retries).\n\n\n\n## Advanced\n\n### Logging\n\nWe use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.\n\nYou can enable logging by setting the environment variable `IMAGE_KIT_LOG` to `info`.\n\n```shell\n$ export IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging.\n\n### How to tell whether `None` means `null` or missing\n\nIn an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:\n\n```py\nif response.my_field is None:\n if \'my_field\' not in response.model_fields_set:\n print(\'Got json like {}, without a "my_field" key present at all.\')\n else:\n print(\'Got json like {"my_field": null}.\')\n```\n\n### Accessing raw response data (e.g. headers)\n\nThe "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,\n\n```py\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\nresponse = client.files.with_raw_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.headers.get(\'X-My-Header\'))\n\nfile = response.parse() # get the object that `files.upload()` would have returned\nprint(file.video_codec)\n```\n\nThese methods return an [`APIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) object.\n\nThe async client returns an [`AsyncAPIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.\n\n#### `.with_streaming_response`\n\nThe above interface eagerly reads the full response body when you make the request, which may not always be what you want.\n\nTo stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.\n\n```python\nwith client.files.with_streaming_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n) as response :\n print(response.headers.get(\'X-My-Header\'))\n\n for line in response.iter_lines():\n print(line)\n```\n\nThe context manager is required so that the response will reliably be closed.\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API.\n\nIf you need to access undocumented endpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other\nhttp verbs. Options on the client will be respected (such as retries) when making this request.\n\n```py\nimport httpx\n\nresponse = client.post(\n "/foo",\n cast_to=httpx.Response,\n body={"my_param": True},\n)\n\nprint(response.headers.get("x-foo"))\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You\ncan also get all the extra fields on the Pydantic model as a dict with\n[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).\n\n### Configuring the HTTP client\n\nYou can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:\n\n- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)\n- Custom [transports](https://www.python-httpx.org/advanced/transports/)\n- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality\n\n```python\nimport httpx\nfrom imagekitio import ImageKit, DefaultHttpxClient\n\nclient = ImageKit(\n # Or use the `IMAGE_KIT_BASE_URL` env var\n base_url="http://my.test.server.example.com:8083",\n http_client=DefaultHttpxClient(proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),\n)\n```\n\nYou can also customize the client on a per-request basis by using `with_options()`:\n\n```python\nclient.with_options(http_client=DefaultHttpxClient(...))\n```\n\n### Managing HTTP resources\n\nBy default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.\n\n```py\nfrom imagekitio import ImageKit\n\nwith ImageKit() as client:\n # make requests here\n ...\n\n# HTTP client is now closed\n```\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you\'ve upgraded to the latest version but aren\'t seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport imagekitio\nprint(imagekitio.__version__)\n```\n\n## Requirements\n\nPython 3.9 or higher.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', }, { language: 'go', content: - '# Image Kit Go API Library\n\nGo Reference\n\nThe Image Kit Go library provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference)\nfrom applications written in Go.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n\n\n```go\nimport (\n\t"github.com/imagekit-developer/imagekit-go" // imported as SDK_PackageName\n)\n```\n\n\n\nOr to pin the version:\n\n\n\n```sh\ngo get -u \'github.com/imagekit-developer/imagekit-go@v0.0.1\'\n```\n\n\n\n## Requirements\n\nThis library requires Go 1.22+.\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```go\npackage main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"), // defaults to os.LookupEnv("IMAGEKIT_PRIVATE_KEY")\n\t\toption.WithPassword("My Password"), // defaults to os.LookupEnv("OPTIONAL_IMAGEKIT_IGNORES_THIS")\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n\n```\n\n### Request fields\n\nAll request parameters are wrapped in a generic `Field` type,\nwhich we use to distinguish zero values from null or omitted fields.\n\nThis prevents accidentally sending a zero value if you forget a required parameter,\nand enables explicitly sending `null`, `false`, `\'\'`, or `0` on optional parameters.\nAny field not specified is not sent.\n\nTo construct fields with values, use the helpers `String()`, `Int()`, `Float()`, or most commonly, the generic `F[T]()`.\nTo send a null, use `Null[T]()`, and to send a nonconforming value, use `Raw[T](any)`. For example:\n\n```go\nparams := FooParams{\n\tName: SDK_PackageName.F("hello"),\n\n\t// Explicitly send `"description": null`\n\tDescription: SDK_PackageName.Null[string](),\n\n\tPoint: SDK_PackageName.F(SDK_PackageName.Point{\n\t\tX: SDK_PackageName.Int(0),\n\t\tY: SDK_PackageName.Int(1),\n\n\t\t// In cases where the API specifies a given type,\n\t\t// but you want to send something else, use `Raw`:\n\t\tZ: SDK_PackageName.Raw[int64](0.01), // sends a float\n\t}),\n}\n```\n\n### Response objects\n\nAll fields in response structs are value types (not pointers or wrappers).\n\nIf a given field is `null`, not present, or invalid, the corresponding field\nwill simply be its zero value.\n\nAll response structs also include a special `JSON` field, containing more detailed\ninformation about each property, which you can use like so:\n\n```go\nif res.Name == "" {\n\t// true if `"name"` is either not present or explicitly null\n\tres.JSON.Name.IsNull()\n\n\t// true if the `"name"` key was not present in the response JSON at all\n\tres.JSON.Name.IsMissing()\n\n\t// When the API returns data that cannot be coerced to the expected type:\n\tif res.JSON.Name.IsInvalid() {\n\t\traw := res.JSON.Name.Raw()\n\n\t\tlegacyName := struct{\n\t\t\tFirst string `json:"first"`\n\t\t\tLast string `json:"last"`\n\t\t}{}\n\t\tjson.Unmarshal([]byte(raw), &legacyName)\n\t\tname = legacyName.First + " " + legacyName.Last\n\t}\n}\n```\n\nThese `.JSON` structs also include an `Extras` map containing\nany properties in the json response that were not specified\nin the struct. This can be useful for API features not yet\npresent in the SDK.\n\n```go\nbody := res.JSON.ExtraFields["my_unexpected_field"].Raw()\n```\n\n### RequestOptions\n\nThis library uses the functional options pattern. Functions defined in the\n`SDK_PackageOptionName` package return a `RequestOption`, which is a closure that mutates a\n`RequestConfig`. These options can be supplied to the client or at individual\nrequests. For example:\n\n```go\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\t// Adds a header to every request made by the client\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "custom_header_info"),\n)\n\nclient.Files.Upload(context.TODO(), ...,\n\t// Override the header\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "some_other_custom_header_info"),\n\t// Add an undocumented field to the request body, using sjson syntax\n\tSDK_PackageOptionName.WithJSONSet("some.json.path", map[string]string{"my": "object"}),\n)\n```\n\nSee the [full list of request options](https://pkg.go.dev/github.com/imagekit-developer/imagekit-go/SDK_PackageOptionName).\n\n### Pagination\n\nThis library provides some conveniences for working with paginated list endpoints.\n\nYou can use `.ListAutoPaging()` methods to iterate through items across all pages:\n\n\n\nOr you can use simple `.List()` methods to fetch a single page and receive a standard response object\nwith additional helper methods like `.GetNextPage()`, e.g.:\n\n\n\n### Errors\n\nWhen the API returns a non-success status code, we return an error with type\n`*SDK_PackageName.Error`. This contains the `StatusCode`, `*http.Request`, and\n`*http.Response` values of the request, as well as the JSON of the error body\n(much like other response objects in the SDK).\n\nTo handle errors, we recommend that you use the `errors.As` pattern:\n\n```go\n_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\tFileName: "file-name.jpg",\n})\nif err != nil {\n\tvar apierr *imagekit.Error\n\tif errors.As(err, &apierr) {\n\t\tprintln(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request\n\t\tprintln(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response\n\t}\n\tpanic(err.Error()) // GET "/api/v1/files/upload": 400 Bad Request { ... }\n}\n```\n\nWhen other errors occur, they are returned unwrapped; for example,\nif HTTP transport fails, you might receive `*url.Error` wrapping `*net.OpError`.\n\n### Timeouts\n\nRequests do not time out by default; use context to configure a timeout for a request lifecycle.\n\nNote that if a request is [retried](#retries), the context timeout does not start over.\nTo set a per-retry timeout, use `SDK_PackageOptionName.WithRequestTimeout()`.\n\n```go\n// This sets the timeout for the request, including all the retries.\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\nclient.Files.Upload(\n\tctx,\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\t// This sets the per-retry timeout\n\toption.WithRequestTimeout(20*time.Second),\n)\n```\n\n### File uploads\n\nRequest parameters that correspond to file uploads in multipart requests are typed as\n`param.Field[io.Reader]`. The contents of the `io.Reader` will by default be sent as a multipart form\npart with the file name of "anonymous_file" and content-type of "application/octet-stream".\n\nThe file name and content-type can be customized by implementing `Name() string` or `ContentType()\nstring` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a\nfile returned by `os.Open` will be sent with the file name on disk.\n\nWe also provide a helper `SDK_PackageName.FileParam(reader io.Reader, filename string, contentType string)`\nwhich can be used to wrap any `io.Reader` with the appropriate file name and content type.\n\n```go\n// A file from the file system\nfile, err := os.Open("/path/to/file")\nimagekit.FileUploadParams{\n\tFile: file,\n\tFileName: "fileName",\n}\n\n// A file from a string\nimagekit.FileUploadParams{\n\tFile: strings.NewReader("my file contents"),\n\tFileName: "fileName",\n}\n\n// With a custom filename and contentType\nimagekit.FileUploadParams{\n\tFile: imagekit.NewFile(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"),\n\tFileName: "fileName",\n}\n```\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nWe retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit,\nand >=500 Internal errors.\n\nYou can use the `WithMaxRetries` option to configure or disable this:\n\n```go\n// Configure the default for all requests:\nclient := imagekit.NewClient(\n\toption.WithMaxRetries(0), // default is 2\n)\n\n// Override per-request:\nclient.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithMaxRetries(5),\n)\n```\n\n\n### Accessing raw response data (e.g. response headers)\n\nYou can access the raw HTTP response data by using the `option.WithResponseInto()` request option. This is useful when\nyou need to examine response headers, status codes, or other details.\n\n```go\n// Create a variable to store the HTTP response\nvar response *http.Response\nresponse, err := client.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithResponseInto(&response),\n)\nif err != nil {\n\t// handle error\n}\nfmt.Printf("%+v\\n", response)\n\nfmt.Printf("Status Code: %d\\n", response.StatusCode)\nfmt.Printf("Headers: %+#v\\n", response.Header)\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.Get`, `client.Post`, and other HTTP verbs.\n`RequestOptions` on the client, such as retries, will be respected when making these requests.\n\n```go\nvar (\n // params can be an io.Reader, a []byte, an encoding/json serializable object,\n // or a "…Params" struct defined in this library.\n params map[string]interface{}\n\n // result can be an []byte, *http.Response, a encoding/json deserializable object,\n // or a model defined in this library.\n result *http.Response\n)\nerr := client.Post(context.Background(), "/unspecified", params, &result)\nif err != nil {\n …\n}\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use either the `SDK_PackageOptionName.WithQuerySet()`\nor the `SDK_PackageOptionName.WithJSONSet()` methods.\n\n```go\nparams := FooNewParams{\n ID: SDK_PackageName.F("id_xxxx"),\n Data: SDK_PackageName.F(FooNewParamsData{\n FirstName: SDK_PackageName.F("John"),\n }),\n}\nclient.Foo.New(context.Background(), params, SDK_PackageOptionName.WithJSONSet("data.last_name", "Doe"))\n```\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may either access the raw JSON of the response as a string\nwith `result.JSON.RawJSON()`, or get the raw JSON of a particular field on the result with\n`result.JSON.Foo.Raw()`.\n\nAny fields that are not present on the response struct will be saved and can be accessed by `result.JSON.ExtraFields()` which returns the extra fields as a `map[string]Field`.\n\n### Middleware\n\nWe provide `SDK_PackageOptionName.WithMiddleware` which applies the given\nmiddleware to requests.\n\n```go\nfunc Logger(req *http.Request, next SDK_PackageOptionName.MiddlewareNext) (res *http.Response, err error) {\n\t// Before the request\n\tstart := time.Now()\n\tLogReq(req)\n\n\t// Forward the request to the next handler\n\tres, err = next(req)\n\n\t// Handle stuff after the request\n\tend := time.Now()\n\tLogRes(res, err, start - end)\n\n return res, err\n}\n\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\tSDK_PackageOptionName.WithMiddleware(Logger),\n)\n```\n\nWhen multiple middlewares are provided as variadic arguments, the middlewares\nare applied left to right. If `SDK_PackageOptionName.WithMiddleware` is given\nmultiple times, for example first in the client then the method, the\nmiddleware in the client will run first and the middleware given in the method\nwill run next.\n\nYou may also replace the default `http.Client` with\n`SDK_PackageOptionName.WithHTTPClient(client)`. Only one http client is\naccepted (this overwrites any previous client) and receives requests after any\nmiddleware has been applied.\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-go/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', + '# Image Kit Go API Library\n\nGo Reference\n\nThe Image Kit Go library provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference)\nfrom applications written in Go.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n\n\n```go\nimport (\n\t"github.com/imagekit-developer/imagekit-go" // imported as SDK_PackageName\n)\n```\n\n\n\nOr to pin the version:\n\n\n\n```sh\ngo get -u \'github.com/imagekit-developer/imagekit-go@v0.0.1\'\n```\n\n\n\n## Requirements\n\nThis library requires Go 1.22+.\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```go\npackage main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"), // defaults to os.LookupEnv("IMAGEKIT_PRIVATE_KEY")\n\t\toption.WithPassword("My Password"), // defaults to os.LookupEnv("OPTIONAL_IMAGEKIT_IGNORES_THIS")\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n\n```\n\n### Request fields\n\nAll request parameters are wrapped in a generic `Field` type,\nwhich we use to distinguish zero values from null or omitted fields.\n\nThis prevents accidentally sending a zero value if you forget a required parameter,\nand enables explicitly sending `null`, `false`, `\'\'`, or `0` on optional parameters.\nAny field not specified is not sent.\n\nTo construct fields with values, use the helpers `String()`, `Int()`, `Float()`, or most commonly, the generic `F[T]()`.\nTo send a null, use `Null[T]()`, and to send a nonconforming value, use `Raw[T](any)`. For example:\n\n```go\nparams := FooParams{\n\tName: SDK_PackageName.F("hello"),\n\n\t// Explicitly send `"description": null`\n\tDescription: SDK_PackageName.Null[string](),\n\n\tPoint: SDK_PackageName.F(SDK_PackageName.Point{\n\t\tX: SDK_PackageName.Int(0),\n\t\tY: SDK_PackageName.Int(1),\n\n\t\t// In cases where the API specifies a given type,\n\t\t// but you want to send something else, use `Raw`:\n\t\tZ: SDK_PackageName.Raw[int64](0.01), // sends a float\n\t}),\n}\n```\n\n### Response objects\n\nAll fields in response structs are value types (not pointers or wrappers).\n\nIf a given field is `null`, not present, or invalid, the corresponding field\nwill simply be its zero value.\n\nAll response structs also include a special `JSON` field, containing more detailed\ninformation about each property, which you can use like so:\n\n```go\nif res.Name == "" {\n\t// true if `"name"` is either not present or explicitly null\n\tres.JSON.Name.IsNull()\n\n\t// true if the `"name"` key was not present in the response JSON at all\n\tres.JSON.Name.IsMissing()\n\n\t// When the API returns data that cannot be coerced to the expected type:\n\tif res.JSON.Name.IsInvalid() {\n\t\traw := res.JSON.Name.Raw()\n\n\t\tlegacyName := struct{\n\t\t\tFirst string `json:"first"`\n\t\t\tLast string `json:"last"`\n\t\t}{}\n\t\tjson.Unmarshal([]byte(raw), &legacyName)\n\t\tname = legacyName.First + " " + legacyName.Last\n\t}\n}\n```\n\nThese `.JSON` structs also include an `Extras` map containing\nany properties in the json response that were not specified\nin the struct. This can be useful for API features not yet\npresent in the SDK.\n\n```go\nbody := res.JSON.ExtraFields["my_unexpected_field"].Raw()\n```\n\n### RequestOptions\n\nThis library uses the functional options pattern. Functions defined in the\n`SDK_PackageOptionName` package return a `RequestOption`, which is a closure that mutates a\n`RequestConfig`. These options can be supplied to the client or at individual\nrequests. For example:\n\n```go\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\t// Adds a header to every request made by the client\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "custom_header_info"),\n)\n\nclient.Files.Upload(context.TODO(), ...,\n\t// Override the header\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "some_other_custom_header_info"),\n\t// Add an undocumented field to the request body, using sjson syntax\n\tSDK_PackageOptionName.WithJSONSet("some.json.path", map[string]string{"my": "object"}),\n)\n```\n\nSee the [full list of request options](https://pkg.go.dev/github.com/imagekit-developer/imagekit-go/SDK_PackageOptionName).\n\n### Pagination\n\nThis library provides some conveniences for working with paginated list endpoints.\n\nYou can use `.ListAutoPaging()` methods to iterate through items across all pages:\n\n\n\nOr you can use simple `.List()` methods to fetch a single page and receive a standard response object\nwith additional helper methods like `.GetNextPage()`, e.g.:\n\n\n\n### Errors\n\nWhen the API returns a non-success status code, we return an error with type\n`*SDK_PackageName.Error`. This contains the `StatusCode`, `*http.Request`, and\n`*http.Response` values of the request, as well as the JSON of the error body\n(much like other response objects in the SDK).\n\nTo handle errors, we recommend that you use the `errors.As` pattern:\n\n```go\n_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\tFileName: "file-name.jpg",\n})\nif err != nil {\n\tvar apierr *imagekit.Error\n\tif errors.As(err, &apierr) {\n\t\tprintln(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request\n\t\tprintln(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response\n\t}\n\tpanic(err.Error()) // GET "/api/v1/files/upload": 400 Bad Request { ... }\n}\n```\n\nWhen other errors occur, they are returned unwrapped; for example,\nif HTTP transport fails, you might receive `*url.Error` wrapping `*net.OpError`.\n\n### Timeouts\n\nRequests do not time out by default; use context to configure a timeout for a request lifecycle.\n\nNote that if a request is [retried](#retries), the context timeout does not start over.\nTo set a per-retry timeout, use `SDK_PackageOptionName.WithRequestTimeout()`.\n\n```go\n// This sets the timeout for the request, including all the retries.\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\nclient.Files.Upload(\n\tctx,\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\t// This sets the per-retry timeout\n\toption.WithRequestTimeout(20*time.Second),\n)\n```\n\n### File uploads\n\nRequest parameters that correspond to file uploads in multipart requests are typed as\n`param.Field[io.Reader]`. The contents of the `io.Reader` will by default be sent as a multipart form\npart with the file name of "anonymous_file" and content-type of "application/octet-stream".\n\nThe file name and content-type can be customized by implementing `Name() string` or `ContentType()\nstring` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a\nfile returned by `os.Open` will be sent with the file name on disk.\n\nWe also provide a helper `SDK_PackageName.FileParam(reader io.Reader, filename string, contentType string)`\nwhich can be used to wrap any `io.Reader` with the appropriate file name and content type.\n\n```go\n// A file from the file system\nfile, err := os.Open("/path/to/file")\nimagekit.FileUploadParams{\n\tFile: file,\n\tFileName: "fileName",\n}\n\n// A file from a string\nimagekit.FileUploadParams{\n\tFile: strings.NewReader("my file contents"),\n\tFileName: "fileName",\n}\n\n// With a custom filename and contentType\nimagekit.FileUploadParams{\n\tFile: imagekit.NewFile(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"),\n\tFileName: "fileName",\n}\n```\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nWe retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit,\nand >=500 Internal errors.\n\nYou can use the `WithMaxRetries` option to configure or disable this:\n\n```go\n// Configure the default for all requests:\nclient := imagekit.NewClient(\n\toption.WithMaxRetries(0), // default is 2\n)\n\n// Override per-request:\nclient.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithMaxRetries(5),\n)\n```\n\n\n### Accessing raw response data (e.g. response headers)\n\nYou can access the raw HTTP response data by using the `option.WithResponseInto()` request option. This is useful when\nyou need to examine response headers, status codes, or other details.\n\n```go\n// Create a variable to store the HTTP response\nvar response *http.Response\nresponse, err := client.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithResponseInto(&response),\n)\nif err != nil {\n\t// handle error\n}\nfmt.Printf("%+v\\n", response)\n\nfmt.Printf("Status Code: %d\\n", response.StatusCode)\nfmt.Printf("Headers: %+#v\\n", response.Header)\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.Get`, `client.Post`, and other HTTP verbs.\n`RequestOptions` on the client, such as retries, will be respected when making these requests.\n\n```go\nvar (\n // params can be an io.Reader, a []byte, an encoding/json serializable object,\n // or a "…Params" struct defined in this library.\n params map[string]interface{}\n\n // result can be an []byte, *http.Response, a encoding/json deserializable object,\n // or a model defined in this library.\n result *http.Response\n)\nerr := client.Post(context.Background(), "/unspecified", params, &result)\nif err != nil {\n …\n}\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use either the `SDK_PackageOptionName.WithQuerySet()`\nor the `SDK_PackageOptionName.WithJSONSet()` methods.\n\n```go\nparams := FooNewParams{\n ID: SDK_PackageName.F("id_xxxx"),\n Data: SDK_PackageName.F(FooNewParamsData{\n FirstName: SDK_PackageName.F("John"),\n }),\n}\nclient.Foo.New(context.Background(), params, SDK_PackageOptionName.WithJSONSet("data.last_name", "Doe"))\n```\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may either access the raw JSON of the response as a string\nwith `result.JSON.RawJSON()`, or get the raw JSON of a particular field on the result with\n`result.JSON.Foo.Raw()`.\n\nAny fields that are not present on the response struct will be saved and can be accessed by `result.JSON.ExtraFields()` which returns the extra fields as a `map[string]Field`.\n\n### Middleware\n\nWe provide `SDK_PackageOptionName.WithMiddleware` which applies the given\nmiddleware to requests.\n\n```go\nfunc Logger(req *http.Request, next SDK_PackageOptionName.MiddlewareNext) (res *http.Response, err error) {\n\t// Before the request\n\tstart := time.Now()\n\tLogReq(req)\n\n\t// Forward the request to the next handler\n\tres, err = next(req)\n\n\t// Handle stuff after the request\n\tend := time.Now()\n\tLogRes(res, err, start - end)\n\n return res, err\n}\n\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\tSDK_PackageOptionName.WithMiddleware(Logger),\n)\n```\n\nWhen multiple middlewares are provided as variadic arguments, the middlewares\nare applied left to right. If `SDK_PackageOptionName.WithMiddleware` is given\nmultiple times, for example first in the client then the method, the\nmiddleware in the client will run first and the middleware given in the method\nwill run next.\n\nYou may also replace the default `http.Client` with\n`SDK_PackageOptionName.WithHTTPClient(client)`. Only one http client is\naccepted (this overwrites any previous client) and receives requests after any\nmiddleware has been applied.\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-go/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', }, { language: 'terraform', @@ -3318,22 +3318,22 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'typescript', content: - "# Image Kit TypeScript API Library\n\n[![NPM version](https://img.shields.io/npm/v/@imagekit/nodejs.svg?label=npm%20(stable))](https://npmjs.org/package/@imagekit/nodejs) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@imagekit/nodejs)\n\nThis library provides convenient access to the Image Kit REST API from server-side TypeScript or JavaScript.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n```sh\nnpm install @imagekit/nodejs\n```\n\n\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n\n```js\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n});\n\nconsole.log(response.videoCodec);\n```\n\n\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst params: ImageKit.FileUploadParams = {\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n};\nconst response: ImageKit.FileUploadResponse = await client.files.upload(params);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed in many different forms:\n- `File` (or an object with the same structure)\n- a `fetch` `Response` (or an object with the same structure)\n- an `fs.ReadStream`\n- the return value of our `toFile` helper\n\n```ts\nimport fs from 'fs';\nimport ImageKit, { toFile } from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\n// If you have access to Node `fs` we recommend using `fs.createReadStream()`:\nawait client.files.upload({ file: fs.createReadStream('/path/to/file'), fileName: 'fileName' });\n\n// Or if you have the web `File` API you can pass a `File` instance:\nawait client.files.upload({ file: new File(['my bytes'], 'file'), fileName: 'fileName' });\n\n// You can also pass a `fetch` `Response`:\nawait client.files.upload({ file: await fetch('https://somesite/file'), fileName: 'fileName' });\n\n// Finally, if none of the above are convenient, you can use our `toFile` helper:\nawait client.files.upload({\n file: await toFile(Buffer.from('my bytes'), 'file'),\n fileName: 'fileName',\n});\nawait client.files.upload({\n file: await toFile(new Uint8Array([0, 1, 2]), 'file'),\n fileName: 'fileName',\n});\n```\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n\n```ts\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .catch(async (err) => {\n if (err instanceof ImageKit.APIError) {\n console.log(err.status); // 400\n console.log(err.name); // BadRequestError\n console.log(err.headers); // {server: 'nginx', ...}\n } else {\n throw err;\n }\n });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n\n```js\n// Configure the default for all requests:\nconst client = new ImageKit({\n maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n\n```ts\n// Configure the default for all requests:\nconst client = new ImageKit({\n timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n\n\n\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n\n```ts\nconst client = new ImageKit();\n\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: response, response: raw } = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(response.videoCodec);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `IMAGE_KIT_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new ImageKit({\n logger: logger.child({ name: 'ImageKit' }),\n logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.\nOptions on the client, such as retries, will be respected when making these requests.\n\n```ts\nawait client.post('/some/path', {\n body: { some_prop: 'foo' },\n query: { some_query_arg: 'bar' },\n});\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented\nparameter. This library doesn't validate at runtime that the request matches the type, so any extra values you\nsend will be sent as-is.\n\n```ts\nclient.files.upload({\n // ...\n // @ts-expect-error baz is not yet public\n baz: 'undocumented option',\n});\n```\n\nFor requests with the `GET` verb, any extra params will be in the query, all other requests will send the\nextra param in the body.\n\nIf you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may access the response object with `// @ts-expect-error` on\nthe response object, or cast the response object to the requisite type. Like the request params, we do not\nvalidate or strip extra properties from the response from the API.\n\n### Customizing the fetch client\n\nBy default, this library expects a global `fetch` function is defined.\n\nIf you want to use a different `fetch` function, you can either polyfill the global:\n\n```ts\nimport fetch from 'my-fetch';\n\nglobalThis.fetch = fetch;\n```\n\nOr pass it to the client:\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport fetch from 'my-fetch';\n\nconst client = new ImageKit({ fetch });\n```\n\n### Fetch options\n\nIf you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n // `RequestInit` options\n },\n});\n```\n\n#### Configuring proxies\n\nTo modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy\noptions to requests:\n\n **Node** [[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport * as undici from 'undici';\n\nconst proxyAgent = new undici.ProxyAgent('http://localhost:8888');\nconst client = new ImageKit({\n fetchOptions: {\n dispatcher: proxyAgent,\n },\n});\n```\n\n **Bun** [[docs](https://bun.sh/guides/http/proxy)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n proxy: 'http://localhost:8888',\n },\n});\n```\n\n **Deno** [[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]\n\n```ts\nimport ImageKit from 'npm:@imagekit/nodejs';\n\nconst httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });\nconst client = new ImageKit({\n fetchOptions: {\n client: httpClient,\n },\n});\n```\n\n## Frequently Asked Questions\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-nodejs/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n", + "# Image Kit TypeScript API Library\n\n[![NPM version](https://img.shields.io/npm/v/@imagekit/nodejs.svg?label=npm%20(stable))](https://npmjs.org/package/@imagekit/nodejs) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@imagekit/nodejs)\n\nThis library provides convenient access to the Image Kit REST API from server-side TypeScript or JavaScript.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n```sh\nnpm install @imagekit/nodejs\n```\n\n\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n\n```js\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n});\n\nconsole.log(response.videoCodec);\n```\n\n\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst params: ImageKit.FileUploadParams = {\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n};\nconst response: ImageKit.FileUploadResponse = await client.files.upload(params);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed in many different forms:\n- `File` (or an object with the same structure)\n- a `fetch` `Response` (or an object with the same structure)\n- an `fs.ReadStream`\n- the return value of our `toFile` helper\n\n```ts\nimport fs from 'fs';\nimport ImageKit, { toFile } from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\n// If you have access to Node `fs` we recommend using `fs.createReadStream()`:\nawait client.files.upload({ file: fs.createReadStream('/path/to/file'), fileName: 'fileName' });\n\n// Or if you have the web `File` API you can pass a `File` instance:\nawait client.files.upload({ file: new File(['my bytes'], 'file'), fileName: 'fileName' });\n\n// You can also pass a `fetch` `Response`:\nawait client.files.upload({ file: await fetch('https://somesite/file'), fileName: 'fileName' });\n\n// Finally, if none of the above are convenient, you can use our `toFile` helper:\nawait client.files.upload({\n file: await toFile(Buffer.from('my bytes'), 'file'),\n fileName: 'fileName',\n});\nawait client.files.upload({\n file: await toFile(new Uint8Array([0, 1, 2]), 'file'),\n fileName: 'fileName',\n});\n```\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n\n```ts\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .catch(async (err) => {\n if (err instanceof ImageKit.APIError) {\n console.log(err.status); // 400\n console.log(err.name); // BadRequestError\n console.log(err.headers); // {server: 'nginx', ...}\n } else {\n throw err;\n }\n });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n\n```js\n// Configure the default for all requests:\nconst client = new ImageKit({\n maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n\n```ts\n// Configure the default for all requests:\nconst client = new ImageKit({\n timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n\n\n\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n\n```ts\nconst client = new ImageKit();\n\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: response, response: raw } = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(response.videoCodec);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `IMAGE_KIT_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new ImageKit({\n logger: logger.child({ name: 'ImageKit' }),\n logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.\nOptions on the client, such as retries, will be respected when making these requests.\n\n```ts\nawait client.post('/some/path', {\n body: { some_prop: 'foo' },\n query: { some_query_arg: 'bar' },\n});\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented\nparameter. This library doesn't validate at runtime that the request matches the type, so any extra values you\nsend will be sent as-is.\n\n```ts\nclient.files.upload({\n // ...\n // @ts-expect-error baz is not yet public\n baz: 'undocumented option',\n});\n```\n\nFor requests with the `GET` verb, any extra params will be in the query, all other requests will send the\nextra param in the body.\n\nIf you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may access the response object with `// @ts-expect-error` on\nthe response object, or cast the response object to the requisite type. Like the request params, we do not\nvalidate or strip extra properties from the response from the API.\n\n### Customizing the fetch client\n\nBy default, this library expects a global `fetch` function is defined.\n\nIf you want to use a different `fetch` function, you can either polyfill the global:\n\n```ts\nimport fetch from 'my-fetch';\n\nglobalThis.fetch = fetch;\n```\n\nOr pass it to the client:\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport fetch from 'my-fetch';\n\nconst client = new ImageKit({ fetch });\n```\n\n### Fetch options\n\nIf you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n // `RequestInit` options\n },\n});\n```\n\n#### Configuring proxies\n\nTo modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy\noptions to requests:\n\n **Node** [[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport * as undici from 'undici';\n\nconst proxyAgent = new undici.ProxyAgent('http://localhost:8888');\nconst client = new ImageKit({\n fetchOptions: {\n dispatcher: proxyAgent,\n },\n});\n```\n\n **Bun** [[docs](https://bun.sh/guides/http/proxy)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n proxy: 'http://localhost:8888',\n },\n});\n```\n\n **Deno** [[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]\n\n```ts\nimport ImageKit from 'npm:@imagekit/nodejs';\n\nconst httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });\nconst client = new ImageKit({\n fetchOptions: {\n client: httpClient,\n },\n});\n```\n\n## Frequently Asked Questions\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-nodejs/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n", }, { language: 'ruby', content: - '# Image Kit Ruby API library\n\nThe Image Kit Ruby library provides convenient access to the Image Kit REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/imagekit-developer/imagekit-ruby#Sorbet) for usage with Sorbet. The standard library\'s `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nDocumentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/imagekitio).\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference).\n\n## Installation\n\nTo use this gem, install via Bundler by adding the following to your application\'s `Gemfile`:\n\n\n\n```ruby\ngem "imagekitio", "~> 0.0.1"\n```\n\n\n\n## Usage\n\n```ruby\nrequire "bundler/setup"\nrequire "imagekitio"\n\nimage_kit = Imagekitio::Client.new(\n private_key: ENV["IMAGEKIT_PRIVATE_KEY"], # This is the default and can be omitted\n password: ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"] # This is the default and can be omitted\n)\n\nresponse = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\nputs(response.videoCodec)\n```\n\n\n\n\n\n### File uploads\n\nRequest parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, [`StringIO`](https://rubyapi.org/3.2/o/stringio), or more.\n\n```ruby\nrequire "pathname"\n\n# Use `Pathname` to send the filename and/or avoid paging a large file into memory:\nresponse = image_kit.files.upload(file: Pathname("/path/to/file"))\n\n# Alternatively, pass file contents or a `StringIO` directly:\nresponse = image_kit.files.upload(file: File.read("/path/to/file"))\n\n# Or, to control the filename and/or content type:\nfile = Imagekitio::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…")\nresponse = image_kit.files.upload(file: file)\n\nputs(response.videoCodec)\n```\n\nNote that you can also pass a raw `IO` descriptor, but this disables retries, as the library can\'t be sure if the descriptor is a file or pipe (which cannot be rewound).\n\n### Handling errors\n\nWhen the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Imagekitio::Errors::APIError` will be thrown:\n\n```ruby\nbegin\n file = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n )\nrescue Imagekitio::Errors::APIConnectionError => e\n puts("The server could not be reached")\n puts(e.cause) # an underlying Exception, likely raised within `net/http`\nrescue Imagekitio::Errors::RateLimitError => e\n puts("A 429 status code was received; we should back off a bit.")\nrescue Imagekitio::Errors::APIStatusError => e\n puts("Another non-200-range status code was received")\n puts(e.status)\nend\n```\n\nError codes are as follows:\n\n| Cause | Error Type |\n| ---------------- | -------------------------- |\n| HTTP 400 | `BadRequestError` |\n| HTTP 401 | `AuthenticationError` |\n| HTTP 403 | `PermissionDeniedError` |\n| HTTP 404 | `NotFoundError` |\n| HTTP 409 | `ConflictError` |\n| HTTP 422 | `UnprocessableEntityError` |\n| HTTP 429 | `RateLimitError` |\n| HTTP >= 500 | `InternalServerError` |\n| Other HTTP error | `APIStatusError` |\n| Timeout | `APITimeoutError` |\n| Network error | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\n\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.\n\nYou can use the `max_retries` option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n max_retries: 0 # default is 2\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {max_retries: 5}\n)\n```\n\n### Timeouts\n\nBy default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n timeout: nil # default is 60\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {timeout: 5}\n)\n```\n\nOn timeout, `Imagekitio::Errors::APITimeoutError` is raised.\n\nNote that requests that time out are retried by default.\n\n## Advanced concepts\n\n### BaseModel\n\nAll parameter and response objects inherit from `Imagekitio::Internal::Type::BaseModel`, which provides several conveniences, including:\n\n1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.\n\n2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.\n\n3. Both instances and the classes themselves can be pretty-printed.\n\n4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.\n\n### Making custom or undocumented requests\n\n#### Undocumented properties\n\nYou can send undocumented parameters to any endpoint, and read undocumented response properties, like so:\n\nNote: the `extra_` parameters of the same name overrides the documented parameters.\n\n```ruby\nresponse =\n image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {\n extra_query: {my_query_parameter: value},\n extra_body: {my_body_parameter: value},\n extra_headers: {"my-header": value}\n }\n )\n\nputs(response[:my_undocumented_property])\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:\n\n```ruby\nresponse = client.request(\n method: :post,\n path: \'/undocumented/endpoint\',\n query: {"dog": "woof"},\n headers: {"useful-header": "interesting-value"},\n body: {"hello": "world"}\n)\n```\n\n### Concurrency & connection pooling\n\nThe `Imagekitio::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.\n\nEach instance of `Imagekitio::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.\n\nWhen all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.\n\nUnless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.\n\n## Sorbet\n\nThis library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.\n\nYou can provide typesafe request parameters like so:\n\n```ruby\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n```\n\nOr, equivalently:\n\n```ruby\n# Hashes work, but are not typesafe:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\n# You can also splat a full Params class:\nparams = Imagekitio::FileUploadParams.new(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\nimage_kit.files.upload(**params)\n```\n\n### Enums\n\nSince this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:\n\n```ruby\n# :all\nputs(Imagekitio::AssetListParams::FileType::ALL)\n\n# Revealed type: `T.all(Imagekitio::AssetListParams::FileType, Symbol)`\nT.reveal_type(Imagekitio::AssetListParams::FileType::ALL)\n```\n\nEnum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:\n\n```ruby\n# Using the enum constants preserves the tagged type information:\nimage_kit.assets.list(\n file_type: Imagekitio::AssetListParams::FileType::ALL,\n # …\n)\n\n# Literal values are also permissible:\nimage_kit.assets.list(\n file_type: :all,\n # …\n)\n```\n\n## Versioning\n\nThis package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.\n\nThis package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.\n\n## Requirements\n\nRuby 3.2.0 or higher.\n\n## Contributing\n\nSee [the contributing documentation](https://github.com/imagekit-developer/imagekit-ruby/tree/master/CONTRIBUTING.md).\n', + '# Image Kit Ruby API library\n\nThe Image Kit Ruby library provides convenient access to the Image Kit REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/imagekit-developer/imagekit-ruby#Sorbet) for usage with Sorbet. The standard library\'s `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nDocumentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/imagekitio).\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference).\n\n## Installation\n\nTo use this gem, install via Bundler by adding the following to your application\'s `Gemfile`:\n\n\n\n```ruby\ngem "imagekitio", "~> 0.0.1"\n```\n\n\n\n## Usage\n\n```ruby\nrequire "bundler/setup"\nrequire "imagekitio"\n\nimage_kit = Imagekitio::Client.new(\n private_key: ENV["IMAGEKIT_PRIVATE_KEY"], # This is the default and can be omitted\n password: ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"] # This is the default and can be omitted\n)\n\nresponse = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\nputs(response.videoCodec)\n```\n\n\n\n\n\n### File uploads\n\nRequest parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, [`StringIO`](https://rubyapi.org/3.2/o/stringio), or more.\n\n```ruby\nrequire "pathname"\n\n# Use `Pathname` to send the filename and/or avoid paging a large file into memory:\nresponse = image_kit.files.upload(file: Pathname("/path/to/file"))\n\n# Alternatively, pass file contents or a `StringIO` directly:\nresponse = image_kit.files.upload(file: File.read("/path/to/file"))\n\n# Or, to control the filename and/or content type:\nfile = Imagekitio::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…")\nresponse = image_kit.files.upload(file: file)\n\nputs(response.videoCodec)\n```\n\nNote that you can also pass a raw `IO` descriptor, but this disables retries, as the library can\'t be sure if the descriptor is a file or pipe (which cannot be rewound).\n\n### Handling errors\n\nWhen the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Imagekitio::Errors::APIError` will be thrown:\n\n```ruby\nbegin\n file = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n )\nrescue Imagekitio::Errors::APIConnectionError => e\n puts("The server could not be reached")\n puts(e.cause) # an underlying Exception, likely raised within `net/http`\nrescue Imagekitio::Errors::RateLimitError => e\n puts("A 429 status code was received; we should back off a bit.")\nrescue Imagekitio::Errors::APIStatusError => e\n puts("Another non-200-range status code was received")\n puts(e.status)\nend\n```\n\nError codes are as follows:\n\n| Cause | Error Type |\n| ---------------- | -------------------------- |\n| HTTP 400 | `BadRequestError` |\n| HTTP 401 | `AuthenticationError` |\n| HTTP 403 | `PermissionDeniedError` |\n| HTTP 404 | `NotFoundError` |\n| HTTP 409 | `ConflictError` |\n| HTTP 422 | `UnprocessableEntityError` |\n| HTTP 429 | `RateLimitError` |\n| HTTP >= 500 | `InternalServerError` |\n| Other HTTP error | `APIStatusError` |\n| Timeout | `APITimeoutError` |\n| Network error | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\n\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.\n\nYou can use the `max_retries` option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n max_retries: 0 # default is 2\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {max_retries: 5}\n)\n```\n\n### Timeouts\n\nBy default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n timeout: nil # default is 60\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {timeout: 5}\n)\n```\n\nOn timeout, `Imagekitio::Errors::APITimeoutError` is raised.\n\nNote that requests that time out are retried by default.\n\n## Advanced concepts\n\n### BaseModel\n\nAll parameter and response objects inherit from `Imagekitio::Internal::Type::BaseModel`, which provides several conveniences, including:\n\n1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.\n\n2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.\n\n3. Both instances and the classes themselves can be pretty-printed.\n\n4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.\n\n### Making custom or undocumented requests\n\n#### Undocumented properties\n\nYou can send undocumented parameters to any endpoint, and read undocumented response properties, like so:\n\nNote: the `extra_` parameters of the same name overrides the documented parameters.\n\n```ruby\nresponse =\n image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {\n extra_query: {my_query_parameter: value},\n extra_body: {my_body_parameter: value},\n extra_headers: {"my-header": value}\n }\n )\n\nputs(response[:my_undocumented_property])\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:\n\n```ruby\nresponse = client.request(\n method: :post,\n path: \'/undocumented/endpoint\',\n query: {"dog": "woof"},\n headers: {"useful-header": "interesting-value"},\n body: {"hello": "world"}\n)\n```\n\n### Concurrency & connection pooling\n\nThe `Imagekitio::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.\n\nEach instance of `Imagekitio::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.\n\nWhen all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.\n\nUnless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.\n\n## Sorbet\n\nThis library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.\n\nYou can provide typesafe request parameters like so:\n\n```ruby\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n```\n\nOr, equivalently:\n\n```ruby\n# Hashes work, but are not typesafe:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\n# You can also splat a full Params class:\nparams = Imagekitio::FileUploadParams.new(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\nimage_kit.files.upload(**params)\n```\n\n### Enums\n\nSince this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:\n\n```ruby\n# :all\nputs(Imagekitio::AssetListParams::FileType::ALL)\n\n# Revealed type: `T.all(Imagekitio::AssetListParams::FileType, Symbol)`\nT.reveal_type(Imagekitio::AssetListParams::FileType::ALL)\n```\n\nEnum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:\n\n```ruby\n# Using the enum constants preserves the tagged type information:\nimage_kit.assets.list(\n file_type: Imagekitio::AssetListParams::FileType::ALL,\n # …\n)\n\n# Literal values are also permissible:\nimage_kit.assets.list(\n file_type: :all,\n # …\n)\n```\n\n## Versioning\n\nThis package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.\n\nThis package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.\n\n## Requirements\n\nRuby 3.2.0 or higher.\n\n## Contributing\n\nSee [the contributing documentation](https://github.com/imagekit-developer/imagekit-ruby/tree/master/CONTRIBUTING.md).\n', }, { language: 'java', content: - '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-java\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport com.imagekit.api.client.ImageKitClientAsync;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.MultipartField;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport com.imagekit.api.core.http.Headers;\nimport com.imagekit.api.core.http.HttpResponseFor;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.JsonMissing;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport com.imagekit.api.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-java/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-java\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport com.imagekit.api.client.ImageKitClientAsync;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.MultipartField;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport com.imagekit.api.core.http.Headers;\nimport com.imagekit.api.core.http.HttpResponseFor;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.JsonMissing;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport com.imagekit.api.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-java/issues) with questions, bugs, or suggestions.\n', }, { language: 'kotlin', content: - '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', }, { language: 'csharp', diff --git a/packages/mcp-server/tsconfig.build.json b/packages/mcp-server/tsconfig.build.json index 97a7682a..1b954538 100644 --- a/packages/mcp-server/tsconfig.build.json +++ b/packages/mcp-server/tsconfig.build.json @@ -5,8 +5,8 @@ "compilerOptions": { "rootDir": "./dist/src", "paths": { - "@imagekit/nodejs-mcp/*": ["./dist/src/*"], - "@imagekit/nodejs-mcp": ["./dist/src/index.ts"] + "@imagekit/api-mcp/*": ["./dist/src/*"], + "@imagekit/api-mcp": ["./dist/src/index.ts"] }, "noEmit": false, "declaration": true, diff --git a/packages/mcp-server/tsconfig.json b/packages/mcp-server/tsconfig.json index d189e6f9..d39971cc 100644 --- a/packages/mcp-server/tsconfig.json +++ b/packages/mcp-server/tsconfig.json @@ -8,8 +8,8 @@ "moduleResolution": "node", "esModuleInterop": true, "paths": { - "@imagekit/nodejs-mcp/*": ["./src/*"], - "@imagekit/nodejs-mcp": ["./src/index.ts"] + "@imagekit/api-mcp/*": ["./src/*"], + "@imagekit/api-mcp": ["./src/index.ts"] }, "noEmit": true, From fab0b1e4659e232c59df2a1e1ebec09d0f8639da Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 05:11:57 +0000 Subject: [PATCH 08/36] chore: update SDK settings --- .stats.yml | 2 +- packages/mcp-server/src/local-docs-search.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 669269dd..a37aee71 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: d886c9d8ebe60aa25c77553dba16d410 +config_hash: 4fa07762cb363071cfdeef3f7eeec56e diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 17af4877..20b4437f 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -3328,7 +3328,7 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'java', content: - '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-java\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport com.imagekit.api.client.ImageKitClientAsync;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.MultipartField;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport com.imagekit.api.core.http.Headers;\nimport com.imagekit.api.core.http.HttpResponseFor;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.JsonMissing;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport com.imagekit.api.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-java/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport com.imagekit.api.client.ImageKitClientAsync;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.MultipartField;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport com.imagekit.api.core.http.Headers;\nimport com.imagekit.api.core.http.HttpResponseFor;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.JsonMissing;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport com.imagekit.api.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', }, { language: 'kotlin', From f4b748aab3a25fed6f0a29c30ca9c6f49f992c94 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 05:52:12 +0000 Subject: [PATCH 09/36] feat(api): manual updates --- .stats.yml | 2 +- packages/mcp-server/src/local-docs-search.ts | 102 +++++++++---------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/.stats.yml b/.stats.yml index a37aee71..71485510 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: 4fa07762cb363071cfdeef3f7eeec56e +config_hash: ef918f7e878d4168a07e867607eb68ea diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 20b4437f..33f9211d 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -91,7 +91,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().create', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build();\n CustomMetadataField customMetadataField = client.customMetadataFields().create(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build();\n CustomMetadataField customMetadataField = client.customMetadataFields().create(params);\n }\n}', }, kotlin: { method: 'customMetadataFields().create', @@ -157,7 +157,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().list', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List customMetadataFields = client.customMetadataFields().list();\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List customMetadataFields = client.customMetadataFields().list();\n }\n}', }, kotlin: { method: 'customMetadataFields().list', @@ -226,7 +226,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().update', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataField customMetadataField = client.customMetadataFields().update("id");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataField customMetadataField = client.customMetadataFields().update("id");\n }\n}', }, kotlin: { method: 'customMetadataFields().update', @@ -291,7 +291,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldDeleteResponse customMetadataField = client.customMetadataFields().delete("id");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteParams;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldDeleteResponse customMetadataField = client.customMetadataFields().delete("id");\n }\n}', }, kotlin: { method: 'customMetadataFields().delete', @@ -381,7 +381,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().upload', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.files().upload(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.files().upload(params);\n }\n}', }, kotlin: { method: 'files().upload', @@ -447,7 +447,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.FileGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n File file = client.files().get("fileId");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.File;\nimport io.imagekit.io.models.files.FileGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n File file = client.files().get("fileId");\n }\n}', }, kotlin: { method: 'files().get', @@ -514,7 +514,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().update', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUpdateParams;\nimport com.imagekit.api.models.files.FileUpdateResponse;\nimport com.imagekit.api.models.files.UpdateFileRequest;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUpdateParams params = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build();\n FileUpdateResponse file = client.files().update(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileUpdateParams;\nimport io.imagekit.io.models.files.FileUpdateResponse;\nimport io.imagekit.io.models.files.UpdateFileRequest;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUpdateParams params = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build();\n FileUpdateResponse file = client.files().update(params);\n }\n}', }, kotlin: { method: 'files().update', @@ -578,7 +578,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.files().delete("fileId");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.files().delete("fileId");\n }\n}', }, kotlin: { method: 'files().delete', @@ -643,7 +643,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().copy', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileCopyParams;\nimport com.imagekit.api.models.files.FileCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileCopyParams params = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileCopyResponse response = client.files().copy(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileCopyParams;\nimport io.imagekit.io.models.files.FileCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileCopyParams params = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileCopyResponse response = client.files().copy(params);\n }\n}', }, kotlin: { method: 'files().copy', @@ -708,7 +708,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().move', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileMoveParams;\nimport com.imagekit.api.models.files.FileMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileMoveParams params = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileMoveResponse response = client.files().move(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileMoveParams;\nimport io.imagekit.io.models.files.FileMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileMoveParams params = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileMoveResponse response = client.files().move(params);\n }\n}', }, kotlin: { method: 'files().move', @@ -773,7 +773,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().rename', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileRenameParams;\nimport com.imagekit.api.models.files.FileRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileRenameParams params = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build();\n FileRenameResponse response = client.files().rename(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileRenameParams;\nimport io.imagekit.io.models.files.FileRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileRenameParams params = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build();\n FileRenameResponse response = client.files().rename(params);\n }\n}', }, kotlin: { method: 'files().rename', @@ -838,7 +838,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkDeleteParams;\nimport com.imagekit.api.models.files.bulk.BulkDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkDeleteParams params = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkDeleteResponse bulk = client.files().bulk().delete(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.bulk.BulkDeleteParams;\nimport io.imagekit.io.models.files.bulk.BulkDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkDeleteParams params = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkDeleteResponse bulk = client.files().bulk().delete(params);\n }\n}', }, kotlin: { method: 'files().bulk().delete', @@ -903,7 +903,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().addTags', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkAddTagsParams;\nimport com.imagekit.api.models.files.bulk.BulkAddTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkAddTagsParams params = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkAddTagsResponse response = client.files().bulk().addTags(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.bulk.BulkAddTagsParams;\nimport io.imagekit.io.models.files.bulk.BulkAddTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkAddTagsParams params = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkAddTagsResponse response = client.files().bulk().addTags(params);\n }\n}', }, kotlin: { method: 'files().bulk().addTags', @@ -968,7 +968,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().removeTags', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsParams;\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveTagsParams params = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkRemoveTagsResponse response = client.files().bulk().removeTags(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.bulk.BulkRemoveTagsParams;\nimport io.imagekit.io.models.files.bulk.BulkRemoveTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveTagsParams params = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkRemoveTagsResponse response = client.files().bulk().removeTags(params);\n }\n}', }, kotlin: { method: 'files().bulk().removeTags', @@ -1033,7 +1033,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().removeAiTags', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams;\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveAiTagsParams params = BulkRemoveAiTagsParams.builder()\n .aiTags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkRemoveAiTagsResponse response = client.files().bulk().removeAiTags(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams;\nimport io.imagekit.io.models.files.bulk.BulkRemoveAiTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveAiTagsParams params = BulkRemoveAiTagsParams.builder()\n .aiTags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkRemoveAiTagsResponse response = client.files().bulk().removeAiTags(params);\n }\n}', }, kotlin: { method: 'files().bulk().removeAiTags', @@ -1098,7 +1098,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().list', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.versions.VersionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List files = client.files().versions().list("fileId");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.File;\nimport io.imagekit.io.models.files.versions.VersionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List files = client.files().versions().list("fileId");\n }\n}', }, kotlin: { method: 'files().versions().list', @@ -1163,7 +1163,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.versions.VersionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionGetParams params = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().get(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.File;\nimport io.imagekit.io.models.files.versions.VersionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionGetParams params = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().get(params);\n }\n}', }, kotlin: { method: 'files().versions().get', @@ -1228,7 +1228,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.versions.VersionDeleteParams;\nimport com.imagekit.api.models.files.versions.VersionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionDeleteParams params = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n VersionDeleteResponse version = client.files().versions().delete(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.versions.VersionDeleteParams;\nimport io.imagekit.io.models.files.versions.VersionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionDeleteParams params = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n VersionDeleteResponse version = client.files().versions().delete(params);\n }\n}', }, kotlin: { method: 'files().versions().delete', @@ -1293,7 +1293,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().restore', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.versions.VersionRestoreParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionRestoreParams params = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().restore(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.File;\nimport io.imagekit.io.models.files.versions.VersionRestoreParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionRestoreParams params = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().restore(params);\n }\n}', }, kotlin: { method: 'files().versions().restore', @@ -1359,7 +1359,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().metadata().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.Metadata;\nimport com.imagekit.api.models.files.metadata.MetadataGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n Metadata metadata = client.files().metadata().get("fileId");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.Metadata;\nimport io.imagekit.io.models.files.metadata.MetadataGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n Metadata metadata = client.files().metadata().get("fileId");\n }\n}', }, kotlin: { method: 'files().metadata().get', @@ -1425,7 +1425,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().metadata().getFromUrl', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.Metadata;\nimport com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n MetadataGetFromUrlParams params = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build();\n Metadata metadata = client.files().metadata().getFromUrl(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.Metadata;\nimport io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n MetadataGetFromUrlParams params = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build();\n Metadata metadata = client.files().metadata().getFromUrl(params);\n }\n}', }, kotlin: { method: 'files().metadata().getFromUrl', @@ -1490,7 +1490,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().list', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List savedExtensions = client.savedExtensions().list();\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.SavedExtension;\nimport io.imagekit.io.models.savedextensions.SavedExtensionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List savedExtensions = client.savedExtensions().list();\n }\n}', }, kotlin: { method: 'savedExtensions().list', @@ -1560,7 +1560,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().create', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.ExtensionConfig;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtensionCreateParams params = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build();\n SavedExtension savedExtension = client.savedExtensions().create(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.ExtensionConfig;\nimport io.imagekit.io.models.SavedExtension;\nimport io.imagekit.io.models.savedextensions.SavedExtensionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtensionCreateParams params = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build();\n SavedExtension savedExtension = client.savedExtensions().create(params);\n }\n}', }, kotlin: { method: 'savedExtensions().create', @@ -1625,7 +1625,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().get("id");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.SavedExtension;\nimport io.imagekit.io.models.savedextensions.SavedExtensionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().get("id");\n }\n}', }, kotlin: { method: 'savedExtensions().get', @@ -1696,7 +1696,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().update', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().update("id");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.SavedExtension;\nimport io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().update("id");\n }\n}', }, kotlin: { method: 'savedExtensions().update', @@ -1759,7 +1759,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.savedExtensions().delete("id");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.savedextensions.SavedExtensionDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.savedExtensions().delete("id");\n }\n}', }, kotlin: { method: 'savedExtensions().delete', @@ -1832,7 +1832,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'assets().list', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.assets.AssetListParams;\nimport com.imagekit.api.models.assets.AssetListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List assets = client.assets().list();\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.assets.AssetListParams;\nimport io.imagekit.io.models.assets.AssetListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List assets = client.assets().list();\n }\n}', }, kotlin: { method: 'assets().list', @@ -1897,7 +1897,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'cache().invalidation().create', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateParams;\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationCreateParams params = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build();\n InvalidationCreateResponse invalidation = client.cache().invalidation().create(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.cache.invalidation.InvalidationCreateParams;\nimport io.imagekit.io.models.cache.invalidation.InvalidationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationCreateParams params = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build();\n InvalidationCreateResponse invalidation = client.cache().invalidation().create(params);\n }\n}', }, kotlin: { method: 'cache().invalidation().create', @@ -1961,7 +1961,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'cache().invalidation().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetParams;\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationGetResponse invalidation = client.cache().invalidation().get("requestId");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.cache.invalidation.InvalidationGetParams;\nimport io.imagekit.io.models.cache.invalidation.InvalidationGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationGetResponse invalidation = client.cache().invalidation().get("requestId");\n }\n}', }, kotlin: { method: 'cache().invalidation().get', @@ -2026,7 +2026,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().create', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderCreateParams;\nimport com.imagekit.api.models.folders.FolderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCreateParams params = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build();\n FolderCreateResponse folder = client.folders().create(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.folders.FolderCreateParams;\nimport io.imagekit.io.models.folders.FolderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCreateParams params = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build();\n FolderCreateResponse folder = client.folders().create(params);\n }\n}', }, kotlin: { method: 'folders().create', @@ -2091,7 +2091,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderDeleteParams;\nimport com.imagekit.api.models.folders.FolderDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderDeleteParams params = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build();\n FolderDeleteResponse folder = client.folders().delete(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.folders.FolderDeleteParams;\nimport io.imagekit.io.models.folders.FolderDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderDeleteParams params = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build();\n FolderDeleteResponse folder = client.folders().delete(params);\n }\n}', }, kotlin: { method: 'folders().delete', @@ -2156,7 +2156,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().copy', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderCopyParams;\nimport com.imagekit.api.models.folders.FolderCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCopyParams params = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderCopyResponse response = client.folders().copy(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.folders.FolderCopyParams;\nimport io.imagekit.io.models.folders.FolderCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCopyParams params = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderCopyResponse response = client.folders().copy(params);\n }\n}', }, kotlin: { method: 'folders().copy', @@ -2221,7 +2221,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().move', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderMoveParams;\nimport com.imagekit.api.models.folders.FolderMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderMoveParams params = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderMoveResponse response = client.folders().move(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.folders.FolderMoveParams;\nimport io.imagekit.io.models.folders.FolderMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderMoveParams params = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderMoveResponse response = client.folders().move(params);\n }\n}', }, kotlin: { method: 'folders().move', @@ -2286,7 +2286,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().rename', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderRenameParams;\nimport com.imagekit.api.models.folders.FolderRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderRenameParams params = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build();\n FolderRenameResponse response = client.folders().rename(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.folders.FolderRenameParams;\nimport io.imagekit.io.models.folders.FolderRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderRenameParams params = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build();\n FolderRenameResponse response = client.folders().rename(params);\n }\n}', }, kotlin: { method: 'folders().rename', @@ -2351,7 +2351,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().job().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.job.JobGetParams;\nimport com.imagekit.api.models.folders.job.JobGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n JobGetResponse job = client.folders().job().get("jobId");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.folders.job.JobGetParams;\nimport io.imagekit.io.models.folders.job.JobGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n JobGetResponse job = client.folders().job().get("jobId");\n }\n}', }, kotlin: { method: 'folders().job().get', @@ -2417,7 +2417,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().usage().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.usage.UsageGetParams;\nimport com.imagekit.api.models.accounts.usage.UsageGetResponse;\nimport java.time.LocalDate;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UsageGetParams params = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build();\n UsageGetResponse usage = client.accounts().usage().get(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.usage.UsageGetParams;\nimport io.imagekit.io.models.accounts.usage.UsageGetResponse;\nimport java.time.LocalDate;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UsageGetParams params = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build();\n UsageGetResponse usage = client.accounts().usage().get(params);\n }\n}', }, kotlin: { method: 'accounts().usage().get', @@ -2481,7 +2481,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().list', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginListParams;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List originResponses = client.accounts().origins().list();\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.origins.OriginListParams;\nimport io.imagekit.io.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List originResponses = client.accounts().origins().list();\n }\n}', }, kotlin: { method: 'accounts().origins().list', @@ -2546,7 +2546,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().create', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginCreateParams;\nimport com.imagekit.api.models.accounts.origins.OriginRequest;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.origins.OriginCreateParams;\nimport io.imagekit.io.models.accounts.origins.OriginRequest;\nimport io.imagekit.io.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}', }, kotlin: { method: 'accounts().origins().create', @@ -2610,7 +2610,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginGetParams;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginResponse originResponse = client.accounts().origins().get("id");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.origins.OriginGetParams;\nimport io.imagekit.io.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginResponse originResponse = client.accounts().origins().get("id");\n }\n}', }, kotlin: { method: 'accounts().origins().get', @@ -2676,7 +2676,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().update', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginRequest;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\nimport com.imagekit.api.models.accounts.origins.OriginUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginUpdateParams params = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build();\n OriginResponse originResponse = client.accounts().origins().update(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.origins.OriginRequest;\nimport io.imagekit.io.models.accounts.origins.OriginResponse;\nimport io.imagekit.io.models.accounts.origins.OriginUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginUpdateParams params = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build();\n OriginResponse originResponse = client.accounts().origins().update(params);\n }\n}', }, kotlin: { method: 'accounts().origins().update', @@ -2740,7 +2740,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().origins().delete("id");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.origins.OriginDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().origins().delete("id");\n }\n}', }, kotlin: { method: 'accounts().origins().delete', @@ -2805,7 +2805,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().list', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List urlEndpointResponses = client.accounts().urlEndpoints().list();\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointListParams;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List urlEndpointResponses = client.accounts().urlEndpoints().list();\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().list', @@ -2876,7 +2876,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().create', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().create', @@ -2942,7 +2942,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get("id");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get("id");\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().get', @@ -3014,7 +3014,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().update', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointUpdateParams params = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().update(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointUpdateParams params = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().update(params);\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().update', @@ -3078,7 +3078,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().urlEndpoints().delete("id");\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().urlEndpoints().delete("id");\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().delete', @@ -3165,7 +3165,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'beta().v2().files().upload', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.beta.v2.files.FileUploadParams;\nimport com.imagekit.api.models.beta.v2.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.beta().v2().files().upload(params);\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.beta.v2.files.FileUploadParams;\nimport io.imagekit.io.models.beta.v2.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.beta().v2().files().upload(params);\n }\n}', }, kotlin: { method: 'beta().v2().files().upload', @@ -3217,7 +3217,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ }, java: { example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.webhooks.WebhookUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unwrap();\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.webhooks.WebhookUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unwrap();\n }\n}', }, kotlin: { example: @@ -3269,7 +3269,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ }, java: { example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.webhooks.WebhookUnsafeUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unsafeUnwrap();\n }\n}', + 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.webhooks.WebhookUnsafeUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unsafeUnwrap();\n }\n}', }, kotlin: { example: @@ -3328,12 +3328,12 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'java', content: - '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport com.imagekit.api.client.ImageKitClientAsync;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.MultipartField;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport com.imagekit.api.core.http.Headers;\nimport com.imagekit.api.core.http.HttpResponseFor;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.JsonMissing;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport com.imagekit.api.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit.io/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit.io/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit.io/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit.io/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit.io/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit.io:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit.io\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.io.client.ImageKitClientAsync;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt):\n\n```java\nimport io.imagekit.io.core.MultipartField;\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.io.core.http.Headers;\nimport io.imagekit.io.core.http.HttpResponseFor;\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.io.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.io.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.io.core.JsonValue;\nimport io.imagekit.io.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.io.core.JsonValue;\nimport io.imagekit.io.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.io.core.JsonValue;\nimport io.imagekit.io.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.io.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt):\n\n```java\nimport io.imagekit.io.core.JsonMissing;\nimport io.imagekit.io.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.io.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.io.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.io.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.io.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', }, { language: 'kotlin', content: - '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\nThe Image Kit Kotlin SDK is similar to the Image Kit Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', }, { language: 'csharp', From 03a3952e171bec93bc9efcd6897f33b5af3e2243 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 05:53:17 +0000 Subject: [PATCH 10/36] feat(api): manual updates --- .stats.yml | 2 +- packages/mcp-server/src/local-docs-search.ts | 100 +++++++++---------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/.stats.yml b/.stats.yml index 71485510..7ae635fc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: ef918f7e878d4168a07e867607eb68ea +config_hash: 85ee7f056e5c05338bd9b7a7abb33c6e diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 33f9211d..5180b2fe 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -91,7 +91,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().create', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build();\n CustomMetadataField customMetadataField = client.customMetadataFields().create(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build();\n CustomMetadataField customMetadataField = client.customMetadataFields().create(params);\n }\n}', }, kotlin: { method: 'customMetadataFields().create', @@ -157,7 +157,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().list', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List customMetadataFields = client.customMetadataFields().list();\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List customMetadataFields = client.customMetadataFields().list();\n }\n}', }, kotlin: { method: 'customMetadataFields().list', @@ -226,7 +226,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().update', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataField customMetadataField = client.customMetadataFields().update("id");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataField customMetadataField = client.customMetadataFields().update("id");\n }\n}', }, kotlin: { method: 'customMetadataFields().update', @@ -291,7 +291,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().delete', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteParams;\nimport io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldDeleteResponse customMetadataField = client.customMetadataFields().delete("id");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldDeleteResponse customMetadataField = client.customMetadataFields().delete("id");\n }\n}', }, kotlin: { method: 'customMetadataFields().delete', @@ -381,7 +381,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().upload', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.files().upload(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.files().upload(params);\n }\n}', }, kotlin: { method: 'files().upload', @@ -447,7 +447,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().get', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.File;\nimport io.imagekit.io.models.files.FileGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n File file = client.files().get("fileId");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.FileGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n File file = client.files().get("fileId");\n }\n}', }, kotlin: { method: 'files().get', @@ -514,7 +514,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().update', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileUpdateParams;\nimport io.imagekit.io.models.files.FileUpdateResponse;\nimport io.imagekit.io.models.files.UpdateFileRequest;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUpdateParams params = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build();\n FileUpdateResponse file = client.files().update(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUpdateParams;\nimport com.imagekit.api.models.files.FileUpdateResponse;\nimport com.imagekit.api.models.files.UpdateFileRequest;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUpdateParams params = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build();\n FileUpdateResponse file = client.files().update(params);\n }\n}', }, kotlin: { method: 'files().update', @@ -578,7 +578,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().delete', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.files().delete("fileId");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.files().delete("fileId");\n }\n}', }, kotlin: { method: 'files().delete', @@ -643,7 +643,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().copy', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileCopyParams;\nimport io.imagekit.io.models.files.FileCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileCopyParams params = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileCopyResponse response = client.files().copy(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileCopyParams;\nimport com.imagekit.api.models.files.FileCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileCopyParams params = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileCopyResponse response = client.files().copy(params);\n }\n}', }, kotlin: { method: 'files().copy', @@ -708,7 +708,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().move', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileMoveParams;\nimport io.imagekit.io.models.files.FileMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileMoveParams params = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileMoveResponse response = client.files().move(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileMoveParams;\nimport com.imagekit.api.models.files.FileMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileMoveParams params = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileMoveResponse response = client.files().move(params);\n }\n}', }, kotlin: { method: 'files().move', @@ -773,7 +773,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().rename', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileRenameParams;\nimport io.imagekit.io.models.files.FileRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileRenameParams params = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build();\n FileRenameResponse response = client.files().rename(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileRenameParams;\nimport com.imagekit.api.models.files.FileRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileRenameParams params = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build();\n FileRenameResponse response = client.files().rename(params);\n }\n}', }, kotlin: { method: 'files().rename', @@ -838,7 +838,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().delete', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.bulk.BulkDeleteParams;\nimport io.imagekit.io.models.files.bulk.BulkDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkDeleteParams params = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkDeleteResponse bulk = client.files().bulk().delete(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkDeleteParams;\nimport com.imagekit.api.models.files.bulk.BulkDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkDeleteParams params = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkDeleteResponse bulk = client.files().bulk().delete(params);\n }\n}', }, kotlin: { method: 'files().bulk().delete', @@ -903,7 +903,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().addTags', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.bulk.BulkAddTagsParams;\nimport io.imagekit.io.models.files.bulk.BulkAddTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkAddTagsParams params = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkAddTagsResponse response = client.files().bulk().addTags(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkAddTagsParams;\nimport com.imagekit.api.models.files.bulk.BulkAddTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkAddTagsParams params = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkAddTagsResponse response = client.files().bulk().addTags(params);\n }\n}', }, kotlin: { method: 'files().bulk().addTags', @@ -968,7 +968,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().removeTags', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.bulk.BulkRemoveTagsParams;\nimport io.imagekit.io.models.files.bulk.BulkRemoveTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveTagsParams params = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkRemoveTagsResponse response = client.files().bulk().removeTags(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsParams;\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveTagsParams params = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkRemoveTagsResponse response = client.files().bulk().removeTags(params);\n }\n}', }, kotlin: { method: 'files().bulk().removeTags', @@ -1033,7 +1033,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().removeAiTags', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams;\nimport io.imagekit.io.models.files.bulk.BulkRemoveAiTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveAiTagsParams params = BulkRemoveAiTagsParams.builder()\n .aiTags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkRemoveAiTagsResponse response = client.files().bulk().removeAiTags(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams;\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveAiTagsParams params = BulkRemoveAiTagsParams.builder()\n .aiTags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkRemoveAiTagsResponse response = client.files().bulk().removeAiTags(params);\n }\n}', }, kotlin: { method: 'files().bulk().removeAiTags', @@ -1098,7 +1098,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().list', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.File;\nimport io.imagekit.io.models.files.versions.VersionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List files = client.files().versions().list("fileId");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.versions.VersionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List files = client.files().versions().list("fileId");\n }\n}', }, kotlin: { method: 'files().versions().list', @@ -1163,7 +1163,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().get', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.File;\nimport io.imagekit.io.models.files.versions.VersionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionGetParams params = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().get(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.versions.VersionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionGetParams params = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().get(params);\n }\n}', }, kotlin: { method: 'files().versions().get', @@ -1228,7 +1228,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().delete', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.versions.VersionDeleteParams;\nimport io.imagekit.io.models.files.versions.VersionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionDeleteParams params = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n VersionDeleteResponse version = client.files().versions().delete(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.versions.VersionDeleteParams;\nimport com.imagekit.api.models.files.versions.VersionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionDeleteParams params = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n VersionDeleteResponse version = client.files().versions().delete(params);\n }\n}', }, kotlin: { method: 'files().versions().delete', @@ -1293,7 +1293,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().restore', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.File;\nimport io.imagekit.io.models.files.versions.VersionRestoreParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionRestoreParams params = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().restore(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.versions.VersionRestoreParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionRestoreParams params = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().restore(params);\n }\n}', }, kotlin: { method: 'files().versions().restore', @@ -1359,7 +1359,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().metadata().get', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.Metadata;\nimport io.imagekit.io.models.files.metadata.MetadataGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n Metadata metadata = client.files().metadata().get("fileId");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.Metadata;\nimport com.imagekit.api.models.files.metadata.MetadataGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n Metadata metadata = client.files().metadata().get("fileId");\n }\n}', }, kotlin: { method: 'files().metadata().get', @@ -1425,7 +1425,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().metadata().getFromUrl', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.Metadata;\nimport io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n MetadataGetFromUrlParams params = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build();\n Metadata metadata = client.files().metadata().getFromUrl(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.Metadata;\nimport com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n MetadataGetFromUrlParams params = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build();\n Metadata metadata = client.files().metadata().getFromUrl(params);\n }\n}', }, kotlin: { method: 'files().metadata().getFromUrl', @@ -1490,7 +1490,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().list', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.SavedExtension;\nimport io.imagekit.io.models.savedextensions.SavedExtensionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List savedExtensions = client.savedExtensions().list();\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List savedExtensions = client.savedExtensions().list();\n }\n}', }, kotlin: { method: 'savedExtensions().list', @@ -1560,7 +1560,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().create', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.ExtensionConfig;\nimport io.imagekit.io.models.SavedExtension;\nimport io.imagekit.io.models.savedextensions.SavedExtensionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtensionCreateParams params = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build();\n SavedExtension savedExtension = client.savedExtensions().create(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.ExtensionConfig;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtensionCreateParams params = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build();\n SavedExtension savedExtension = client.savedExtensions().create(params);\n }\n}', }, kotlin: { method: 'savedExtensions().create', @@ -1625,7 +1625,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().get', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.SavedExtension;\nimport io.imagekit.io.models.savedextensions.SavedExtensionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().get("id");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().get("id");\n }\n}', }, kotlin: { method: 'savedExtensions().get', @@ -1696,7 +1696,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().update', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.SavedExtension;\nimport io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().update("id");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().update("id");\n }\n}', }, kotlin: { method: 'savedExtensions().update', @@ -1759,7 +1759,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().delete', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.savedextensions.SavedExtensionDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.savedExtensions().delete("id");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.savedExtensions().delete("id");\n }\n}', }, kotlin: { method: 'savedExtensions().delete', @@ -1832,7 +1832,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'assets().list', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.assets.AssetListParams;\nimport io.imagekit.io.models.assets.AssetListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List assets = client.assets().list();\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.assets.AssetListParams;\nimport com.imagekit.api.models.assets.AssetListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List assets = client.assets().list();\n }\n}', }, kotlin: { method: 'assets().list', @@ -1897,7 +1897,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'cache().invalidation().create', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.cache.invalidation.InvalidationCreateParams;\nimport io.imagekit.io.models.cache.invalidation.InvalidationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationCreateParams params = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build();\n InvalidationCreateResponse invalidation = client.cache().invalidation().create(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateParams;\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationCreateParams params = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build();\n InvalidationCreateResponse invalidation = client.cache().invalidation().create(params);\n }\n}', }, kotlin: { method: 'cache().invalidation().create', @@ -1961,7 +1961,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'cache().invalidation().get', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.cache.invalidation.InvalidationGetParams;\nimport io.imagekit.io.models.cache.invalidation.InvalidationGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationGetResponse invalidation = client.cache().invalidation().get("requestId");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetParams;\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationGetResponse invalidation = client.cache().invalidation().get("requestId");\n }\n}', }, kotlin: { method: 'cache().invalidation().get', @@ -2026,7 +2026,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().create', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.folders.FolderCreateParams;\nimport io.imagekit.io.models.folders.FolderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCreateParams params = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build();\n FolderCreateResponse folder = client.folders().create(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderCreateParams;\nimport com.imagekit.api.models.folders.FolderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCreateParams params = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build();\n FolderCreateResponse folder = client.folders().create(params);\n }\n}', }, kotlin: { method: 'folders().create', @@ -2091,7 +2091,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().delete', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.folders.FolderDeleteParams;\nimport io.imagekit.io.models.folders.FolderDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderDeleteParams params = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build();\n FolderDeleteResponse folder = client.folders().delete(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderDeleteParams;\nimport com.imagekit.api.models.folders.FolderDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderDeleteParams params = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build();\n FolderDeleteResponse folder = client.folders().delete(params);\n }\n}', }, kotlin: { method: 'folders().delete', @@ -2156,7 +2156,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().copy', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.folders.FolderCopyParams;\nimport io.imagekit.io.models.folders.FolderCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCopyParams params = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderCopyResponse response = client.folders().copy(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderCopyParams;\nimport com.imagekit.api.models.folders.FolderCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCopyParams params = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderCopyResponse response = client.folders().copy(params);\n }\n}', }, kotlin: { method: 'folders().copy', @@ -2221,7 +2221,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().move', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.folders.FolderMoveParams;\nimport io.imagekit.io.models.folders.FolderMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderMoveParams params = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderMoveResponse response = client.folders().move(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderMoveParams;\nimport com.imagekit.api.models.folders.FolderMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderMoveParams params = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderMoveResponse response = client.folders().move(params);\n }\n}', }, kotlin: { method: 'folders().move', @@ -2286,7 +2286,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().rename', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.folders.FolderRenameParams;\nimport io.imagekit.io.models.folders.FolderRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderRenameParams params = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build();\n FolderRenameResponse response = client.folders().rename(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderRenameParams;\nimport com.imagekit.api.models.folders.FolderRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderRenameParams params = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build();\n FolderRenameResponse response = client.folders().rename(params);\n }\n}', }, kotlin: { method: 'folders().rename', @@ -2351,7 +2351,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().job().get', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.folders.job.JobGetParams;\nimport io.imagekit.io.models.folders.job.JobGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n JobGetResponse job = client.folders().job().get("jobId");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.job.JobGetParams;\nimport com.imagekit.api.models.folders.job.JobGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n JobGetResponse job = client.folders().job().get("jobId");\n }\n}', }, kotlin: { method: 'folders().job().get', @@ -2417,7 +2417,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().usage().get', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.usage.UsageGetParams;\nimport io.imagekit.io.models.accounts.usage.UsageGetResponse;\nimport java.time.LocalDate;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UsageGetParams params = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build();\n UsageGetResponse usage = client.accounts().usage().get(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.usage.UsageGetParams;\nimport com.imagekit.api.models.accounts.usage.UsageGetResponse;\nimport java.time.LocalDate;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UsageGetParams params = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build();\n UsageGetResponse usage = client.accounts().usage().get(params);\n }\n}', }, kotlin: { method: 'accounts().usage().get', @@ -2481,7 +2481,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().list', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.origins.OriginListParams;\nimport io.imagekit.io.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List originResponses = client.accounts().origins().list();\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginListParams;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List originResponses = client.accounts().origins().list();\n }\n}', }, kotlin: { method: 'accounts().origins().list', @@ -2546,7 +2546,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().create', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.origins.OriginCreateParams;\nimport io.imagekit.io.models.accounts.origins.OriginRequest;\nimport io.imagekit.io.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginCreateParams;\nimport com.imagekit.api.models.accounts.origins.OriginRequest;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}', }, kotlin: { method: 'accounts().origins().create', @@ -2610,7 +2610,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().get', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.origins.OriginGetParams;\nimport io.imagekit.io.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginResponse originResponse = client.accounts().origins().get("id");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginGetParams;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginResponse originResponse = client.accounts().origins().get("id");\n }\n}', }, kotlin: { method: 'accounts().origins().get', @@ -2676,7 +2676,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().update', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.origins.OriginRequest;\nimport io.imagekit.io.models.accounts.origins.OriginResponse;\nimport io.imagekit.io.models.accounts.origins.OriginUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginUpdateParams params = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build();\n OriginResponse originResponse = client.accounts().origins().update(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginRequest;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\nimport com.imagekit.api.models.accounts.origins.OriginUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginUpdateParams params = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build();\n OriginResponse originResponse = client.accounts().origins().update(params);\n }\n}', }, kotlin: { method: 'accounts().origins().update', @@ -2740,7 +2740,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().delete', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.origins.OriginDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().origins().delete("id");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().origins().delete("id");\n }\n}', }, kotlin: { method: 'accounts().origins().delete', @@ -2805,7 +2805,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().list', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointListParams;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List urlEndpointResponses = client.accounts().urlEndpoints().list();\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List urlEndpointResponses = client.accounts().urlEndpoints().list();\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().list', @@ -2876,7 +2876,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().create', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().create', @@ -2942,7 +2942,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().get', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get("id");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get("id");\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().get', @@ -3014,7 +3014,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().update', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointUpdateParams params = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().update(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointUpdateParams params = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().update(params);\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().update', @@ -3078,7 +3078,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().delete', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.accounts.urlendpoints.UrlEndpointDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().urlEndpoints().delete("id");\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().urlEndpoints().delete("id");\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().delete', @@ -3165,7 +3165,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'beta().v2().files().upload', example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.beta.v2.files.FileUploadParams;\nimport io.imagekit.io.models.beta.v2.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.beta().v2().files().upload(params);\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.beta.v2.files.FileUploadParams;\nimport com.imagekit.api.models.beta.v2.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.beta().v2().files().upload(params);\n }\n}', }, kotlin: { method: 'beta().v2().files().upload', @@ -3217,7 +3217,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ }, java: { example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.webhooks.WebhookUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unwrap();\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.webhooks.WebhookUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unwrap();\n }\n}', }, kotlin: { example: @@ -3269,7 +3269,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ }, java: { example: - 'package io.imagekit.io.example;\n\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.webhooks.WebhookUnsafeUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unsafeUnwrap();\n }\n}', + 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.webhooks.WebhookUnsafeUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unsafeUnwrap();\n }\n}', }, kotlin: { example: @@ -3328,7 +3328,7 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'java', content: - '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit.io/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit.io/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit.io/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit.io/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit.io/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit.io:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit.io\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.io.client.ImageKitClientAsync;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt):\n\n```java\nimport io.imagekit.io.core.MultipartField;\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.io.core.http.Headers;\nimport io.imagekit.io.core.http.HttpResponseFor;\nimport io.imagekit.io.models.files.FileUploadParams;\nimport io.imagekit.io.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.io.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.io.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.io.core.JsonValue;\nimport io.imagekit.io.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.io.core.JsonValue;\nimport io.imagekit.io.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.io.core.JsonValue;\nimport io.imagekit.io.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.io.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt):\n\n```java\nimport io.imagekit.io.core.JsonMissing;\nimport io.imagekit.io.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.io.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.io.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.io.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.io.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.io.client.ImageKitClient;\nimport io.imagekit.io.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport com.imagekit.api.client.ImageKitClientAsync;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.MultipartField;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport com.imagekit.api.core.http.Headers;\nimport com.imagekit.api.core.http.HttpResponseFor;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.JsonMissing;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport com.imagekit.api.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', }, { language: 'kotlin', From e6c68dd1183dc12376ac54ef11da3a0f20487893 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 06:58:18 +0000 Subject: [PATCH 11/36] feat(api): manual updates --- .stats.yml | 2 +- packages/mcp-server/src/local-docs-search.ts | 100 +++++++++---------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7ae635fc..8624958a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: 85ee7f056e5c05338bd9b7a7abb33c6e +config_hash: 4e6bdc90056ab9bddbeb207bd720cf53 diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 5180b2fe..a3ba0de3 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -91,7 +91,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().create', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build();\n CustomMetadataField customMetadataField = client.customMetadataFields().create(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build();\n CustomMetadataField customMetadataField = client.customMetadataFields().create(params);\n }\n}', }, kotlin: { method: 'customMetadataFields().create', @@ -157,7 +157,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().list', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List customMetadataFields = client.customMetadataFields().list();\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List customMetadataFields = client.customMetadataFields().list();\n }\n}', }, kotlin: { method: 'customMetadataFields().list', @@ -226,7 +226,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().update', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataField customMetadataField = client.customMetadataFields().update("id");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataField customMetadataField = client.customMetadataFields().update("id");\n }\n}', }, kotlin: { method: 'customMetadataFields().update', @@ -291,7 +291,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams;\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldDeleteResponse customMetadataField = client.customMetadataFields().delete("id");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldDeleteResponse customMetadataField = client.customMetadataFields().delete("id");\n }\n}', }, kotlin: { method: 'customMetadataFields().delete', @@ -381,7 +381,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().upload', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.files().upload(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.files().upload(params);\n }\n}', }, kotlin: { method: 'files().upload', @@ -447,7 +447,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.FileGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n File file = client.files().get("fileId");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.File;\nimport io.imagekit.api.models.files.FileGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n File file = client.files().get("fileId");\n }\n}', }, kotlin: { method: 'files().get', @@ -514,7 +514,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().update', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUpdateParams;\nimport com.imagekit.api.models.files.FileUpdateResponse;\nimport com.imagekit.api.models.files.UpdateFileRequest;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUpdateParams params = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build();\n FileUpdateResponse file = client.files().update(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileUpdateParams;\nimport io.imagekit.api.models.files.FileUpdateResponse;\nimport io.imagekit.api.models.files.UpdateFileRequest;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUpdateParams params = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build();\n FileUpdateResponse file = client.files().update(params);\n }\n}', }, kotlin: { method: 'files().update', @@ -578,7 +578,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.files().delete("fileId");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.files().delete("fileId");\n }\n}', }, kotlin: { method: 'files().delete', @@ -643,7 +643,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().copy', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileCopyParams;\nimport com.imagekit.api.models.files.FileCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileCopyParams params = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileCopyResponse response = client.files().copy(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileCopyParams;\nimport io.imagekit.api.models.files.FileCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileCopyParams params = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileCopyResponse response = client.files().copy(params);\n }\n}', }, kotlin: { method: 'files().copy', @@ -708,7 +708,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().move', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileMoveParams;\nimport com.imagekit.api.models.files.FileMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileMoveParams params = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileMoveResponse response = client.files().move(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileMoveParams;\nimport io.imagekit.api.models.files.FileMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileMoveParams params = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileMoveResponse response = client.files().move(params);\n }\n}', }, kotlin: { method: 'files().move', @@ -773,7 +773,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().rename', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileRenameParams;\nimport com.imagekit.api.models.files.FileRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileRenameParams params = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build();\n FileRenameResponse response = client.files().rename(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileRenameParams;\nimport io.imagekit.api.models.files.FileRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileRenameParams params = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build();\n FileRenameResponse response = client.files().rename(params);\n }\n}', }, kotlin: { method: 'files().rename', @@ -838,7 +838,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkDeleteParams;\nimport com.imagekit.api.models.files.bulk.BulkDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkDeleteParams params = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkDeleteResponse bulk = client.files().bulk().delete(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.bulk.BulkDeleteParams;\nimport io.imagekit.api.models.files.bulk.BulkDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkDeleteParams params = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkDeleteResponse bulk = client.files().bulk().delete(params);\n }\n}', }, kotlin: { method: 'files().bulk().delete', @@ -903,7 +903,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().addTags', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkAddTagsParams;\nimport com.imagekit.api.models.files.bulk.BulkAddTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkAddTagsParams params = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkAddTagsResponse response = client.files().bulk().addTags(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.bulk.BulkAddTagsParams;\nimport io.imagekit.api.models.files.bulk.BulkAddTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkAddTagsParams params = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkAddTagsResponse response = client.files().bulk().addTags(params);\n }\n}', }, kotlin: { method: 'files().bulk().addTags', @@ -968,7 +968,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().removeTags', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsParams;\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveTagsParams params = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkRemoveTagsResponse response = client.files().bulk().removeTags(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.bulk.BulkRemoveTagsParams;\nimport io.imagekit.api.models.files.bulk.BulkRemoveTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveTagsParams params = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkRemoveTagsResponse response = client.files().bulk().removeTags(params);\n }\n}', }, kotlin: { method: 'files().bulk().removeTags', @@ -1033,7 +1033,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().removeAiTags', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams;\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveAiTagsParams params = BulkRemoveAiTagsParams.builder()\n .aiTags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkRemoveAiTagsResponse response = client.files().bulk().removeAiTags(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams;\nimport io.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveAiTagsParams params = BulkRemoveAiTagsParams.builder()\n .aiTags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkRemoveAiTagsResponse response = client.files().bulk().removeAiTags(params);\n }\n}', }, kotlin: { method: 'files().bulk().removeAiTags', @@ -1098,7 +1098,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().list', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.versions.VersionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List files = client.files().versions().list("fileId");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.File;\nimport io.imagekit.api.models.files.versions.VersionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List files = client.files().versions().list("fileId");\n }\n}', }, kotlin: { method: 'files().versions().list', @@ -1163,7 +1163,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.versions.VersionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionGetParams params = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().get(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.File;\nimport io.imagekit.api.models.files.versions.VersionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionGetParams params = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().get(params);\n }\n}', }, kotlin: { method: 'files().versions().get', @@ -1228,7 +1228,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.versions.VersionDeleteParams;\nimport com.imagekit.api.models.files.versions.VersionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionDeleteParams params = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n VersionDeleteResponse version = client.files().versions().delete(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.versions.VersionDeleteParams;\nimport io.imagekit.api.models.files.versions.VersionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionDeleteParams params = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n VersionDeleteResponse version = client.files().versions().delete(params);\n }\n}', }, kotlin: { method: 'files().versions().delete', @@ -1293,7 +1293,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().restore', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.File;\nimport com.imagekit.api.models.files.versions.VersionRestoreParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionRestoreParams params = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().restore(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.File;\nimport io.imagekit.api.models.files.versions.VersionRestoreParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionRestoreParams params = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().restore(params);\n }\n}', }, kotlin: { method: 'files().versions().restore', @@ -1359,7 +1359,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().metadata().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.Metadata;\nimport com.imagekit.api.models.files.metadata.MetadataGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n Metadata metadata = client.files().metadata().get("fileId");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.Metadata;\nimport io.imagekit.api.models.files.metadata.MetadataGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n Metadata metadata = client.files().metadata().get("fileId");\n }\n}', }, kotlin: { method: 'files().metadata().get', @@ -1425,7 +1425,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().metadata().getFromUrl', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.Metadata;\nimport com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n MetadataGetFromUrlParams params = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build();\n Metadata metadata = client.files().metadata().getFromUrl(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.Metadata;\nimport io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n MetadataGetFromUrlParams params = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build();\n Metadata metadata = client.files().metadata().getFromUrl(params);\n }\n}', }, kotlin: { method: 'files().metadata().getFromUrl', @@ -1490,7 +1490,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().list', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List savedExtensions = client.savedExtensions().list();\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.SavedExtension;\nimport io.imagekit.api.models.savedextensions.SavedExtensionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List savedExtensions = client.savedExtensions().list();\n }\n}', }, kotlin: { method: 'savedExtensions().list', @@ -1560,7 +1560,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().create', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.ExtensionConfig;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtensionCreateParams params = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build();\n SavedExtension savedExtension = client.savedExtensions().create(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.ExtensionConfig;\nimport io.imagekit.api.models.SavedExtension;\nimport io.imagekit.api.models.savedextensions.SavedExtensionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtensionCreateParams params = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build();\n SavedExtension savedExtension = client.savedExtensions().create(params);\n }\n}', }, kotlin: { method: 'savedExtensions().create', @@ -1625,7 +1625,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().get("id");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.SavedExtension;\nimport io.imagekit.api.models.savedextensions.SavedExtensionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().get("id");\n }\n}', }, kotlin: { method: 'savedExtensions().get', @@ -1696,7 +1696,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().update', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.SavedExtension;\nimport com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().update("id");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.SavedExtension;\nimport io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().update("id");\n }\n}', }, kotlin: { method: 'savedExtensions().update', @@ -1759,7 +1759,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.savedExtensions().delete("id");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.savedextensions.SavedExtensionDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.savedExtensions().delete("id");\n }\n}', }, kotlin: { method: 'savedExtensions().delete', @@ -1832,7 +1832,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'assets().list', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.assets.AssetListParams;\nimport com.imagekit.api.models.assets.AssetListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List assets = client.assets().list();\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.assets.AssetListParams;\nimport io.imagekit.api.models.assets.AssetListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List assets = client.assets().list();\n }\n}', }, kotlin: { method: 'assets().list', @@ -1897,7 +1897,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'cache().invalidation().create', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateParams;\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationCreateParams params = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build();\n InvalidationCreateResponse invalidation = client.cache().invalidation().create(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.cache.invalidation.InvalidationCreateParams;\nimport io.imagekit.api.models.cache.invalidation.InvalidationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationCreateParams params = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build();\n InvalidationCreateResponse invalidation = client.cache().invalidation().create(params);\n }\n}', }, kotlin: { method: 'cache().invalidation().create', @@ -1961,7 +1961,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'cache().invalidation().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetParams;\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationGetResponse invalidation = client.cache().invalidation().get("requestId");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.cache.invalidation.InvalidationGetParams;\nimport io.imagekit.api.models.cache.invalidation.InvalidationGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationGetResponse invalidation = client.cache().invalidation().get("requestId");\n }\n}', }, kotlin: { method: 'cache().invalidation().get', @@ -2026,7 +2026,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().create', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderCreateParams;\nimport com.imagekit.api.models.folders.FolderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCreateParams params = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build();\n FolderCreateResponse folder = client.folders().create(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.folders.FolderCreateParams;\nimport io.imagekit.api.models.folders.FolderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCreateParams params = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build();\n FolderCreateResponse folder = client.folders().create(params);\n }\n}', }, kotlin: { method: 'folders().create', @@ -2091,7 +2091,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderDeleteParams;\nimport com.imagekit.api.models.folders.FolderDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderDeleteParams params = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build();\n FolderDeleteResponse folder = client.folders().delete(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.folders.FolderDeleteParams;\nimport io.imagekit.api.models.folders.FolderDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderDeleteParams params = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build();\n FolderDeleteResponse folder = client.folders().delete(params);\n }\n}', }, kotlin: { method: 'folders().delete', @@ -2156,7 +2156,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().copy', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderCopyParams;\nimport com.imagekit.api.models.folders.FolderCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCopyParams params = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderCopyResponse response = client.folders().copy(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.folders.FolderCopyParams;\nimport io.imagekit.api.models.folders.FolderCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCopyParams params = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderCopyResponse response = client.folders().copy(params);\n }\n}', }, kotlin: { method: 'folders().copy', @@ -2221,7 +2221,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().move', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderMoveParams;\nimport com.imagekit.api.models.folders.FolderMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderMoveParams params = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderMoveResponse response = client.folders().move(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.folders.FolderMoveParams;\nimport io.imagekit.api.models.folders.FolderMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderMoveParams params = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderMoveResponse response = client.folders().move(params);\n }\n}', }, kotlin: { method: 'folders().move', @@ -2286,7 +2286,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().rename', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.FolderRenameParams;\nimport com.imagekit.api.models.folders.FolderRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderRenameParams params = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build();\n FolderRenameResponse response = client.folders().rename(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.folders.FolderRenameParams;\nimport io.imagekit.api.models.folders.FolderRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderRenameParams params = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build();\n FolderRenameResponse response = client.folders().rename(params);\n }\n}', }, kotlin: { method: 'folders().rename', @@ -2351,7 +2351,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().job().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.folders.job.JobGetParams;\nimport com.imagekit.api.models.folders.job.JobGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n JobGetResponse job = client.folders().job().get("jobId");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.folders.job.JobGetParams;\nimport io.imagekit.api.models.folders.job.JobGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n JobGetResponse job = client.folders().job().get("jobId");\n }\n}', }, kotlin: { method: 'folders().job().get', @@ -2417,7 +2417,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().usage().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.usage.UsageGetParams;\nimport com.imagekit.api.models.accounts.usage.UsageGetResponse;\nimport java.time.LocalDate;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UsageGetParams params = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build();\n UsageGetResponse usage = client.accounts().usage().get(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.usage.UsageGetParams;\nimport io.imagekit.api.models.accounts.usage.UsageGetResponse;\nimport java.time.LocalDate;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UsageGetParams params = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build();\n UsageGetResponse usage = client.accounts().usage().get(params);\n }\n}', }, kotlin: { method: 'accounts().usage().get', @@ -2481,7 +2481,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().list', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginListParams;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List originResponses = client.accounts().origins().list();\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.origins.OriginListParams;\nimport io.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List originResponses = client.accounts().origins().list();\n }\n}', }, kotlin: { method: 'accounts().origins().list', @@ -2546,7 +2546,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().create', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginCreateParams;\nimport com.imagekit.api.models.accounts.origins.OriginRequest;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.origins.OriginCreateParams;\nimport io.imagekit.api.models.accounts.origins.OriginRequest;\nimport io.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}', }, kotlin: { method: 'accounts().origins().create', @@ -2610,7 +2610,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginGetParams;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginResponse originResponse = client.accounts().origins().get("id");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.origins.OriginGetParams;\nimport io.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginResponse originResponse = client.accounts().origins().get("id");\n }\n}', }, kotlin: { method: 'accounts().origins().get', @@ -2676,7 +2676,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().update', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginRequest;\nimport com.imagekit.api.models.accounts.origins.OriginResponse;\nimport com.imagekit.api.models.accounts.origins.OriginUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginUpdateParams params = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build();\n OriginResponse originResponse = client.accounts().origins().update(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.origins.OriginRequest;\nimport io.imagekit.api.models.accounts.origins.OriginResponse;\nimport io.imagekit.api.models.accounts.origins.OriginUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginUpdateParams params = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build();\n OriginResponse originResponse = client.accounts().origins().update(params);\n }\n}', }, kotlin: { method: 'accounts().origins().update', @@ -2740,7 +2740,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.origins.OriginDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().origins().delete("id");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.origins.OriginDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().origins().delete("id");\n }\n}', }, kotlin: { method: 'accounts().origins().delete', @@ -2805,7 +2805,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().list', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List urlEndpointResponses = client.accounts().urlEndpoints().list();\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List urlEndpointResponses = client.accounts().urlEndpoints().list();\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().list', @@ -2876,7 +2876,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().create', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().create', @@ -2942,7 +2942,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().get', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get("id");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get("id");\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().get', @@ -3014,7 +3014,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().update', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointUpdateParams params = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().update(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointUpdateParams params = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().update(params);\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().update', @@ -3078,7 +3078,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().delete', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().urlEndpoints().delete("id");\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().urlEndpoints().delete("id");\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().delete', @@ -3165,7 +3165,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'beta().v2().files().upload', example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.beta.v2.files.FileUploadParams;\nimport com.imagekit.api.models.beta.v2.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.beta().v2().files().upload(params);\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.beta.v2.files.FileUploadParams;\nimport io.imagekit.api.models.beta.v2.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.beta().v2().files().upload(params);\n }\n}', }, kotlin: { method: 'beta().v2().files().upload', @@ -3217,7 +3217,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ }, java: { example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.webhooks.WebhookUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unwrap();\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.webhooks.WebhookUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unwrap();\n }\n}', }, kotlin: { example: @@ -3269,7 +3269,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ }, java: { example: - 'package com.imagekit.api.example;\n\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.webhooks.WebhookUnsafeUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unsafeUnwrap();\n }\n}', + 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.webhooks.WebhookUnsafeUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unsafeUnwrap();\n }\n}', }, kotlin: { example: @@ -3328,7 +3328,7 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'java', content: - '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport com.imagekit.api.client.ImageKitClientAsync;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.MultipartField;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport com.imagekit.api.core.http.Headers;\nimport com.imagekit.api.core.http.HttpResponseFor;\nimport com.imagekit.api.models.files.FileUploadParams;\nimport com.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```java\nimport com.imagekit.api.core.JsonMissing;\nimport com.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport com.imagekit.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport com.imagekit.api.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport com.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.imagekit.api.client.ImageKitClient;\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit.api/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit.api/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit.api/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit.api:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit.api\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.api.client.ImageKitClientAsync;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt):\n\n```java\nimport io.imagekit.api.core.MultipartField;\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.api.core.http.Headers;\nimport io.imagekit.api.core.http.HttpResponseFor;\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.api.core.JsonValue;\nimport io.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.api.core.JsonValue;\nimport io.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.api.core.JsonValue;\nimport io.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt):\n\n```java\nimport io.imagekit.api.core.JsonMissing;\nimport io.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.api.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', }, { language: 'kotlin', From 7c35871232cfa418c30c6145fe0da2ec8937bca2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 18:43:43 +0000 Subject: [PATCH 12/36] feat(api): manual updates --- .stats.yml | 2 +- packages/mcp-server/src/local-docs-search.ts | 100 +++++++++---------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8624958a..6d0a83a8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: 4e6bdc90056ab9bddbeb207bd720cf53 +config_hash: da0c89d794fefcf600a4ddfc78553c2a diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index a3ba0de3..329613e5 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -91,7 +91,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().create', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build();\n CustomMetadataField customMetadataField = client.customMetadataFields().create(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build();\n CustomMetadataField customMetadataField = client.customMetadataFields().create(params);\n }\n}', }, kotlin: { method: 'customMetadataFields().create', @@ -157,7 +157,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().list', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List customMetadataFields = client.customMetadataFields().list();\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List customMetadataFields = client.customMetadataFields().list();\n }\n}', }, kotlin: { method: 'customMetadataFields().list', @@ -226,7 +226,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().update', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataField customMetadataField = client.customMetadataFields().update("id");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataField customMetadataField = client.customMetadataFields().update("id");\n }\n}', }, kotlin: { method: 'customMetadataFields().update', @@ -291,7 +291,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'customMetadataFields().delete', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams;\nimport io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldDeleteResponse customMetadataField = client.customMetadataFields().delete("id");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteParams;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldDeleteResponse customMetadataField = client.customMetadataFields().delete("id");\n }\n}', }, kotlin: { method: 'customMetadataFields().delete', @@ -381,7 +381,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().upload', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.files().upload(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.files().upload(params);\n }\n}', }, kotlin: { method: 'files().upload', @@ -447,7 +447,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().get', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.File;\nimport io.imagekit.api.models.files.FileGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n File file = client.files().get("fileId");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.FileGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n File file = client.files().get("fileId");\n }\n}', }, kotlin: { method: 'files().get', @@ -514,7 +514,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().update', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileUpdateParams;\nimport io.imagekit.api.models.files.FileUpdateResponse;\nimport io.imagekit.api.models.files.UpdateFileRequest;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUpdateParams params = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build();\n FileUpdateResponse file = client.files().update(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUpdateParams;\nimport io.imagekit.models.files.FileUpdateResponse;\nimport io.imagekit.models.files.UpdateFileRequest;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUpdateParams params = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build();\n FileUpdateResponse file = client.files().update(params);\n }\n}', }, kotlin: { method: 'files().update', @@ -578,7 +578,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().delete', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.files().delete("fileId");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.files().delete("fileId");\n }\n}', }, kotlin: { method: 'files().delete', @@ -643,7 +643,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().copy', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileCopyParams;\nimport io.imagekit.api.models.files.FileCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileCopyParams params = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileCopyResponse response = client.files().copy(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileCopyParams;\nimport io.imagekit.models.files.FileCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileCopyParams params = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileCopyResponse response = client.files().copy(params);\n }\n}', }, kotlin: { method: 'files().copy', @@ -708,7 +708,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().move', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileMoveParams;\nimport io.imagekit.api.models.files.FileMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileMoveParams params = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileMoveResponse response = client.files().move(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileMoveParams;\nimport io.imagekit.models.files.FileMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileMoveParams params = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileMoveResponse response = client.files().move(params);\n }\n}', }, kotlin: { method: 'files().move', @@ -773,7 +773,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().rename', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileRenameParams;\nimport io.imagekit.api.models.files.FileRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileRenameParams params = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build();\n FileRenameResponse response = client.files().rename(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileRenameParams;\nimport io.imagekit.models.files.FileRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileRenameParams params = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build();\n FileRenameResponse response = client.files().rename(params);\n }\n}', }, kotlin: { method: 'files().rename', @@ -838,7 +838,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().delete', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.bulk.BulkDeleteParams;\nimport io.imagekit.api.models.files.bulk.BulkDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkDeleteParams params = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkDeleteResponse bulk = client.files().bulk().delete(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkDeleteParams;\nimport io.imagekit.models.files.bulk.BulkDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkDeleteParams params = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkDeleteResponse bulk = client.files().bulk().delete(params);\n }\n}', }, kotlin: { method: 'files().bulk().delete', @@ -903,7 +903,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().addTags', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.bulk.BulkAddTagsParams;\nimport io.imagekit.api.models.files.bulk.BulkAddTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkAddTagsParams params = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkAddTagsResponse response = client.files().bulk().addTags(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkAddTagsParams;\nimport io.imagekit.models.files.bulk.BulkAddTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkAddTagsParams params = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkAddTagsResponse response = client.files().bulk().addTags(params);\n }\n}', }, kotlin: { method: 'files().bulk().addTags', @@ -968,7 +968,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().removeTags', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.bulk.BulkRemoveTagsParams;\nimport io.imagekit.api.models.files.bulk.BulkRemoveTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveTagsParams params = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkRemoveTagsResponse response = client.files().bulk().removeTags(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkRemoveTagsParams;\nimport io.imagekit.models.files.bulk.BulkRemoveTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveTagsParams params = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkRemoveTagsResponse response = client.files().bulk().removeTags(params);\n }\n}', }, kotlin: { method: 'files().bulk().removeTags', @@ -1033,7 +1033,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().bulk().removeAiTags', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams;\nimport io.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveAiTagsParams params = BulkRemoveAiTagsParams.builder()\n .aiTags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkRemoveAiTagsResponse response = client.files().bulk().removeAiTags(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkRemoveAiTagsParams;\nimport io.imagekit.models.files.bulk.BulkRemoveAiTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveAiTagsParams params = BulkRemoveAiTagsParams.builder()\n .aiTags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkRemoveAiTagsResponse response = client.files().bulk().removeAiTags(params);\n }\n}', }, kotlin: { method: 'files().bulk().removeAiTags', @@ -1098,7 +1098,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().list', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.File;\nimport io.imagekit.api.models.files.versions.VersionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List files = client.files().versions().list("fileId");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List files = client.files().versions().list("fileId");\n }\n}', }, kotlin: { method: 'files().versions().list', @@ -1163,7 +1163,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().get', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.File;\nimport io.imagekit.api.models.files.versions.VersionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionGetParams params = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().get(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionGetParams params = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().get(params);\n }\n}', }, kotlin: { method: 'files().versions().get', @@ -1228,7 +1228,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().delete', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.versions.VersionDeleteParams;\nimport io.imagekit.api.models.files.versions.VersionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionDeleteParams params = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n VersionDeleteResponse version = client.files().versions().delete(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.versions.VersionDeleteParams;\nimport io.imagekit.models.files.versions.VersionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionDeleteParams params = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n VersionDeleteResponse version = client.files().versions().delete(params);\n }\n}', }, kotlin: { method: 'files().versions().delete', @@ -1293,7 +1293,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().versions().restore', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.File;\nimport io.imagekit.api.models.files.versions.VersionRestoreParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionRestoreParams params = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().restore(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionRestoreParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionRestoreParams params = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().restore(params);\n }\n}', }, kotlin: { method: 'files().versions().restore', @@ -1359,7 +1359,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().metadata().get', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.Metadata;\nimport io.imagekit.api.models.files.metadata.MetadataGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n Metadata metadata = client.files().metadata().get("fileId");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.Metadata;\nimport io.imagekit.models.files.metadata.MetadataGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n Metadata metadata = client.files().metadata().get("fileId");\n }\n}', }, kotlin: { method: 'files().metadata().get', @@ -1425,7 +1425,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'files().metadata().getFromUrl', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.Metadata;\nimport io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n MetadataGetFromUrlParams params = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build();\n Metadata metadata = client.files().metadata().getFromUrl(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.Metadata;\nimport io.imagekit.models.files.metadata.MetadataGetFromUrlParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n MetadataGetFromUrlParams params = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build();\n Metadata metadata = client.files().metadata().getFromUrl(params);\n }\n}', }, kotlin: { method: 'files().metadata().getFromUrl', @@ -1490,7 +1490,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().list', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.SavedExtension;\nimport io.imagekit.api.models.savedextensions.SavedExtensionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List savedExtensions = client.savedExtensions().list();\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List savedExtensions = client.savedExtensions().list();\n }\n}', }, kotlin: { method: 'savedExtensions().list', @@ -1560,7 +1560,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().create', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.ExtensionConfig;\nimport io.imagekit.api.models.SavedExtension;\nimport io.imagekit.api.models.savedextensions.SavedExtensionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtensionCreateParams params = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build();\n SavedExtension savedExtension = client.savedExtensions().create(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.ExtensionConfig;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtensionCreateParams params = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build();\n SavedExtension savedExtension = client.savedExtensions().create(params);\n }\n}', }, kotlin: { method: 'savedExtensions().create', @@ -1625,7 +1625,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().get', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.SavedExtension;\nimport io.imagekit.api.models.savedextensions.SavedExtensionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().get("id");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().get("id");\n }\n}', }, kotlin: { method: 'savedExtensions().get', @@ -1696,7 +1696,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().update', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.SavedExtension;\nimport io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().update("id");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().update("id");\n }\n}', }, kotlin: { method: 'savedExtensions().update', @@ -1759,7 +1759,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'savedExtensions().delete', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.savedextensions.SavedExtensionDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.savedExtensions().delete("id");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.savedextensions.SavedExtensionDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.savedExtensions().delete("id");\n }\n}', }, kotlin: { method: 'savedExtensions().delete', @@ -1832,7 +1832,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'assets().list', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.assets.AssetListParams;\nimport io.imagekit.api.models.assets.AssetListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List assets = client.assets().list();\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.assets.AssetListParams;\nimport io.imagekit.models.assets.AssetListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List assets = client.assets().list();\n }\n}', }, kotlin: { method: 'assets().list', @@ -1897,7 +1897,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'cache().invalidation().create', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.cache.invalidation.InvalidationCreateParams;\nimport io.imagekit.api.models.cache.invalidation.InvalidationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationCreateParams params = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build();\n InvalidationCreateResponse invalidation = client.cache().invalidation().create(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.cache.invalidation.InvalidationCreateParams;\nimport io.imagekit.models.cache.invalidation.InvalidationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationCreateParams params = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build();\n InvalidationCreateResponse invalidation = client.cache().invalidation().create(params);\n }\n}', }, kotlin: { method: 'cache().invalidation().create', @@ -1961,7 +1961,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'cache().invalidation().get', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.cache.invalidation.InvalidationGetParams;\nimport io.imagekit.api.models.cache.invalidation.InvalidationGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationGetResponse invalidation = client.cache().invalidation().get("requestId");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.cache.invalidation.InvalidationGetParams;\nimport io.imagekit.models.cache.invalidation.InvalidationGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationGetResponse invalidation = client.cache().invalidation().get("requestId");\n }\n}', }, kotlin: { method: 'cache().invalidation().get', @@ -2026,7 +2026,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().create', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.folders.FolderCreateParams;\nimport io.imagekit.api.models.folders.FolderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCreateParams params = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build();\n FolderCreateResponse folder = client.folders().create(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderCreateParams;\nimport io.imagekit.models.folders.FolderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCreateParams params = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build();\n FolderCreateResponse folder = client.folders().create(params);\n }\n}', }, kotlin: { method: 'folders().create', @@ -2091,7 +2091,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().delete', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.folders.FolderDeleteParams;\nimport io.imagekit.api.models.folders.FolderDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderDeleteParams params = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build();\n FolderDeleteResponse folder = client.folders().delete(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderDeleteParams;\nimport io.imagekit.models.folders.FolderDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderDeleteParams params = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build();\n FolderDeleteResponse folder = client.folders().delete(params);\n }\n}', }, kotlin: { method: 'folders().delete', @@ -2156,7 +2156,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().copy', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.folders.FolderCopyParams;\nimport io.imagekit.api.models.folders.FolderCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCopyParams params = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderCopyResponse response = client.folders().copy(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderCopyParams;\nimport io.imagekit.models.folders.FolderCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCopyParams params = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderCopyResponse response = client.folders().copy(params);\n }\n}', }, kotlin: { method: 'folders().copy', @@ -2221,7 +2221,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().move', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.folders.FolderMoveParams;\nimport io.imagekit.api.models.folders.FolderMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderMoveParams params = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderMoveResponse response = client.folders().move(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderMoveParams;\nimport io.imagekit.models.folders.FolderMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderMoveParams params = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderMoveResponse response = client.folders().move(params);\n }\n}', }, kotlin: { method: 'folders().move', @@ -2286,7 +2286,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().rename', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.folders.FolderRenameParams;\nimport io.imagekit.api.models.folders.FolderRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderRenameParams params = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build();\n FolderRenameResponse response = client.folders().rename(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderRenameParams;\nimport io.imagekit.models.folders.FolderRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderRenameParams params = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build();\n FolderRenameResponse response = client.folders().rename(params);\n }\n}', }, kotlin: { method: 'folders().rename', @@ -2351,7 +2351,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'folders().job().get', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.folders.job.JobGetParams;\nimport io.imagekit.api.models.folders.job.JobGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n JobGetResponse job = client.folders().job().get("jobId");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.job.JobGetParams;\nimport io.imagekit.models.folders.job.JobGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n JobGetResponse job = client.folders().job().get("jobId");\n }\n}', }, kotlin: { method: 'folders().job().get', @@ -2417,7 +2417,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().usage().get', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.usage.UsageGetParams;\nimport io.imagekit.api.models.accounts.usage.UsageGetResponse;\nimport java.time.LocalDate;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UsageGetParams params = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build();\n UsageGetResponse usage = client.accounts().usage().get(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.usage.UsageGetParams;\nimport io.imagekit.models.accounts.usage.UsageGetResponse;\nimport java.time.LocalDate;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UsageGetParams params = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build();\n UsageGetResponse usage = client.accounts().usage().get(params);\n }\n}', }, kotlin: { method: 'accounts().usage().get', @@ -2481,7 +2481,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().list', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.origins.OriginListParams;\nimport io.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List originResponses = client.accounts().origins().list();\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginListParams;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List originResponses = client.accounts().origins().list();\n }\n}', }, kotlin: { method: 'accounts().origins().list', @@ -2546,7 +2546,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().create', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.origins.OriginCreateParams;\nimport io.imagekit.api.models.accounts.origins.OriginRequest;\nimport io.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginCreateParams;\nimport io.imagekit.models.accounts.origins.OriginRequest;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}', }, kotlin: { method: 'accounts().origins().create', @@ -2610,7 +2610,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().get', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.origins.OriginGetParams;\nimport io.imagekit.api.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginResponse originResponse = client.accounts().origins().get("id");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginGetParams;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginResponse originResponse = client.accounts().origins().get("id");\n }\n}', }, kotlin: { method: 'accounts().origins().get', @@ -2676,7 +2676,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().update', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.origins.OriginRequest;\nimport io.imagekit.api.models.accounts.origins.OriginResponse;\nimport io.imagekit.api.models.accounts.origins.OriginUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginUpdateParams params = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build();\n OriginResponse originResponse = client.accounts().origins().update(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginRequest;\nimport io.imagekit.models.accounts.origins.OriginResponse;\nimport io.imagekit.models.accounts.origins.OriginUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginUpdateParams params = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build();\n OriginResponse originResponse = client.accounts().origins().update(params);\n }\n}', }, kotlin: { method: 'accounts().origins().update', @@ -2740,7 +2740,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().delete', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.origins.OriginDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().origins().delete("id");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().origins().delete("id");\n }\n}', }, kotlin: { method: 'accounts().origins().delete', @@ -2805,7 +2805,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().list', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List urlEndpointResponses = client.accounts().urlEndpoints().list();\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointListParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List urlEndpointResponses = client.accounts().urlEndpoints().list();\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().list', @@ -2876,7 +2876,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().create', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().create', @@ -2942,7 +2942,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().get', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get("id");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get("id");\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().get', @@ -3014,7 +3014,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().update', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointUpdateParams params = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().update(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointUpdateParams params = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().update(params);\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().update', @@ -3078,7 +3078,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().delete', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().urlEndpoints().delete("id");\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().urlEndpoints().delete("id");\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().delete', @@ -3165,7 +3165,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'beta().v2().files().upload', example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.beta.v2.files.FileUploadParams;\nimport io.imagekit.api.models.beta.v2.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.beta().v2().files().upload(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.beta.v2.files.FileUploadParams;\nimport io.imagekit.models.beta.v2.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.beta().v2().files().upload(params);\n }\n}', }, kotlin: { method: 'beta().v2().files().upload', @@ -3217,7 +3217,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ }, java: { example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.webhooks.WebhookUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unwrap();\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.webhooks.WebhookUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unwrap();\n }\n}', }, kotlin: { example: @@ -3269,7 +3269,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ }, java: { example: - 'package io.imagekit.api.example;\n\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.webhooks.WebhookUnsafeUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unsafeUnwrap();\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.webhooks.WebhookUnsafeUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unsafeUnwrap();\n }\n}', }, kotlin: { example: @@ -3328,7 +3328,7 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'java', content: - '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit.api/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit.api/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit.api/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit.api:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit.api\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.api.client.ImageKitClientAsync;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt):\n\n```java\nimport io.imagekit.api.core.MultipartField;\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.api.core.http.Headers;\nimport io.imagekit.api.core.http.HttpResponseFor;\nimport io.imagekit.api.models.files.FileUploadParams;\nimport io.imagekit.api.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.api.core.JsonValue;\nimport io.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.api.core.JsonValue;\nimport io.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.api.core.JsonValue;\nimport io.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt):\n\n```java\nimport io.imagekit.api.core.JsonMissing;\nimport io.imagekit.api.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.api.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.api.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.api.client.ImageKitClient;\nimport io.imagekit.api.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.client.ImageKitClientAsync;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.MultipartField;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.core.http.Headers;\nimport io.imagekit.core.http.HttpResponseFor;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.JsonMissing;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', }, { language: 'kotlin', From 885c2ad3123fb0be7f58a12576402a31eda9743d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 Apr 2026 10:28:42 +0000 Subject: [PATCH 13/36] chore(internal): update docs ordering --- packages/mcp-server/src/local-docs-search.ts | 40 ++++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 329613e5..1465f6f4 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -3301,54 +3301,54 @@ const EMBEDDED_METHODS: MethodEntry[] = [ const EMBEDDED_READMES: { language: string; content: string }[] = [ { - language: 'python', + language: 'cli', content: - '# Image Kit Python API library\n\n\n[![PyPI version](https://img.shields.io/pypi/v/imagekitio.svg?label=pypi%20(stable))](https://pypi.org/project/imagekitio/)\n\nThe Image Kit Python library provides convenient access to the Image Kit REST API from any Python 3.9+\napplication. The library includes type definitions for all request params and response fields,\nand offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n## Installation\n\n```sh\n# install from PyPI\npip install imagekitio\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nresponse = client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.video_codec)\n```\n\nWhile you can provide a `private_key` keyword argument,\nwe recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nto add `IMAGEKIT_PRIVATE_KEY="My Private Key"` to your `.env` file\nso that your Private Key is not stored in source control.\n\n## Async usage\n\nSimply import `AsyncImageKit` instead of `ImageKit` and use `await` with each API call:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import AsyncImageKit\n\nclient = AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nasync def main() -> None:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n### With aiohttp\n\nBy default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.\n\nYou can enable this by installing `aiohttp`:\n\n```sh\n# install from PyPI\npip install imagekitio[aiohttp]\n```\n\nThen you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import DefaultAioHttpClient\nfrom imagekitio import AsyncImageKit\n\nasync def main() -> None:\n async with AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n http_client=DefaultAioHttpClient(),\n) as client:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\n\n\n## Using types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:\n\n- Serializing back into JSON, `model.to_json()`\n- Converting to a dictionary, `model.to_dict()`\n\nTyped requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.\n\n\n\n## Nested params\n\nNested parameters are dictionaries, typed using `TypedDict`, for example:\n\n```python\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nresponse = client.files.upload(\n file=b"Example data",\n file_name="fileName",\n transformation={\n "post": [{\n "type": "thumbnail",\n "value": "w-150,h-150",\n }, {\n "protocol": "dash",\n "type": "abs",\n "value": "sr-240_360_480_720_1080",\n }]\n },\n)\nprint(response.transformation)\n```\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.\n\n```python\nfrom pathlib import Path\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nclient.files.upload(\n file=Path("/path/to/file"),\n file_name="fileName",\n)\n```\n\nThe async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.\n\n## Handling errors\n\nWhen the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `imagekitio.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (that is, 4xx or 5xx\nresponse), a subclass of `imagekitio.APIStatusError` is raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `imagekitio.APIError`.\n\n```python\nimport imagekitio\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\ntry:\n client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\nexcept imagekitio.APIConnectionError as e:\n print("The server could not be reached")\n print(e.__cause__) # an underlying Exception, likely raised within httpx.\nexcept imagekitio.RateLimitError as e:\n print("A 429 status code was received; we should back off a bit.")\nexcept imagekitio.APIStatusError as e:\n print("Another non-200-range status code was received")\n print(e.status_code)\n print(e.response)\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors are automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors are all retried by default.\n\nYou can use the `max_retries` option to configure or disable retry settings:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # default is 2\n max_retries=0,\n)\n\n# Or, configure per-request:\nclient.with_options(max_retries = 5).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\n### Timeouts\n\nBy default requests time out after 1 minute. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # 20 seconds (default is 1 minute)\n timeout=20.0,\n)\n\n# More granular control:\nclient = ImageKit(\n timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n)\n\n# Override per-request:\nclient.with_options(timeout = 5.0).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests that time out are [retried twice by default](#retries).\n\n\n\n## Advanced\n\n### Logging\n\nWe use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.\n\nYou can enable logging by setting the environment variable `IMAGE_KIT_LOG` to `info`.\n\n```shell\n$ export IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging.\n\n### How to tell whether `None` means `null` or missing\n\nIn an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:\n\n```py\nif response.my_field is None:\n if \'my_field\' not in response.model_fields_set:\n print(\'Got json like {}, without a "my_field" key present at all.\')\n else:\n print(\'Got json like {"my_field": null}.\')\n```\n\n### Accessing raw response data (e.g. headers)\n\nThe "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,\n\n```py\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\nresponse = client.files.with_raw_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.headers.get(\'X-My-Header\'))\n\nfile = response.parse() # get the object that `files.upload()` would have returned\nprint(file.video_codec)\n```\n\nThese methods return an [`APIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) object.\n\nThe async client returns an [`AsyncAPIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.\n\n#### `.with_streaming_response`\n\nThe above interface eagerly reads the full response body when you make the request, which may not always be what you want.\n\nTo stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.\n\n```python\nwith client.files.with_streaming_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n) as response :\n print(response.headers.get(\'X-My-Header\'))\n\n for line in response.iter_lines():\n print(line)\n```\n\nThe context manager is required so that the response will reliably be closed.\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API.\n\nIf you need to access undocumented endpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other\nhttp verbs. Options on the client will be respected (such as retries) when making this request.\n\n```py\nimport httpx\n\nresponse = client.post(\n "/foo",\n cast_to=httpx.Response,\n body={"my_param": True},\n)\n\nprint(response.headers.get("x-foo"))\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You\ncan also get all the extra fields on the Pydantic model as a dict with\n[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).\n\n### Configuring the HTTP client\n\nYou can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:\n\n- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)\n- Custom [transports](https://www.python-httpx.org/advanced/transports/)\n- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality\n\n```python\nimport httpx\nfrom imagekitio import ImageKit, DefaultHttpxClient\n\nclient = ImageKit(\n # Or use the `IMAGE_KIT_BASE_URL` env var\n base_url="http://my.test.server.example.com:8083",\n http_client=DefaultHttpxClient(proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),\n)\n```\n\nYou can also customize the client on a per-request basis by using `with_options()`:\n\n```python\nclient.with_options(http_client=DefaultHttpxClient(...))\n```\n\n### Managing HTTP resources\n\nBy default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.\n\n```py\nfrom imagekitio import ImageKit\n\nwith ImageKit() as client:\n # make requests here\n ...\n\n# HTTP client is now closed\n```\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you\'ve upgraded to the latest version but aren\'t seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport imagekitio\nprint(imagekitio.__version__)\n```\n\n## Requirements\n\nPython 3.9 or higher.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', + "# Image Kit CLI\n\nThe official CLI for the [Image Kit REST API](https://imagekit.io/docs/api-reference).\n\n## Installation\n\n### Installing with Go\n\nTo test or install the CLI locally, you need [Go](https://go.dev/doc/install) version 1.22 or later installed.\n\n~~~sh\ngo install 'github.com/stainless-sdks/imagekit-cli/cmd/imagekit@latest'\n~~~\n\nOnce you have run `go install`, the binary is placed in your Go bin directory:\n\n- **Default location**: `$HOME/go/bin` (or `$GOPATH/bin` if GOPATH is set)\n- **Check your path**: Run `go env GOPATH` to see the base directory\n\nIf commands aren't found after installation, add the Go bin directory to your PATH:\n\n~~~sh\n# Add to your shell profile (.zshrc, .bashrc, etc.)\nexport PATH=\"$PATH:$(go env GOPATH)/bin\"\n~~~\n\n### Running Locally\n\nAfter cloning the git repository for this project, you can use the\n`scripts/run` script to run the tool locally:\n\n~~~sh\n./scripts/run args...\n~~~\n\n## Usage\n\nThe CLI follows a resource-based command structure:\n\n~~~sh\nimagekit [resource] [flags...]\n~~~\n\n~~~sh\nimagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name file-name.jpg\n~~~\n\nFor details about specific commands, use the `--help` flag.\n\n### Environment variables\n\n| Environment variable | Description | Required | Default value |\n| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------- |\n| `IMAGEKIT_PRIVATE_KEY` | Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n | yes | |\n| `OPTIONAL_IMAGEKIT_IGNORES_THIS` | ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n | no | `\"do_not_set\"` |\n| `IMAGEKIT_WEBHOOK_SECRET` | Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n | no | `null` |\n\n### Global flags\n\n- `--private-key` - Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n (can also be set with `IMAGEKIT_PRIVATE_KEY` env var)\n- `--password` - ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n (can also be set with `OPTIONAL_IMAGEKIT_IGNORES_THIS` env var)\n- `--webhook-secret` - Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n (can also be set with `IMAGEKIT_WEBHOOK_SECRET` env var)\n- `--help` - Show command line usage\n- `--debug` - Enable debug logging (includes HTTP request/response details)\n- `--version`, `-v` - Show the CLI version\n- `--base-url` - Use a custom API backend URL\n- `--format` - Change the output format (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--format-error` - Change the output format for errors (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--transform` - Transform the data output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n- `--transform-error` - Transform the error output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n\n### Passing files as arguments\n\nTo pass files to your API, you can use the `@myfile.ext` syntax:\n\n~~~bash\nimagekit --arg @abe.jpg\n~~~\n\nFiles can also be passed inside JSON or YAML blobs:\n\n~~~bash\nimagekit --arg '{image: \"@abe.jpg\"}'\n# Equivalent:\nimagekit < --username '\\@abe'\n~~~\n\n#### Explicit encoding\n\nFor JSON endpoints, the CLI tool does filetype sniffing to determine whether the\nfile contents should be sent as a string literal (for plain text files) or as a\nbase64-encoded string literal (for binary files). If you need to explicitly send\nthe file as either plain text or base64-encoded data, you can use\n`@file://myfile.txt` (for string encoding) or `@data://myfile.dat` (for\nbase64-encoding). Note that absolute paths will begin with `@file://` or\n`@data://`, followed by a third `/` (for example, `@file:///tmp/file.txt`).\n\n~~~bash\nimagekit --arg @data://file.txt\n~~~\n\n## Linking different Go SDK versions\n\nYou can link the CLI against a different version of the Image Kit Go SDK\nfor development purposes using the `./scripts/link` script.\n\nTo link to a specific version from a repository (version can be a branch,\ngit tag, or commit hash):\n\n~~~bash\n./scripts/link github.com/org/repo@version\n~~~\n\nTo link to a local copy of the SDK:\n\n~~~bash\n./scripts/link ../path/to/imagekit-go\n~~~\n\nIf you run the link script without any arguments, it will default to `../imagekit-go`.\n", }, { - language: 'go', + language: 'csharp', content: - '# Image Kit Go API Library\n\nGo Reference\n\nThe Image Kit Go library provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference)\nfrom applications written in Go.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n\n\n```go\nimport (\n\t"github.com/imagekit-developer/imagekit-go" // imported as SDK_PackageName\n)\n```\n\n\n\nOr to pin the version:\n\n\n\n```sh\ngo get -u \'github.com/imagekit-developer/imagekit-go@v0.0.1\'\n```\n\n\n\n## Requirements\n\nThis library requires Go 1.22+.\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```go\npackage main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"), // defaults to os.LookupEnv("IMAGEKIT_PRIVATE_KEY")\n\t\toption.WithPassword("My Password"), // defaults to os.LookupEnv("OPTIONAL_IMAGEKIT_IGNORES_THIS")\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n\n```\n\n### Request fields\n\nAll request parameters are wrapped in a generic `Field` type,\nwhich we use to distinguish zero values from null or omitted fields.\n\nThis prevents accidentally sending a zero value if you forget a required parameter,\nand enables explicitly sending `null`, `false`, `\'\'`, or `0` on optional parameters.\nAny field not specified is not sent.\n\nTo construct fields with values, use the helpers `String()`, `Int()`, `Float()`, or most commonly, the generic `F[T]()`.\nTo send a null, use `Null[T]()`, and to send a nonconforming value, use `Raw[T](any)`. For example:\n\n```go\nparams := FooParams{\n\tName: SDK_PackageName.F("hello"),\n\n\t// Explicitly send `"description": null`\n\tDescription: SDK_PackageName.Null[string](),\n\n\tPoint: SDK_PackageName.F(SDK_PackageName.Point{\n\t\tX: SDK_PackageName.Int(0),\n\t\tY: SDK_PackageName.Int(1),\n\n\t\t// In cases where the API specifies a given type,\n\t\t// but you want to send something else, use `Raw`:\n\t\tZ: SDK_PackageName.Raw[int64](0.01), // sends a float\n\t}),\n}\n```\n\n### Response objects\n\nAll fields in response structs are value types (not pointers or wrappers).\n\nIf a given field is `null`, not present, or invalid, the corresponding field\nwill simply be its zero value.\n\nAll response structs also include a special `JSON` field, containing more detailed\ninformation about each property, which you can use like so:\n\n```go\nif res.Name == "" {\n\t// true if `"name"` is either not present or explicitly null\n\tres.JSON.Name.IsNull()\n\n\t// true if the `"name"` key was not present in the response JSON at all\n\tres.JSON.Name.IsMissing()\n\n\t// When the API returns data that cannot be coerced to the expected type:\n\tif res.JSON.Name.IsInvalid() {\n\t\traw := res.JSON.Name.Raw()\n\n\t\tlegacyName := struct{\n\t\t\tFirst string `json:"first"`\n\t\t\tLast string `json:"last"`\n\t\t}{}\n\t\tjson.Unmarshal([]byte(raw), &legacyName)\n\t\tname = legacyName.First + " " + legacyName.Last\n\t}\n}\n```\n\nThese `.JSON` structs also include an `Extras` map containing\nany properties in the json response that were not specified\nin the struct. This can be useful for API features not yet\npresent in the SDK.\n\n```go\nbody := res.JSON.ExtraFields["my_unexpected_field"].Raw()\n```\n\n### RequestOptions\n\nThis library uses the functional options pattern. Functions defined in the\n`SDK_PackageOptionName` package return a `RequestOption`, which is a closure that mutates a\n`RequestConfig`. These options can be supplied to the client or at individual\nrequests. For example:\n\n```go\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\t// Adds a header to every request made by the client\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "custom_header_info"),\n)\n\nclient.Files.Upload(context.TODO(), ...,\n\t// Override the header\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "some_other_custom_header_info"),\n\t// Add an undocumented field to the request body, using sjson syntax\n\tSDK_PackageOptionName.WithJSONSet("some.json.path", map[string]string{"my": "object"}),\n)\n```\n\nSee the [full list of request options](https://pkg.go.dev/github.com/imagekit-developer/imagekit-go/SDK_PackageOptionName).\n\n### Pagination\n\nThis library provides some conveniences for working with paginated list endpoints.\n\nYou can use `.ListAutoPaging()` methods to iterate through items across all pages:\n\n\n\nOr you can use simple `.List()` methods to fetch a single page and receive a standard response object\nwith additional helper methods like `.GetNextPage()`, e.g.:\n\n\n\n### Errors\n\nWhen the API returns a non-success status code, we return an error with type\n`*SDK_PackageName.Error`. This contains the `StatusCode`, `*http.Request`, and\n`*http.Response` values of the request, as well as the JSON of the error body\n(much like other response objects in the SDK).\n\nTo handle errors, we recommend that you use the `errors.As` pattern:\n\n```go\n_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\tFileName: "file-name.jpg",\n})\nif err != nil {\n\tvar apierr *imagekit.Error\n\tif errors.As(err, &apierr) {\n\t\tprintln(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request\n\t\tprintln(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response\n\t}\n\tpanic(err.Error()) // GET "/api/v1/files/upload": 400 Bad Request { ... }\n}\n```\n\nWhen other errors occur, they are returned unwrapped; for example,\nif HTTP transport fails, you might receive `*url.Error` wrapping `*net.OpError`.\n\n### Timeouts\n\nRequests do not time out by default; use context to configure a timeout for a request lifecycle.\n\nNote that if a request is [retried](#retries), the context timeout does not start over.\nTo set a per-retry timeout, use `SDK_PackageOptionName.WithRequestTimeout()`.\n\n```go\n// This sets the timeout for the request, including all the retries.\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\nclient.Files.Upload(\n\tctx,\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\t// This sets the per-retry timeout\n\toption.WithRequestTimeout(20*time.Second),\n)\n```\n\n### File uploads\n\nRequest parameters that correspond to file uploads in multipart requests are typed as\n`param.Field[io.Reader]`. The contents of the `io.Reader` will by default be sent as a multipart form\npart with the file name of "anonymous_file" and content-type of "application/octet-stream".\n\nThe file name and content-type can be customized by implementing `Name() string` or `ContentType()\nstring` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a\nfile returned by `os.Open` will be sent with the file name on disk.\n\nWe also provide a helper `SDK_PackageName.FileParam(reader io.Reader, filename string, contentType string)`\nwhich can be used to wrap any `io.Reader` with the appropriate file name and content type.\n\n```go\n// A file from the file system\nfile, err := os.Open("/path/to/file")\nimagekit.FileUploadParams{\n\tFile: file,\n\tFileName: "fileName",\n}\n\n// A file from a string\nimagekit.FileUploadParams{\n\tFile: strings.NewReader("my file contents"),\n\tFileName: "fileName",\n}\n\n// With a custom filename and contentType\nimagekit.FileUploadParams{\n\tFile: imagekit.NewFile(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"),\n\tFileName: "fileName",\n}\n```\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nWe retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit,\nand >=500 Internal errors.\n\nYou can use the `WithMaxRetries` option to configure or disable this:\n\n```go\n// Configure the default for all requests:\nclient := imagekit.NewClient(\n\toption.WithMaxRetries(0), // default is 2\n)\n\n// Override per-request:\nclient.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithMaxRetries(5),\n)\n```\n\n\n### Accessing raw response data (e.g. response headers)\n\nYou can access the raw HTTP response data by using the `option.WithResponseInto()` request option. This is useful when\nyou need to examine response headers, status codes, or other details.\n\n```go\n// Create a variable to store the HTTP response\nvar response *http.Response\nresponse, err := client.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithResponseInto(&response),\n)\nif err != nil {\n\t// handle error\n}\nfmt.Printf("%+v\\n", response)\n\nfmt.Printf("Status Code: %d\\n", response.StatusCode)\nfmt.Printf("Headers: %+#v\\n", response.Header)\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.Get`, `client.Post`, and other HTTP verbs.\n`RequestOptions` on the client, such as retries, will be respected when making these requests.\n\n```go\nvar (\n // params can be an io.Reader, a []byte, an encoding/json serializable object,\n // or a "…Params" struct defined in this library.\n params map[string]interface{}\n\n // result can be an []byte, *http.Response, a encoding/json deserializable object,\n // or a model defined in this library.\n result *http.Response\n)\nerr := client.Post(context.Background(), "/unspecified", params, &result)\nif err != nil {\n …\n}\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use either the `SDK_PackageOptionName.WithQuerySet()`\nor the `SDK_PackageOptionName.WithJSONSet()` methods.\n\n```go\nparams := FooNewParams{\n ID: SDK_PackageName.F("id_xxxx"),\n Data: SDK_PackageName.F(FooNewParamsData{\n FirstName: SDK_PackageName.F("John"),\n }),\n}\nclient.Foo.New(context.Background(), params, SDK_PackageOptionName.WithJSONSet("data.last_name", "Doe"))\n```\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may either access the raw JSON of the response as a string\nwith `result.JSON.RawJSON()`, or get the raw JSON of a particular field on the result with\n`result.JSON.Foo.Raw()`.\n\nAny fields that are not present on the response struct will be saved and can be accessed by `result.JSON.ExtraFields()` which returns the extra fields as a `map[string]Field`.\n\n### Middleware\n\nWe provide `SDK_PackageOptionName.WithMiddleware` which applies the given\nmiddleware to requests.\n\n```go\nfunc Logger(req *http.Request, next SDK_PackageOptionName.MiddlewareNext) (res *http.Response, err error) {\n\t// Before the request\n\tstart := time.Now()\n\tLogReq(req)\n\n\t// Forward the request to the next handler\n\tres, err = next(req)\n\n\t// Handle stuff after the request\n\tend := time.Now()\n\tLogRes(res, err, start - end)\n\n return res, err\n}\n\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\tSDK_PackageOptionName.WithMiddleware(Logger),\n)\n```\n\nWhen multiple middlewares are provided as variadic arguments, the middlewares\nare applied left to right. If `SDK_PackageOptionName.WithMiddleware` is given\nmultiple times, for example first in the client then the method, the\nmiddleware in the client will run first and the middleware given in the method\nwill run next.\n\nYou may also replace the default `http.Client` with\n`SDK_PackageOptionName.WithHTTPClient(client)`. Only one http client is\naccepted (this overwrites any previous client) and receives requests after any\nmiddleware has been applied.\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-go/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', + '# Image Kit C# API Library\n\nThe Image Kit C# SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in C#.\n\n## Installation\n\n```bash\ngit clone git@github.com:stainless-sdks/imagekit-csharp.git\ndotnet add reference imagekit-csharp/src/ImageKit\n```\n\n## Requirements\n\nThis library requires .NET Standard 2.0 or later.\n\n## Usage\n\nSee the [`examples`](examples) directory for complete and runnable examples.\n\n```csharp\nImageKitClient client = new();\n\nFileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes("https://www.example.com/public-url.jpg"),\n FileName = "file-name.jpg",\n};\n\nvar response = await client.Files.Upload(parameters);\n\nConsole.WriteLine(response);\n```', }, { - language: 'terraform', + language: 'go', content: - '# Image Kit Terraform Provider\n\nThe [Image Kit Terraform provider](https://registry.terraform.io/providers/stainless-sdks/imagekit/latest/docs) provides convenient access to\nthe [Image Kit REST API](https://imagekit.io/docs/api-reference) from Terraform.\n\n\n\n## Requirements\n\nThis provider requires Terraform CLI 1.0 or later. You can [install it for your system](https://developer.hashicorp.com/terraform/install)\non Hashicorp\'s website.\n\n## Usage\n\nAdd the following to your `main.tf` file:\n\n\n\n```hcl\n# Declare the provider and version\nterraform {\n required_providers {\n SDK_ProviderTypeName = {\n source = "stainless-sdks/imagekit"\n version = "~> 0.0.1"\n }\n }\n}\n\n# Initialize the provider\nprovider "imagekit" {\n # Your ImageKit private API key (starts with `private_`).\n You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n private_key = "My Private Key" # or set IMAGEKIT_PRIVATE_KEY env variable\n # ImageKit uses your API key as username and ignores the password. \n The SDK sets a dummy value. You can ignore this field.\n password = "My Password" # or set OPTIONAL_IMAGEKIT_IGNORES_THIS env variable\n # Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\n You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\n Only required if you\'re using webhooks.\n webhook_secret = "My Webhook Secret" # or set IMAGEKIT_WEBHOOK_SECRET env variable\n}\n\n# Configure a resource\nresource "imagekit_account_origin" "example_account_origin" {\n access_key = "AKIAIOSFODNN7EXAMPLE"\n bucket = "product-images"\n name = "US S3 Storage"\n secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"\n type = "S3"\n base_url_for_canonical_header = "https://cdn.example.com"\n include_canonical_header = false\n prefix = "raw-assets"\n}\n```\n\n\n\nInitialize your project by running `terraform init` in the directory.\n\nAdditional examples can be found in the [./examples](./examples) folder within this repository, and you can\nrefer to the full documentation on [the Terraform Registry](https://registry.terraform.io/providers/stainless-sdks/imagekit/latest/docs).\n\n### Provider Options\nWhen you initialize the provider, the following options are supported. It is recommended to use environment variables for sensitive values like access tokens.\nIf an environment variable is provided, then the option does not need to be set in the terraform source.\n\n| Property | Environment variable | Required | Default value |\n| -------------- | -------------------------------- | -------- | -------------- |\n| private_key | `IMAGEKIT_PRIVATE_KEY` | true | — |\n| webhook_secret | `IMAGEKIT_WEBHOOK_SECRET` | false | — |\n| password | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-terraform/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', + '# Image Kit Go API Library\n\nGo Reference\n\nThe Image Kit Go library provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference)\nfrom applications written in Go.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n\n\n```go\nimport (\n\t"github.com/imagekit-developer/imagekit-go" // imported as SDK_PackageName\n)\n```\n\n\n\nOr to pin the version:\n\n\n\n```sh\ngo get -u \'github.com/imagekit-developer/imagekit-go@v0.0.1\'\n```\n\n\n\n## Requirements\n\nThis library requires Go 1.22+.\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```go\npackage main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"), // defaults to os.LookupEnv("IMAGEKIT_PRIVATE_KEY")\n\t\toption.WithPassword("My Password"), // defaults to os.LookupEnv("OPTIONAL_IMAGEKIT_IGNORES_THIS")\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n\n```\n\n### Request fields\n\nAll request parameters are wrapped in a generic `Field` type,\nwhich we use to distinguish zero values from null or omitted fields.\n\nThis prevents accidentally sending a zero value if you forget a required parameter,\nand enables explicitly sending `null`, `false`, `\'\'`, or `0` on optional parameters.\nAny field not specified is not sent.\n\nTo construct fields with values, use the helpers `String()`, `Int()`, `Float()`, or most commonly, the generic `F[T]()`.\nTo send a null, use `Null[T]()`, and to send a nonconforming value, use `Raw[T](any)`. For example:\n\n```go\nparams := FooParams{\n\tName: SDK_PackageName.F("hello"),\n\n\t// Explicitly send `"description": null`\n\tDescription: SDK_PackageName.Null[string](),\n\n\tPoint: SDK_PackageName.F(SDK_PackageName.Point{\n\t\tX: SDK_PackageName.Int(0),\n\t\tY: SDK_PackageName.Int(1),\n\n\t\t// In cases where the API specifies a given type,\n\t\t// but you want to send something else, use `Raw`:\n\t\tZ: SDK_PackageName.Raw[int64](0.01), // sends a float\n\t}),\n}\n```\n\n### Response objects\n\nAll fields in response structs are value types (not pointers or wrappers).\n\nIf a given field is `null`, not present, or invalid, the corresponding field\nwill simply be its zero value.\n\nAll response structs also include a special `JSON` field, containing more detailed\ninformation about each property, which you can use like so:\n\n```go\nif res.Name == "" {\n\t// true if `"name"` is either not present or explicitly null\n\tres.JSON.Name.IsNull()\n\n\t// true if the `"name"` key was not present in the response JSON at all\n\tres.JSON.Name.IsMissing()\n\n\t// When the API returns data that cannot be coerced to the expected type:\n\tif res.JSON.Name.IsInvalid() {\n\t\traw := res.JSON.Name.Raw()\n\n\t\tlegacyName := struct{\n\t\t\tFirst string `json:"first"`\n\t\t\tLast string `json:"last"`\n\t\t}{}\n\t\tjson.Unmarshal([]byte(raw), &legacyName)\n\t\tname = legacyName.First + " " + legacyName.Last\n\t}\n}\n```\n\nThese `.JSON` structs also include an `Extras` map containing\nany properties in the json response that were not specified\nin the struct. This can be useful for API features not yet\npresent in the SDK.\n\n```go\nbody := res.JSON.ExtraFields["my_unexpected_field"].Raw()\n```\n\n### RequestOptions\n\nThis library uses the functional options pattern. Functions defined in the\n`SDK_PackageOptionName` package return a `RequestOption`, which is a closure that mutates a\n`RequestConfig`. These options can be supplied to the client or at individual\nrequests. For example:\n\n```go\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\t// Adds a header to every request made by the client\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "custom_header_info"),\n)\n\nclient.Files.Upload(context.TODO(), ...,\n\t// Override the header\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "some_other_custom_header_info"),\n\t// Add an undocumented field to the request body, using sjson syntax\n\tSDK_PackageOptionName.WithJSONSet("some.json.path", map[string]string{"my": "object"}),\n)\n```\n\nSee the [full list of request options](https://pkg.go.dev/github.com/imagekit-developer/imagekit-go/SDK_PackageOptionName).\n\n### Pagination\n\nThis library provides some conveniences for working with paginated list endpoints.\n\nYou can use `.ListAutoPaging()` methods to iterate through items across all pages:\n\n\n\nOr you can use simple `.List()` methods to fetch a single page and receive a standard response object\nwith additional helper methods like `.GetNextPage()`, e.g.:\n\n\n\n### Errors\n\nWhen the API returns a non-success status code, we return an error with type\n`*SDK_PackageName.Error`. This contains the `StatusCode`, `*http.Request`, and\n`*http.Response` values of the request, as well as the JSON of the error body\n(much like other response objects in the SDK).\n\nTo handle errors, we recommend that you use the `errors.As` pattern:\n\n```go\n_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\tFileName: "file-name.jpg",\n})\nif err != nil {\n\tvar apierr *imagekit.Error\n\tif errors.As(err, &apierr) {\n\t\tprintln(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request\n\t\tprintln(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response\n\t}\n\tpanic(err.Error()) // GET "/api/v1/files/upload": 400 Bad Request { ... }\n}\n```\n\nWhen other errors occur, they are returned unwrapped; for example,\nif HTTP transport fails, you might receive `*url.Error` wrapping `*net.OpError`.\n\n### Timeouts\n\nRequests do not time out by default; use context to configure a timeout for a request lifecycle.\n\nNote that if a request is [retried](#retries), the context timeout does not start over.\nTo set a per-retry timeout, use `SDK_PackageOptionName.WithRequestTimeout()`.\n\n```go\n// This sets the timeout for the request, including all the retries.\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\nclient.Files.Upload(\n\tctx,\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\t// This sets the per-retry timeout\n\toption.WithRequestTimeout(20*time.Second),\n)\n```\n\n### File uploads\n\nRequest parameters that correspond to file uploads in multipart requests are typed as\n`param.Field[io.Reader]`. The contents of the `io.Reader` will by default be sent as a multipart form\npart with the file name of "anonymous_file" and content-type of "application/octet-stream".\n\nThe file name and content-type can be customized by implementing `Name() string` or `ContentType()\nstring` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a\nfile returned by `os.Open` will be sent with the file name on disk.\n\nWe also provide a helper `SDK_PackageName.FileParam(reader io.Reader, filename string, contentType string)`\nwhich can be used to wrap any `io.Reader` with the appropriate file name and content type.\n\n```go\n// A file from the file system\nfile, err := os.Open("/path/to/file")\nimagekit.FileUploadParams{\n\tFile: file,\n\tFileName: "fileName",\n}\n\n// A file from a string\nimagekit.FileUploadParams{\n\tFile: strings.NewReader("my file contents"),\n\tFileName: "fileName",\n}\n\n// With a custom filename and contentType\nimagekit.FileUploadParams{\n\tFile: imagekit.NewFile(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"),\n\tFileName: "fileName",\n}\n```\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nWe retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit,\nand >=500 Internal errors.\n\nYou can use the `WithMaxRetries` option to configure or disable this:\n\n```go\n// Configure the default for all requests:\nclient := imagekit.NewClient(\n\toption.WithMaxRetries(0), // default is 2\n)\n\n// Override per-request:\nclient.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithMaxRetries(5),\n)\n```\n\n\n### Accessing raw response data (e.g. response headers)\n\nYou can access the raw HTTP response data by using the `option.WithResponseInto()` request option. This is useful when\nyou need to examine response headers, status codes, or other details.\n\n```go\n// Create a variable to store the HTTP response\nvar response *http.Response\nresponse, err := client.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithResponseInto(&response),\n)\nif err != nil {\n\t// handle error\n}\nfmt.Printf("%+v\\n", response)\n\nfmt.Printf("Status Code: %d\\n", response.StatusCode)\nfmt.Printf("Headers: %+#v\\n", response.Header)\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.Get`, `client.Post`, and other HTTP verbs.\n`RequestOptions` on the client, such as retries, will be respected when making these requests.\n\n```go\nvar (\n // params can be an io.Reader, a []byte, an encoding/json serializable object,\n // or a "…Params" struct defined in this library.\n params map[string]interface{}\n\n // result can be an []byte, *http.Response, a encoding/json deserializable object,\n // or a model defined in this library.\n result *http.Response\n)\nerr := client.Post(context.Background(), "/unspecified", params, &result)\nif err != nil {\n …\n}\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use either the `SDK_PackageOptionName.WithQuerySet()`\nor the `SDK_PackageOptionName.WithJSONSet()` methods.\n\n```go\nparams := FooNewParams{\n ID: SDK_PackageName.F("id_xxxx"),\n Data: SDK_PackageName.F(FooNewParamsData{\n FirstName: SDK_PackageName.F("John"),\n }),\n}\nclient.Foo.New(context.Background(), params, SDK_PackageOptionName.WithJSONSet("data.last_name", "Doe"))\n```\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may either access the raw JSON of the response as a string\nwith `result.JSON.RawJSON()`, or get the raw JSON of a particular field on the result with\n`result.JSON.Foo.Raw()`.\n\nAny fields that are not present on the response struct will be saved and can be accessed by `result.JSON.ExtraFields()` which returns the extra fields as a `map[string]Field`.\n\n### Middleware\n\nWe provide `SDK_PackageOptionName.WithMiddleware` which applies the given\nmiddleware to requests.\n\n```go\nfunc Logger(req *http.Request, next SDK_PackageOptionName.MiddlewareNext) (res *http.Response, err error) {\n\t// Before the request\n\tstart := time.Now()\n\tLogReq(req)\n\n\t// Forward the request to the next handler\n\tres, err = next(req)\n\n\t// Handle stuff after the request\n\tend := time.Now()\n\tLogRes(res, err, start - end)\n\n return res, err\n}\n\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\tSDK_PackageOptionName.WithMiddleware(Logger),\n)\n```\n\nWhen multiple middlewares are provided as variadic arguments, the middlewares\nare applied left to right. If `SDK_PackageOptionName.WithMiddleware` is given\nmultiple times, for example first in the client then the method, the\nmiddleware in the client will run first and the middleware given in the method\nwill run next.\n\nYou may also replace the default `http.Client` with\n`SDK_PackageOptionName.WithHTTPClient(client)`. Only one http client is\naccepted (this overwrites any previous client) and receives requests after any\nmiddleware has been applied.\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-go/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', }, { - language: 'typescript', + language: 'java', content: - "# Image Kit TypeScript API Library\n\n[![NPM version](https://img.shields.io/npm/v/@imagekit/nodejs.svg?label=npm%20(stable))](https://npmjs.org/package/@imagekit/nodejs) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@imagekit/nodejs)\n\nThis library provides convenient access to the Image Kit REST API from server-side TypeScript or JavaScript.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n```sh\nnpm install @imagekit/nodejs\n```\n\n\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n\n```js\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n});\n\nconsole.log(response.videoCodec);\n```\n\n\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst params: ImageKit.FileUploadParams = {\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n};\nconst response: ImageKit.FileUploadResponse = await client.files.upload(params);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed in many different forms:\n- `File` (or an object with the same structure)\n- a `fetch` `Response` (or an object with the same structure)\n- an `fs.ReadStream`\n- the return value of our `toFile` helper\n\n```ts\nimport fs from 'fs';\nimport ImageKit, { toFile } from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\n// If you have access to Node `fs` we recommend using `fs.createReadStream()`:\nawait client.files.upload({ file: fs.createReadStream('/path/to/file'), fileName: 'fileName' });\n\n// Or if you have the web `File` API you can pass a `File` instance:\nawait client.files.upload({ file: new File(['my bytes'], 'file'), fileName: 'fileName' });\n\n// You can also pass a `fetch` `Response`:\nawait client.files.upload({ file: await fetch('https://somesite/file'), fileName: 'fileName' });\n\n// Finally, if none of the above are convenient, you can use our `toFile` helper:\nawait client.files.upload({\n file: await toFile(Buffer.from('my bytes'), 'file'),\n fileName: 'fileName',\n});\nawait client.files.upload({\n file: await toFile(new Uint8Array([0, 1, 2]), 'file'),\n fileName: 'fileName',\n});\n```\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n\n```ts\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .catch(async (err) => {\n if (err instanceof ImageKit.APIError) {\n console.log(err.status); // 400\n console.log(err.name); // BadRequestError\n console.log(err.headers); // {server: 'nginx', ...}\n } else {\n throw err;\n }\n });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n\n```js\n// Configure the default for all requests:\nconst client = new ImageKit({\n maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n\n```ts\n// Configure the default for all requests:\nconst client = new ImageKit({\n timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n\n\n\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n\n```ts\nconst client = new ImageKit();\n\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: response, response: raw } = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(response.videoCodec);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `IMAGE_KIT_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new ImageKit({\n logger: logger.child({ name: 'ImageKit' }),\n logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.\nOptions on the client, such as retries, will be respected when making these requests.\n\n```ts\nawait client.post('/some/path', {\n body: { some_prop: 'foo' },\n query: { some_query_arg: 'bar' },\n});\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented\nparameter. This library doesn't validate at runtime that the request matches the type, so any extra values you\nsend will be sent as-is.\n\n```ts\nclient.files.upload({\n // ...\n // @ts-expect-error baz is not yet public\n baz: 'undocumented option',\n});\n```\n\nFor requests with the `GET` verb, any extra params will be in the query, all other requests will send the\nextra param in the body.\n\nIf you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may access the response object with `// @ts-expect-error` on\nthe response object, or cast the response object to the requisite type. Like the request params, we do not\nvalidate or strip extra properties from the response from the API.\n\n### Customizing the fetch client\n\nBy default, this library expects a global `fetch` function is defined.\n\nIf you want to use a different `fetch` function, you can either polyfill the global:\n\n```ts\nimport fetch from 'my-fetch';\n\nglobalThis.fetch = fetch;\n```\n\nOr pass it to the client:\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport fetch from 'my-fetch';\n\nconst client = new ImageKit({ fetch });\n```\n\n### Fetch options\n\nIf you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n // `RequestInit` options\n },\n});\n```\n\n#### Configuring proxies\n\nTo modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy\noptions to requests:\n\n **Node** [[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport * as undici from 'undici';\n\nconst proxyAgent = new undici.ProxyAgent('http://localhost:8888');\nconst client = new ImageKit({\n fetchOptions: {\n dispatcher: proxyAgent,\n },\n});\n```\n\n **Bun** [[docs](https://bun.sh/guides/http/proxy)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n proxy: 'http://localhost:8888',\n },\n});\n```\n\n **Deno** [[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]\n\n```ts\nimport ImageKit from 'npm:@imagekit/nodejs';\n\nconst httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });\nconst client = new ImageKit({\n fetchOptions: {\n client: httpClient,\n },\n});\n```\n\n## Frequently Asked Questions\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-nodejs/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n", + '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.client.ImageKitClientAsync;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.MultipartField;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.core.http.Headers;\nimport io.imagekit.core.http.HttpResponseFor;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.JsonMissing;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', }, { - language: 'ruby', + language: 'kotlin', content: - '# Image Kit Ruby API library\n\nThe Image Kit Ruby library provides convenient access to the Image Kit REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/imagekit-developer/imagekit-ruby#Sorbet) for usage with Sorbet. The standard library\'s `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nDocumentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/imagekitio).\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference).\n\n## Installation\n\nTo use this gem, install via Bundler by adding the following to your application\'s `Gemfile`:\n\n\n\n```ruby\ngem "imagekitio", "~> 0.0.1"\n```\n\n\n\n## Usage\n\n```ruby\nrequire "bundler/setup"\nrequire "imagekitio"\n\nimage_kit = Imagekitio::Client.new(\n private_key: ENV["IMAGEKIT_PRIVATE_KEY"], # This is the default and can be omitted\n password: ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"] # This is the default and can be omitted\n)\n\nresponse = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\nputs(response.videoCodec)\n```\n\n\n\n\n\n### File uploads\n\nRequest parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, [`StringIO`](https://rubyapi.org/3.2/o/stringio), or more.\n\n```ruby\nrequire "pathname"\n\n# Use `Pathname` to send the filename and/or avoid paging a large file into memory:\nresponse = image_kit.files.upload(file: Pathname("/path/to/file"))\n\n# Alternatively, pass file contents or a `StringIO` directly:\nresponse = image_kit.files.upload(file: File.read("/path/to/file"))\n\n# Or, to control the filename and/or content type:\nfile = Imagekitio::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…")\nresponse = image_kit.files.upload(file: file)\n\nputs(response.videoCodec)\n```\n\nNote that you can also pass a raw `IO` descriptor, but this disables retries, as the library can\'t be sure if the descriptor is a file or pipe (which cannot be rewound).\n\n### Handling errors\n\nWhen the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Imagekitio::Errors::APIError` will be thrown:\n\n```ruby\nbegin\n file = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n )\nrescue Imagekitio::Errors::APIConnectionError => e\n puts("The server could not be reached")\n puts(e.cause) # an underlying Exception, likely raised within `net/http`\nrescue Imagekitio::Errors::RateLimitError => e\n puts("A 429 status code was received; we should back off a bit.")\nrescue Imagekitio::Errors::APIStatusError => e\n puts("Another non-200-range status code was received")\n puts(e.status)\nend\n```\n\nError codes are as follows:\n\n| Cause | Error Type |\n| ---------------- | -------------------------- |\n| HTTP 400 | `BadRequestError` |\n| HTTP 401 | `AuthenticationError` |\n| HTTP 403 | `PermissionDeniedError` |\n| HTTP 404 | `NotFoundError` |\n| HTTP 409 | `ConflictError` |\n| HTTP 422 | `UnprocessableEntityError` |\n| HTTP 429 | `RateLimitError` |\n| HTTP >= 500 | `InternalServerError` |\n| Other HTTP error | `APIStatusError` |\n| Timeout | `APITimeoutError` |\n| Network error | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\n\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.\n\nYou can use the `max_retries` option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n max_retries: 0 # default is 2\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {max_retries: 5}\n)\n```\n\n### Timeouts\n\nBy default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n timeout: nil # default is 60\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {timeout: 5}\n)\n```\n\nOn timeout, `Imagekitio::Errors::APITimeoutError` is raised.\n\nNote that requests that time out are retried by default.\n\n## Advanced concepts\n\n### BaseModel\n\nAll parameter and response objects inherit from `Imagekitio::Internal::Type::BaseModel`, which provides several conveniences, including:\n\n1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.\n\n2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.\n\n3. Both instances and the classes themselves can be pretty-printed.\n\n4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.\n\n### Making custom or undocumented requests\n\n#### Undocumented properties\n\nYou can send undocumented parameters to any endpoint, and read undocumented response properties, like so:\n\nNote: the `extra_` parameters of the same name overrides the documented parameters.\n\n```ruby\nresponse =\n image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {\n extra_query: {my_query_parameter: value},\n extra_body: {my_body_parameter: value},\n extra_headers: {"my-header": value}\n }\n )\n\nputs(response[:my_undocumented_property])\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:\n\n```ruby\nresponse = client.request(\n method: :post,\n path: \'/undocumented/endpoint\',\n query: {"dog": "woof"},\n headers: {"useful-header": "interesting-value"},\n body: {"hello": "world"}\n)\n```\n\n### Concurrency & connection pooling\n\nThe `Imagekitio::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.\n\nEach instance of `Imagekitio::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.\n\nWhen all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.\n\nUnless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.\n\n## Sorbet\n\nThis library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.\n\nYou can provide typesafe request parameters like so:\n\n```ruby\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n```\n\nOr, equivalently:\n\n```ruby\n# Hashes work, but are not typesafe:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\n# You can also splat a full Params class:\nparams = Imagekitio::FileUploadParams.new(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\nimage_kit.files.upload(**params)\n```\n\n### Enums\n\nSince this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:\n\n```ruby\n# :all\nputs(Imagekitio::AssetListParams::FileType::ALL)\n\n# Revealed type: `T.all(Imagekitio::AssetListParams::FileType, Symbol)`\nT.reveal_type(Imagekitio::AssetListParams::FileType::ALL)\n```\n\nEnum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:\n\n```ruby\n# Using the enum constants preserves the tagged type information:\nimage_kit.assets.list(\n file_type: Imagekitio::AssetListParams::FileType::ALL,\n # …\n)\n\n# Literal values are also permissible:\nimage_kit.assets.list(\n file_type: :all,\n # …\n)\n```\n\n## Versioning\n\nThis package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.\n\nThis package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.\n\n## Requirements\n\nRuby 3.2.0 or higher.\n\n## Contributing\n\nSee [the contributing documentation](https://github.com/imagekit-developer/imagekit-ruby/tree/master/CONTRIBUTING.md).\n', + '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\nThe Image Kit Kotlin SDK is similar to the Image Kit Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', }, { - language: 'java', + language: 'php', content: - '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.client.ImageKitClientAsync;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.MultipartField;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.core.http.Headers;\nimport io.imagekit.core.http.HttpResponseFor;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.JsonMissing;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', + '# Image Kit PHP API Library\n\nThe Image Kit PHP library provides convenient access to the Image Kit REST API from any PHP 8.1.0+ application.\n\n## Installation\n\nTo use this package, install via Composer by adding the following to your application\'s `composer.json`:\n\n```json\n{\n "repositories": [\n {\n "type": "vcs",\n "url": "git@github.com:stainless-sdks/imagekit-php.git"\n }\n ],\n "require": {\n "imagekit/imagekit": "dev-main"\n }\n}\n```\n\n## Usage\n\n```php\nfiles->upload(\n file: FileParam::fromString(\'https://www.example.com/public-url.jpg\', filename: uniqid(\'file-upload-\', true)),\n fileName: \'file-name.jpg\',\n);\n\nvar_dump($response->videoCodec);\n```', }, { - language: 'kotlin', + language: 'python', content: - '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\nThe Image Kit Kotlin SDK is similar to the Image Kit Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Python API library\n\n\n[![PyPI version](https://img.shields.io/pypi/v/imagekitio.svg?label=pypi%20(stable))](https://pypi.org/project/imagekitio/)\n\nThe Image Kit Python library provides convenient access to the Image Kit REST API from any Python 3.9+\napplication. The library includes type definitions for all request params and response fields,\nand offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n## Installation\n\n```sh\n# install from PyPI\npip install imagekitio\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nresponse = client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.video_codec)\n```\n\nWhile you can provide a `private_key` keyword argument,\nwe recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nto add `IMAGEKIT_PRIVATE_KEY="My Private Key"` to your `.env` file\nso that your Private Key is not stored in source control.\n\n## Async usage\n\nSimply import `AsyncImageKit` instead of `ImageKit` and use `await` with each API call:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import AsyncImageKit\n\nclient = AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nasync def main() -> None:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n### With aiohttp\n\nBy default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.\n\nYou can enable this by installing `aiohttp`:\n\n```sh\n# install from PyPI\npip install imagekitio[aiohttp]\n```\n\nThen you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import DefaultAioHttpClient\nfrom imagekitio import AsyncImageKit\n\nasync def main() -> None:\n async with AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n http_client=DefaultAioHttpClient(),\n) as client:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\n\n\n## Using types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:\n\n- Serializing back into JSON, `model.to_json()`\n- Converting to a dictionary, `model.to_dict()`\n\nTyped requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.\n\n\n\n## Nested params\n\nNested parameters are dictionaries, typed using `TypedDict`, for example:\n\n```python\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nresponse = client.files.upload(\n file=b"Example data",\n file_name="fileName",\n transformation={\n "post": [{\n "type": "thumbnail",\n "value": "w-150,h-150",\n }, {\n "protocol": "dash",\n "type": "abs",\n "value": "sr-240_360_480_720_1080",\n }]\n },\n)\nprint(response.transformation)\n```\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.\n\n```python\nfrom pathlib import Path\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nclient.files.upload(\n file=Path("/path/to/file"),\n file_name="fileName",\n)\n```\n\nThe async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.\n\n## Handling errors\n\nWhen the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `imagekitio.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (that is, 4xx or 5xx\nresponse), a subclass of `imagekitio.APIStatusError` is raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `imagekitio.APIError`.\n\n```python\nimport imagekitio\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\ntry:\n client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\nexcept imagekitio.APIConnectionError as e:\n print("The server could not be reached")\n print(e.__cause__) # an underlying Exception, likely raised within httpx.\nexcept imagekitio.RateLimitError as e:\n print("A 429 status code was received; we should back off a bit.")\nexcept imagekitio.APIStatusError as e:\n print("Another non-200-range status code was received")\n print(e.status_code)\n print(e.response)\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors are automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors are all retried by default.\n\nYou can use the `max_retries` option to configure or disable retry settings:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # default is 2\n max_retries=0,\n)\n\n# Or, configure per-request:\nclient.with_options(max_retries = 5).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\n### Timeouts\n\nBy default requests time out after 1 minute. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # 20 seconds (default is 1 minute)\n timeout=20.0,\n)\n\n# More granular control:\nclient = ImageKit(\n timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n)\n\n# Override per-request:\nclient.with_options(timeout = 5.0).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests that time out are [retried twice by default](#retries).\n\n\n\n## Advanced\n\n### Logging\n\nWe use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.\n\nYou can enable logging by setting the environment variable `IMAGE_KIT_LOG` to `info`.\n\n```shell\n$ export IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging.\n\n### How to tell whether `None` means `null` or missing\n\nIn an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:\n\n```py\nif response.my_field is None:\n if \'my_field\' not in response.model_fields_set:\n print(\'Got json like {}, without a "my_field" key present at all.\')\n else:\n print(\'Got json like {"my_field": null}.\')\n```\n\n### Accessing raw response data (e.g. headers)\n\nThe "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,\n\n```py\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\nresponse = client.files.with_raw_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.headers.get(\'X-My-Header\'))\n\nfile = response.parse() # get the object that `files.upload()` would have returned\nprint(file.video_codec)\n```\n\nThese methods return an [`APIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) object.\n\nThe async client returns an [`AsyncAPIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.\n\n#### `.with_streaming_response`\n\nThe above interface eagerly reads the full response body when you make the request, which may not always be what you want.\n\nTo stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.\n\n```python\nwith client.files.with_streaming_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n) as response :\n print(response.headers.get(\'X-My-Header\'))\n\n for line in response.iter_lines():\n print(line)\n```\n\nThe context manager is required so that the response will reliably be closed.\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API.\n\nIf you need to access undocumented endpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other\nhttp verbs. Options on the client will be respected (such as retries) when making this request.\n\n```py\nimport httpx\n\nresponse = client.post(\n "/foo",\n cast_to=httpx.Response,\n body={"my_param": True},\n)\n\nprint(response.headers.get("x-foo"))\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You\ncan also get all the extra fields on the Pydantic model as a dict with\n[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).\n\n### Configuring the HTTP client\n\nYou can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:\n\n- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)\n- Custom [transports](https://www.python-httpx.org/advanced/transports/)\n- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality\n\n```python\nimport httpx\nfrom imagekitio import ImageKit, DefaultHttpxClient\n\nclient = ImageKit(\n # Or use the `IMAGE_KIT_BASE_URL` env var\n base_url="http://my.test.server.example.com:8083",\n http_client=DefaultHttpxClient(proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),\n)\n```\n\nYou can also customize the client on a per-request basis by using `with_options()`:\n\n```python\nclient.with_options(http_client=DefaultHttpxClient(...))\n```\n\n### Managing HTTP resources\n\nBy default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.\n\n```py\nfrom imagekitio import ImageKit\n\nwith ImageKit() as client:\n # make requests here\n ...\n\n# HTTP client is now closed\n```\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you\'ve upgraded to the latest version but aren\'t seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport imagekitio\nprint(imagekitio.__version__)\n```\n\n## Requirements\n\nPython 3.9 or higher.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', }, { - language: 'csharp', + language: 'ruby', content: - '# Image Kit C# API Library\n\nThe Image Kit C# SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in C#.\n\n## Installation\n\n```bash\ngit clone git@github.com:stainless-sdks/imagekit-csharp.git\ndotnet add reference imagekit-csharp/src/ImageKit\n```\n\n## Requirements\n\nThis library requires .NET Standard 2.0 or later.\n\n## Usage\n\nSee the [`examples`](examples) directory for complete and runnable examples.\n\n```csharp\nImageKitClient client = new();\n\nFileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes("https://www.example.com/public-url.jpg"),\n FileName = "file-name.jpg",\n};\n\nvar response = await client.Files.Upload(parameters);\n\nConsole.WriteLine(response);\n```', + '# Image Kit Ruby API library\n\nThe Image Kit Ruby library provides convenient access to the Image Kit REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/imagekit-developer/imagekit-ruby#Sorbet) for usage with Sorbet. The standard library\'s `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nDocumentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/imagekitio).\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference).\n\n## Installation\n\nTo use this gem, install via Bundler by adding the following to your application\'s `Gemfile`:\n\n\n\n```ruby\ngem "imagekitio", "~> 0.0.1"\n```\n\n\n\n## Usage\n\n```ruby\nrequire "bundler/setup"\nrequire "imagekitio"\n\nimage_kit = Imagekitio::Client.new(\n private_key: ENV["IMAGEKIT_PRIVATE_KEY"], # This is the default and can be omitted\n password: ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"] # This is the default and can be omitted\n)\n\nresponse = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\nputs(response.videoCodec)\n```\n\n\n\n\n\n### File uploads\n\nRequest parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, [`StringIO`](https://rubyapi.org/3.2/o/stringio), or more.\n\n```ruby\nrequire "pathname"\n\n# Use `Pathname` to send the filename and/or avoid paging a large file into memory:\nresponse = image_kit.files.upload(file: Pathname("/path/to/file"))\n\n# Alternatively, pass file contents or a `StringIO` directly:\nresponse = image_kit.files.upload(file: File.read("/path/to/file"))\n\n# Or, to control the filename and/or content type:\nfile = Imagekitio::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…")\nresponse = image_kit.files.upload(file: file)\n\nputs(response.videoCodec)\n```\n\nNote that you can also pass a raw `IO` descriptor, but this disables retries, as the library can\'t be sure if the descriptor is a file or pipe (which cannot be rewound).\n\n### Handling errors\n\nWhen the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Imagekitio::Errors::APIError` will be thrown:\n\n```ruby\nbegin\n file = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n )\nrescue Imagekitio::Errors::APIConnectionError => e\n puts("The server could not be reached")\n puts(e.cause) # an underlying Exception, likely raised within `net/http`\nrescue Imagekitio::Errors::RateLimitError => e\n puts("A 429 status code was received; we should back off a bit.")\nrescue Imagekitio::Errors::APIStatusError => e\n puts("Another non-200-range status code was received")\n puts(e.status)\nend\n```\n\nError codes are as follows:\n\n| Cause | Error Type |\n| ---------------- | -------------------------- |\n| HTTP 400 | `BadRequestError` |\n| HTTP 401 | `AuthenticationError` |\n| HTTP 403 | `PermissionDeniedError` |\n| HTTP 404 | `NotFoundError` |\n| HTTP 409 | `ConflictError` |\n| HTTP 422 | `UnprocessableEntityError` |\n| HTTP 429 | `RateLimitError` |\n| HTTP >= 500 | `InternalServerError` |\n| Other HTTP error | `APIStatusError` |\n| Timeout | `APITimeoutError` |\n| Network error | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\n\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.\n\nYou can use the `max_retries` option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n max_retries: 0 # default is 2\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {max_retries: 5}\n)\n```\n\n### Timeouts\n\nBy default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n timeout: nil # default is 60\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {timeout: 5}\n)\n```\n\nOn timeout, `Imagekitio::Errors::APITimeoutError` is raised.\n\nNote that requests that time out are retried by default.\n\n## Advanced concepts\n\n### BaseModel\n\nAll parameter and response objects inherit from `Imagekitio::Internal::Type::BaseModel`, which provides several conveniences, including:\n\n1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.\n\n2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.\n\n3. Both instances and the classes themselves can be pretty-printed.\n\n4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.\n\n### Making custom or undocumented requests\n\n#### Undocumented properties\n\nYou can send undocumented parameters to any endpoint, and read undocumented response properties, like so:\n\nNote: the `extra_` parameters of the same name overrides the documented parameters.\n\n```ruby\nresponse =\n image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {\n extra_query: {my_query_parameter: value},\n extra_body: {my_body_parameter: value},\n extra_headers: {"my-header": value}\n }\n )\n\nputs(response[:my_undocumented_property])\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:\n\n```ruby\nresponse = client.request(\n method: :post,\n path: \'/undocumented/endpoint\',\n query: {"dog": "woof"},\n headers: {"useful-header": "interesting-value"},\n body: {"hello": "world"}\n)\n```\n\n### Concurrency & connection pooling\n\nThe `Imagekitio::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.\n\nEach instance of `Imagekitio::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.\n\nWhen all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.\n\nUnless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.\n\n## Sorbet\n\nThis library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.\n\nYou can provide typesafe request parameters like so:\n\n```ruby\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n```\n\nOr, equivalently:\n\n```ruby\n# Hashes work, but are not typesafe:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\n# You can also splat a full Params class:\nparams = Imagekitio::FileUploadParams.new(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\nimage_kit.files.upload(**params)\n```\n\n### Enums\n\nSince this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:\n\n```ruby\n# :all\nputs(Imagekitio::AssetListParams::FileType::ALL)\n\n# Revealed type: `T.all(Imagekitio::AssetListParams::FileType, Symbol)`\nT.reveal_type(Imagekitio::AssetListParams::FileType::ALL)\n```\n\nEnum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:\n\n```ruby\n# Using the enum constants preserves the tagged type information:\nimage_kit.assets.list(\n file_type: Imagekitio::AssetListParams::FileType::ALL,\n # …\n)\n\n# Literal values are also permissible:\nimage_kit.assets.list(\n file_type: :all,\n # …\n)\n```\n\n## Versioning\n\nThis package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.\n\nThis package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.\n\n## Requirements\n\nRuby 3.2.0 or higher.\n\n## Contributing\n\nSee [the contributing documentation](https://github.com/imagekit-developer/imagekit-ruby/tree/master/CONTRIBUTING.md).\n', }, { - language: 'cli', + language: 'terraform', content: - "# Image Kit CLI\n\nThe official CLI for the [Image Kit REST API](https://imagekit.io/docs/api-reference).\n\n## Installation\n\n### Installing with Go\n\nTo test or install the CLI locally, you need [Go](https://go.dev/doc/install) version 1.22 or later installed.\n\n~~~sh\ngo install 'github.com/stainless-sdks/imagekit-cli/cmd/imagekit@latest'\n~~~\n\nOnce you have run `go install`, the binary is placed in your Go bin directory:\n\n- **Default location**: `$HOME/go/bin` (or `$GOPATH/bin` if GOPATH is set)\n- **Check your path**: Run `go env GOPATH` to see the base directory\n\nIf commands aren't found after installation, add the Go bin directory to your PATH:\n\n~~~sh\n# Add to your shell profile (.zshrc, .bashrc, etc.)\nexport PATH=\"$PATH:$(go env GOPATH)/bin\"\n~~~\n\n### Running Locally\n\nAfter cloning the git repository for this project, you can use the\n`scripts/run` script to run the tool locally:\n\n~~~sh\n./scripts/run args...\n~~~\n\n## Usage\n\nThe CLI follows a resource-based command structure:\n\n~~~sh\nimagekit [resource] [flags...]\n~~~\n\n~~~sh\nimagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name file-name.jpg\n~~~\n\nFor details about specific commands, use the `--help` flag.\n\n### Environment variables\n\n| Environment variable | Description | Required | Default value |\n| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------- |\n| `IMAGEKIT_PRIVATE_KEY` | Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n | yes | |\n| `OPTIONAL_IMAGEKIT_IGNORES_THIS` | ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n | no | `\"do_not_set\"` |\n| `IMAGEKIT_WEBHOOK_SECRET` | Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n | no | `null` |\n\n### Global flags\n\n- `--private-key` - Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n (can also be set with `IMAGEKIT_PRIVATE_KEY` env var)\n- `--password` - ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n (can also be set with `OPTIONAL_IMAGEKIT_IGNORES_THIS` env var)\n- `--webhook-secret` - Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n (can also be set with `IMAGEKIT_WEBHOOK_SECRET` env var)\n- `--help` - Show command line usage\n- `--debug` - Enable debug logging (includes HTTP request/response details)\n- `--version`, `-v` - Show the CLI version\n- `--base-url` - Use a custom API backend URL\n- `--format` - Change the output format (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--format-error` - Change the output format for errors (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--transform` - Transform the data output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n- `--transform-error` - Transform the error output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n\n### Passing files as arguments\n\nTo pass files to your API, you can use the `@myfile.ext` syntax:\n\n~~~bash\nimagekit --arg @abe.jpg\n~~~\n\nFiles can also be passed inside JSON or YAML blobs:\n\n~~~bash\nimagekit --arg '{image: \"@abe.jpg\"}'\n# Equivalent:\nimagekit < --username '\\@abe'\n~~~\n\n#### Explicit encoding\n\nFor JSON endpoints, the CLI tool does filetype sniffing to determine whether the\nfile contents should be sent as a string literal (for plain text files) or as a\nbase64-encoded string literal (for binary files). If you need to explicitly send\nthe file as either plain text or base64-encoded data, you can use\n`@file://myfile.txt` (for string encoding) or `@data://myfile.dat` (for\nbase64-encoding). Note that absolute paths will begin with `@file://` or\n`@data://`, followed by a third `/` (for example, `@file:///tmp/file.txt`).\n\n~~~bash\nimagekit --arg @data://file.txt\n~~~\n\n## Linking different Go SDK versions\n\nYou can link the CLI against a different version of the Image Kit Go SDK\nfor development purposes using the `./scripts/link` script.\n\nTo link to a specific version from a repository (version can be a branch,\ngit tag, or commit hash):\n\n~~~bash\n./scripts/link github.com/org/repo@version\n~~~\n\nTo link to a local copy of the SDK:\n\n~~~bash\n./scripts/link ../path/to/imagekit-go\n~~~\n\nIf you run the link script without any arguments, it will default to `../imagekit-go`.\n", + '# Image Kit Terraform Provider\n\nThe [Image Kit Terraform provider](https://registry.terraform.io/providers/stainless-sdks/imagekit/latest/docs) provides convenient access to\nthe [Image Kit REST API](https://imagekit.io/docs/api-reference) from Terraform.\n\n\n\n## Requirements\n\nThis provider requires Terraform CLI 1.0 or later. You can [install it for your system](https://developer.hashicorp.com/terraform/install)\non Hashicorp\'s website.\n\n## Usage\n\nAdd the following to your `main.tf` file:\n\n\n\n```hcl\n# Declare the provider and version\nterraform {\n required_providers {\n SDK_ProviderTypeName = {\n source = "stainless-sdks/imagekit"\n version = "~> 0.0.1"\n }\n }\n}\n\n# Initialize the provider\nprovider "imagekit" {\n # Your ImageKit private API key (starts with `private_`).\n You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n private_key = "My Private Key" # or set IMAGEKIT_PRIVATE_KEY env variable\n # ImageKit uses your API key as username and ignores the password. \n The SDK sets a dummy value. You can ignore this field.\n password = "My Password" # or set OPTIONAL_IMAGEKIT_IGNORES_THIS env variable\n # Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\n You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\n Only required if you\'re using webhooks.\n webhook_secret = "My Webhook Secret" # or set IMAGEKIT_WEBHOOK_SECRET env variable\n}\n\n# Configure a resource\nresource "imagekit_account_origin" "example_account_origin" {\n access_key = "AKIAIOSFODNN7EXAMPLE"\n bucket = "product-images"\n name = "US S3 Storage"\n secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"\n type = "S3"\n base_url_for_canonical_header = "https://cdn.example.com"\n include_canonical_header = false\n prefix = "raw-assets"\n}\n```\n\n\n\nInitialize your project by running `terraform init` in the directory.\n\nAdditional examples can be found in the [./examples](./examples) folder within this repository, and you can\nrefer to the full documentation on [the Terraform Registry](https://registry.terraform.io/providers/stainless-sdks/imagekit/latest/docs).\n\n### Provider Options\nWhen you initialize the provider, the following options are supported. It is recommended to use environment variables for sensitive values like access tokens.\nIf an environment variable is provided, then the option does not need to be set in the terraform source.\n\n| Property | Environment variable | Required | Default value |\n| -------------- | -------------------------------- | -------- | -------------- |\n| private_key | `IMAGEKIT_PRIVATE_KEY` | true | — |\n| webhook_secret | `IMAGEKIT_WEBHOOK_SECRET` | false | — |\n| password | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-terraform/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', }, { - language: 'php', + language: 'typescript', content: - '# Image Kit PHP API Library\n\nThe Image Kit PHP library provides convenient access to the Image Kit REST API from any PHP 8.1.0+ application.\n\n## Installation\n\nTo use this package, install via Composer by adding the following to your application\'s `composer.json`:\n\n```json\n{\n "repositories": [\n {\n "type": "vcs",\n "url": "git@github.com:stainless-sdks/imagekit-php.git"\n }\n ],\n "require": {\n "imagekit/imagekit": "dev-main"\n }\n}\n```\n\n## Usage\n\n```php\nfiles->upload(\n file: FileParam::fromString(\'https://www.example.com/public-url.jpg\', filename: uniqid(\'file-upload-\', true)),\n fileName: \'file-name.jpg\',\n);\n\nvar_dump($response->videoCodec);\n```', + "# Image Kit TypeScript API Library\n\n[![NPM version](https://img.shields.io/npm/v/@imagekit/nodejs.svg?label=npm%20(stable))](https://npmjs.org/package/@imagekit/nodejs) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@imagekit/nodejs)\n\nThis library provides convenient access to the Image Kit REST API from server-side TypeScript or JavaScript.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n```sh\nnpm install @imagekit/nodejs\n```\n\n\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n\n```js\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n});\n\nconsole.log(response.videoCodec);\n```\n\n\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst params: ImageKit.FileUploadParams = {\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n};\nconst response: ImageKit.FileUploadResponse = await client.files.upload(params);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed in many different forms:\n- `File` (or an object with the same structure)\n- a `fetch` `Response` (or an object with the same structure)\n- an `fs.ReadStream`\n- the return value of our `toFile` helper\n\n```ts\nimport fs from 'fs';\nimport ImageKit, { toFile } from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\n// If you have access to Node `fs` we recommend using `fs.createReadStream()`:\nawait client.files.upload({ file: fs.createReadStream('/path/to/file'), fileName: 'fileName' });\n\n// Or if you have the web `File` API you can pass a `File` instance:\nawait client.files.upload({ file: new File(['my bytes'], 'file'), fileName: 'fileName' });\n\n// You can also pass a `fetch` `Response`:\nawait client.files.upload({ file: await fetch('https://somesite/file'), fileName: 'fileName' });\n\n// Finally, if none of the above are convenient, you can use our `toFile` helper:\nawait client.files.upload({\n file: await toFile(Buffer.from('my bytes'), 'file'),\n fileName: 'fileName',\n});\nawait client.files.upload({\n file: await toFile(new Uint8Array([0, 1, 2]), 'file'),\n fileName: 'fileName',\n});\n```\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n\n```ts\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .catch(async (err) => {\n if (err instanceof ImageKit.APIError) {\n console.log(err.status); // 400\n console.log(err.name); // BadRequestError\n console.log(err.headers); // {server: 'nginx', ...}\n } else {\n throw err;\n }\n });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n\n```js\n// Configure the default for all requests:\nconst client = new ImageKit({\n maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n\n```ts\n// Configure the default for all requests:\nconst client = new ImageKit({\n timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n\n\n\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n\n```ts\nconst client = new ImageKit();\n\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: response, response: raw } = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(response.videoCodec);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `IMAGE_KIT_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new ImageKit({\n logger: logger.child({ name: 'ImageKit' }),\n logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.\nOptions on the client, such as retries, will be respected when making these requests.\n\n```ts\nawait client.post('/some/path', {\n body: { some_prop: 'foo' },\n query: { some_query_arg: 'bar' },\n});\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented\nparameter. This library doesn't validate at runtime that the request matches the type, so any extra values you\nsend will be sent as-is.\n\n```ts\nclient.files.upload({\n // ...\n // @ts-expect-error baz is not yet public\n baz: 'undocumented option',\n});\n```\n\nFor requests with the `GET` verb, any extra params will be in the query, all other requests will send the\nextra param in the body.\n\nIf you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may access the response object with `// @ts-expect-error` on\nthe response object, or cast the response object to the requisite type. Like the request params, we do not\nvalidate or strip extra properties from the response from the API.\n\n### Customizing the fetch client\n\nBy default, this library expects a global `fetch` function is defined.\n\nIf you want to use a different `fetch` function, you can either polyfill the global:\n\n```ts\nimport fetch from 'my-fetch';\n\nglobalThis.fetch = fetch;\n```\n\nOr pass it to the client:\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport fetch from 'my-fetch';\n\nconst client = new ImageKit({ fetch });\n```\n\n### Fetch options\n\nIf you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n // `RequestInit` options\n },\n});\n```\n\n#### Configuring proxies\n\nTo modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy\noptions to requests:\n\n **Node** [[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport * as undici from 'undici';\n\nconst proxyAgent = new undici.ProxyAgent('http://localhost:8888');\nconst client = new ImageKit({\n fetchOptions: {\n dispatcher: proxyAgent,\n },\n});\n```\n\n **Bun** [[docs](https://bun.sh/guides/http/proxy)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n proxy: 'http://localhost:8888',\n },\n});\n```\n\n **Deno** [[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]\n\n```ts\nimport ImageKit from 'npm:@imagekit/nodejs';\n\nconst httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });\nconst client = new ImageKit({\n fetchOptions: {\n client: httpClient,\n },\n});\n```\n\n## Frequently Asked Questions\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-nodejs/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n", }, ]; From 853429c552a32b3e46246bf9849dbebcc6e41e50 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:54:43 +0000 Subject: [PATCH 14/36] chore(internal): more robust bootstrap script --- scripts/bootstrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/bootstrap b/scripts/bootstrap index a8b69ff3..2e315f53 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,7 +4,7 @@ set -e cd "$(dirname "$0")/.." -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "${SKIP_BREW:-}" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { echo -n "==> Install Homebrew dependencies? (y/N): " read -r response From 60cdc4d83743c3802a507d67d0de2529a60c17d9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 05:08:51 +0000 Subject: [PATCH 15/36] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 6d0a83a8..a1b609ac 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: da0c89d794fefcf600a4ddfc78553c2a +config_hash: 94f48fd13b7d41b8b6a203a3a8cee9ed From 8b9992f6465052eb1b215bf3ed230dbfef5ad4f6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 13:27:20 +0000 Subject: [PATCH 16/36] chore: restructure docs search code --- packages/mcp-server/src/local-docs-search.ts | 2542 +++++++++--------- 1 file changed, 1271 insertions(+), 1271 deletions(-) diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 1465f6f4..828a0523 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -69,24 +69,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## create\n\n`client.customMetadataFields.create(label: string, name: string, schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }): { id: string; label: string; name: string; schema: object; }`\n\n**post** `/v1/customMetadataFields`\n\nThis API creates a new custom metadata field. Once a custom metadata field is created either through this API or using the dashboard UI, its value can be set on the assets. The value of a field for an asset can be set using the media library UI or programmatically through upload or update assets API.\n\n\n### Parameters\n\n- `label: string`\n Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI.\n\n- `name: string`\n API name of the custom metadata field. This should be unique across all (including deleted) custom metadata fields.\n\n- `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n - `type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'`\n Type of the custom metadata field.\n - `defaultValue?: string | number | boolean | string | number | boolean[]`\n The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field.\n\n - `isValueRequired?: boolean`\n Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body.\n\n - `maxLength?: number`\n Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `maxValue?: string | number`\n Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `minLength?: number`\n Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `minValue?: string | number`\n Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `selectOptions?: string | number | boolean[]`\n An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }`\n Object containing details of a custom metadata field.\n\n - `id: string`\n - `label: string`\n - `name: string`\n - `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.create({\n label: 'price',\n name: 'price',\n schema: { type: 'Number' },\n});\n\nconsole.log(customMetadataField);\n```", perLanguage: { - cli: { - method: 'customMetadataFields create', - example: - "imagekit custom-metadata-fields create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --label price \\\n --name price \\\n --schema '{type: Number}'", - }, - csharp: { - method: 'CustomMetadataFields.Create', - example: - 'CustomMetadataFieldCreateParams parameters = new()\n{\n Label = "price",\n Name = "price",\n Schema = new()\n {\n Type = Type.Number,\n DefaultValue = new(\n\n [\n new DefaultValueItem(true),\n new DefaultValueItem(10),\n new DefaultValueItem("Hello"),\n ]\n ),\n IsValueRequired = true,\n MaxLength = 0,\n MaxValue = 3000,\n MinLength = 0,\n MinValue = 1000,\n SelectOptions =\n [\n "small", "medium", "large", 30, 40, true\n ],\n },\n};\n\nvar customMetadataField = await client.CustomMetadataFields.Create(parameters);\n\nConsole.WriteLine(customMetadataField);', - }, - go: { - method: 'client.CustomMetadataFields.New', + typescript: { + method: 'client.customMetadataFields.create', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.New(context.TODO(), imagekit.CustomMetadataFieldNewParams{\n\t\tLabel: "price",\n\t\tName: "price",\n\t\tSchema: imagekit.CustomMetadataFieldNewParamsSchema{\n\t\t\tType: "Number",\n\t\t\tMinValue: imagekit.CustomMetadataFieldNewParamsSchemaMinValueUnion{\n\t\t\t\tOfFloat: imagekit.Float(1000),\n\t\t\t},\n\t\t\tMaxValue: imagekit.CustomMetadataFieldNewParamsSchemaMaxValueUnion{\n\t\t\t\tOfFloat: imagekit.Float(3000),\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataField.ID)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.create({\n label: 'price',\n name: 'price',\n schema: {\n type: 'Number',\n minValue: 1000,\n maxValue: 3000,\n },\n});\n\nconsole.log(customMetadataField.id);", }, - http: { + python: { + method: 'custom_metadata_fields.create', example: - 'curl https://api.imagekit.io/v1/customMetadataFields \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "label": "price",\n "name": "price",\n "schema": {\n "type": "Number",\n "maxValue": 3000,\n "minValue": 1000\n }\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.create(\n label="price",\n name="price",\n schema={\n "type": "Number",\n "min_value": 1000,\n "max_value": 3000,\n },\n)\nprint(custom_metadata_field.id)', }, java: { method: 'customMetadataFields().create', @@ -98,25 +89,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: CustomMetadataFieldCreateParams = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build()\n val customMetadataField: CustomMetadataField = client.customMetadataFields().create(params)\n}', }, - php: { - method: 'customMetadataFields->create', - example: - "customMetadataFields->create(\n label: 'price',\n name: 'price',\n schema: [\n 'type' => 'Number',\n 'defaultValue' => [true, 10, 'Hello'],\n 'isValueRequired' => true,\n 'maxLength' => 0,\n 'maxValue' => 3000,\n 'minLength' => 0,\n 'minValue' => 1000,\n 'selectOptions' => ['small', 'medium', 'large', 30, 40, true],\n ],\n);\n\nvar_dump($customMetadataField);", - }, - python: { - method: 'custom_metadata_fields.create', + go: { + method: 'client.CustomMetadataFields.New', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.create(\n label="price",\n name="price",\n schema={\n "type": "Number",\n "min_value": 1000,\n "max_value": 3000,\n },\n)\nprint(custom_metadata_field.id)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.New(context.TODO(), imagekit.CustomMetadataFieldNewParams{\n\t\tLabel: "price",\n\t\tName: "price",\n\t\tSchema: imagekit.CustomMetadataFieldNewParamsSchema{\n\t\t\tType: "Number",\n\t\t\tMinValue: imagekit.CustomMetadataFieldNewParamsSchemaMinValueUnion{\n\t\t\t\tOfFloat: imagekit.Float(1000),\n\t\t\t},\n\t\t\tMaxValue: imagekit.CustomMetadataFieldNewParamsSchemaMaxValueUnion{\n\t\t\t\tOfFloat: imagekit.Float(3000),\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataField.ID)\n}\n', }, ruby: { method: 'custom_metadata_fields.create', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.create(label: "price", name: "price", schema: {type: :Number})\n\nputs(custom_metadata_field)', }, - typescript: { - method: 'client.customMetadataFields.create', + cli: { + method: 'customMetadataFields create', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.create({\n label: 'price',\n name: 'price',\n schema: {\n type: 'Number',\n minValue: 1000,\n maxValue: 3000,\n },\n});\n\nconsole.log(customMetadataField.id);", + "imagekit custom-metadata-fields create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --label price \\\n --name price \\\n --schema '{type: Number}'", + }, + php: { + method: 'customMetadataFields->create', + example: + "customMetadataFields->create(\n label: 'price',\n name: 'price',\n schema: [\n 'type' => 'Number',\n 'defaultValue' => [true, 10, 'Hello'],\n 'isValueRequired' => true,\n 'maxLength' => 0,\n 'maxValue' => 3000,\n 'minLength' => 0,\n 'minValue' => 1000,\n 'selectOptions' => ['small', 'medium', 'large', 30, 40, true],\n ],\n);\n\nvar_dump($customMetadataField);", + }, + csharp: { + method: 'CustomMetadataFields.Create', + example: + 'CustomMetadataFieldCreateParams parameters = new()\n{\n Label = "price",\n Name = "price",\n Schema = new()\n {\n Type = Type.Number,\n DefaultValue = new(\n\n [\n new DefaultValueItem(true),\n new DefaultValueItem(10),\n new DefaultValueItem("Hello"),\n ]\n ),\n IsValueRequired = true,\n MaxLength = 0,\n MaxValue = 3000,\n MinLength = 0,\n MinValue = 1000,\n SelectOptions =\n [\n "small", "medium", "large", 30, 40, true\n ],\n },\n};\n\nvar customMetadataField = await client.CustomMetadataFields.Create(parameters);\n\nConsole.WriteLine(customMetadataField);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/customMetadataFields \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "label": "price",\n "name": "price",\n "schema": {\n "type": "Number",\n "maxValue": 3000,\n "minValue": 1000\n }\n }\'', }, }, }, @@ -135,24 +135,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## list\n\n`client.customMetadataFields.list(folderPath?: string, includeDeleted?: boolean): object[]`\n\n**get** `/v1/customMetadataFields`\n\nThis API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response.\n\nYou can also filter results by a specific folder path to retrieve custom metadata fields applicable at that location. This path-specific filtering is useful when using the **Path policy** feature to determine which custom metadata fields are selected for a given path.\n\n\n### Parameters\n\n- `folderPath?: string`\n The folder path (e.g., `/path/to/folder`) for which to retrieve applicable custom metadata fields. Useful for determining path-specific field selections when the [Path policy](https://imagekit.io/docs/dam/path-policy) feature is in use.\n\n\n- `includeDeleted?: boolean`\n Set it to `true` to include deleted field objects in the API response.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataFields = await client.customMetadataFields.list();\n\nconsole.log(customMetadataFields);\n```", perLanguage: { - cli: { - method: 'customMetadataFields list', - example: - "imagekit custom-metadata-fields list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - csharp: { - method: 'CustomMetadataFields.List', - example: - 'CustomMetadataFieldListParams parameters = new();\n\nvar customMetadataFields = await client.CustomMetadataFields.List(parameters);\n\nConsole.WriteLine(customMetadataFields);', - }, - go: { - method: 'client.CustomMetadataFields.List', + typescript: { + method: 'client.customMetadataFields.list', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataFields, err := client.CustomMetadataFields.List(context.TODO(), imagekit.CustomMetadataFieldListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataFields)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataFields = await client.customMetadataFields.list();\n\nconsole.log(customMetadataFields);", }, - http: { + python: { + method: 'custom_metadata_fields.list', example: - 'curl https://api.imagekit.io/v1/customMetadataFields \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_fields = client.custom_metadata_fields.list()\nprint(custom_metadata_fields)', }, java: { method: 'customMetadataFields().list', @@ -164,25 +155,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataFields: List = client.customMetadataFields().list()\n}', }, - php: { - method: 'customMetadataFields->list', - example: - "customMetadataFields->list(\n folderPath: 'folderPath', includeDeleted: true\n);\n\nvar_dump($customMetadataFields);", - }, - python: { - method: 'custom_metadata_fields.list', + go: { + method: 'client.CustomMetadataFields.List', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_fields = client.custom_metadata_fields.list()\nprint(custom_metadata_fields)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataFields, err := client.CustomMetadataFields.List(context.TODO(), imagekit.CustomMetadataFieldListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataFields)\n}\n', }, ruby: { method: 'custom_metadata_fields.list', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ncustom_metadata_fields = image_kit.custom_metadata_fields.list\n\nputs(custom_metadata_fields)', }, - typescript: { - method: 'client.customMetadataFields.list', + cli: { + method: 'customMetadataFields list', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataFields = await client.customMetadataFields.list();\n\nconsole.log(customMetadataFields);", + "imagekit custom-metadata-fields list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'customMetadataFields->list', + example: + "customMetadataFields->list(\n folderPath: 'folderPath', includeDeleted: true\n);\n\nvar_dump($customMetadataFields);", + }, + csharp: { + method: 'CustomMetadataFields.List', + example: + 'CustomMetadataFieldListParams parameters = new();\n\nvar customMetadataFields = await client.CustomMetadataFields.List(parameters);\n\nConsole.WriteLine(customMetadataFields);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/customMetadataFields \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -204,24 +204,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## update\n\n`client.customMetadataFields.update(id: string, label?: string, schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }): { id: string; label: string; name: string; schema: object; }`\n\n**patch** `/v1/customMetadataFields/{id}`\n\nThis API updates the label or schema of an existing custom metadata field.\n\n\n### Parameters\n\n- `id: string`\n\n- `label?: string`\n Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI. This parameter is required if `schema` is not provided.\n\n- `schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n An object that describes the rules for the custom metadata key. This parameter is required if `label` is not provided. Note: `type` cannot be updated and will be ignored if sent with the `schema`. The schema will be validated as per the existing `type`.\n\n - `defaultValue?: string | number | boolean | string | number | boolean[]`\n The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field.\n\n - `isValueRequired?: boolean`\n Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body.\n\n - `maxLength?: number`\n Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `maxValue?: string | number`\n Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `minLength?: number`\n Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `minValue?: string | number`\n Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `selectOptions?: string | number | boolean[]`\n An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }`\n Object containing details of a custom metadata field.\n\n - `id: string`\n - `label: string`\n - `name: string`\n - `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.update('id');\n\nconsole.log(customMetadataField);\n```", perLanguage: { - cli: { - method: 'customMetadataFields update', - example: - "imagekit custom-metadata-fields update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - csharp: { - method: 'CustomMetadataFields.Update', - example: - 'CustomMetadataFieldUpdateParams parameters = new() { ID = "id" };\n\nvar customMetadataField = await client.CustomMetadataFields.Update(parameters);\n\nConsole.WriteLine(customMetadataField);', - }, - go: { - method: 'client.CustomMetadataFields.Update', + typescript: { + method: 'client.customMetadataFields.update', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.CustomMetadataFieldUpdateParams{\n\t\t\tLabel: imagekit.String("price"),\n\t\t\tSchema: imagekit.CustomMetadataFieldUpdateParamsSchema{\n\t\t\t\tMinValue: imagekit.CustomMetadataFieldUpdateParamsSchemaMinValueUnion{\n\t\t\t\t\tOfFloat: imagekit.Float(1000),\n\t\t\t\t},\n\t\t\t\tMaxValue: imagekit.CustomMetadataFieldUpdateParamsSchemaMaxValueUnion{\n\t\t\t\t\tOfFloat: imagekit.Float(3000),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataField.ID)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.update('id', {\n label: 'price',\n schema: { minValue: 1000, maxValue: 3000 },\n});\n\nconsole.log(customMetadataField.id);", }, - http: { + python: { + method: 'custom_metadata_fields.update', example: - 'curl https://api.imagekit.io/v1/customMetadataFields/$ID \\\n -X PATCH \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.update(\n id="id",\n label="price",\n schema={\n "min_value": 1000,\n "max_value": 3000,\n },\n)\nprint(custom_metadata_field.id)', }, java: { method: 'customMetadataFields().update', @@ -233,25 +224,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataField: CustomMetadataField = client.customMetadataFields().update("id")\n}', }, - php: { - method: 'customMetadataFields->update', - example: - "customMetadataFields->update(\n 'id',\n label: 'price',\n schema: [\n 'defaultValue' => [true, 10, 'Hello'],\n 'isValueRequired' => true,\n 'maxLength' => 0,\n 'maxValue' => 3000,\n 'minLength' => 0,\n 'minValue' => 1000,\n 'selectOptions' => ['small', 'medium', 'large', 30, 40, true],\n ],\n);\n\nvar_dump($customMetadataField);", - }, - python: { - method: 'custom_metadata_fields.update', + go: { + method: 'client.CustomMetadataFields.Update', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.update(\n id="id",\n label="price",\n schema={\n "min_value": 1000,\n "max_value": 3000,\n },\n)\nprint(custom_metadata_field.id)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.CustomMetadataFieldUpdateParams{\n\t\t\tLabel: imagekit.String("price"),\n\t\t\tSchema: imagekit.CustomMetadataFieldUpdateParamsSchema{\n\t\t\t\tMinValue: imagekit.CustomMetadataFieldUpdateParamsSchemaMinValueUnion{\n\t\t\t\t\tOfFloat: imagekit.Float(1000),\n\t\t\t\t},\n\t\t\t\tMaxValue: imagekit.CustomMetadataFieldUpdateParamsSchemaMaxValueUnion{\n\t\t\t\t\tOfFloat: imagekit.Float(3000),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataField.ID)\n}\n', }, ruby: { method: 'custom_metadata_fields.update', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.update("id")\n\nputs(custom_metadata_field)', }, - typescript: { - method: 'client.customMetadataFields.update', + cli: { + method: 'customMetadataFields update', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.update('id', {\n label: 'price',\n schema: { minValue: 1000, maxValue: 3000 },\n});\n\nconsole.log(customMetadataField.id);", + "imagekit custom-metadata-fields update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'customMetadataFields->update', + example: + "customMetadataFields->update(\n 'id',\n label: 'price',\n schema: [\n 'defaultValue' => [true, 10, 'Hello'],\n 'isValueRequired' => true,\n 'maxLength' => 0,\n 'maxValue' => 3000,\n 'minLength' => 0,\n 'minValue' => 1000,\n 'selectOptions' => ['small', 'medium', 'large', 30, 40, true],\n ],\n);\n\nvar_dump($customMetadataField);", + }, + csharp: { + method: 'CustomMetadataFields.Update', + example: + 'CustomMetadataFieldUpdateParams parameters = new() { ID = "id" };\n\nvar customMetadataField = await client.CustomMetadataFields.Update(parameters);\n\nConsole.WriteLine(customMetadataField);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/customMetadataFields/$ID \\\n -X PATCH \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -269,24 +269,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## delete\n\n`client.customMetadataFields.delete(id: string): { }`\n\n**delete** `/v1/customMetadataFields/{id}`\n\nThis API deletes a custom metadata field. Even after deleting a custom metadata field, you cannot create any new custom metadata field with the same name.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.delete('id');\n\nconsole.log(customMetadataField);\n```", perLanguage: { - cli: { - method: 'customMetadataFields delete', - example: - "imagekit custom-metadata-fields delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - csharp: { - method: 'CustomMetadataFields.Delete', - example: - 'CustomMetadataFieldDeleteParams parameters = new() { ID = "id" };\n\nvar customMetadataField = await client.CustomMetadataFields.Delete(parameters);\n\nConsole.WriteLine(customMetadataField);', - }, - go: { - method: 'client.CustomMetadataFields.Delete', + typescript: { + method: 'client.customMetadataFields.delete', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataField)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.delete('id');\n\nconsole.log(customMetadataField);", }, - http: { + python: { + method: 'custom_metadata_fields.delete', example: - 'curl https://api.imagekit.io/v1/customMetadataFields/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.delete(\n "id",\n)\nprint(custom_metadata_field)', }, java: { method: 'customMetadataFields().delete', @@ -298,25 +289,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataField: CustomMetadataFieldDeleteResponse = client.customMetadataFields().delete("id")\n}', }, - php: { - method: 'customMetadataFields->delete', - example: - "customMetadataFields->delete('id');\n\nvar_dump($customMetadataField);", - }, - python: { - method: 'custom_metadata_fields.delete', + go: { + method: 'client.CustomMetadataFields.Delete', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.delete(\n "id",\n)\nprint(custom_metadata_field)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataField)\n}\n', }, ruby: { method: 'custom_metadata_fields.delete', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.delete("id")\n\nputs(custom_metadata_field)', }, - typescript: { - method: 'client.customMetadataFields.delete', + cli: { + method: 'customMetadataFields delete', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.delete('id');\n\nconsole.log(customMetadataField);", + "imagekit custom-metadata-fields delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'customMetadataFields->delete', + example: + "customMetadataFields->delete('id');\n\nvar_dump($customMetadataField);", + }, + csharp: { + method: 'CustomMetadataFields.Delete', + example: + 'CustomMetadataFieldDeleteParams parameters = new() { ID = "id" };\n\nvar customMetadataField = await client.CustomMetadataFields.Delete(parameters);\n\nConsole.WriteLine(customMetadataField);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/customMetadataFields/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -359,24 +359,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## upload\n\n`client.files.upload(file: string, fileName: string, token?: string, checks?: string, customCoordinates?: string, customMetadata?: object, description?: string, expire?: number, extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[], folder?: string, isPrivateFile?: boolean, isPublished?: boolean, overwriteAITags?: boolean, overwriteCustomMetadata?: boolean, overwriteFile?: boolean, overwriteTags?: boolean, publicKey?: string, responseFields?: string[], signature?: string, tags?: string[], transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }, useUniqueFileName?: boolean, webhookUrl?: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: object; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: metadata; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**post** `/api/v1/files/upload`\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token`, `signature`, and `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) about how to implement client-side file upload.\n\nThe [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the entire payload using JWT.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n\n\n### Parameters\n\n- `file: string`\n The API accepts any of the following:\n\n- **Binary data** – send the raw bytes as `multipart/form-data`.\n- **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.\n- **Base64 string** – the file encoded as a Base64 data URI or plain Base64.\n\nWhen supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.\n\n\n- `fileName: string`\n The name with which the file has to be uploaded.\nThe file name can contain:\n\n - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`.\n - Special Characters: `.`, `-`\n\nAny other character including space will be replaced by `_`\n\n\n- `token?: string`\n A unique value that the ImageKit.io server will use to recognize and prevent subsequent retries for the same request. We suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. This field is only required for authentication when uploading a file from the client side.\n\n**Note**: Sending a value that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new value for this field.\n\n\n- `checks?: string`\n Server-side checks to run on the asset.\nRead more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks).\n\n\n- `customCoordinates?: string`\n Define an important area in the image. This is only relevant for image type files.\n\n - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100`\n - Can be used with fo-customtransformation.\n - If this field is not specified and the file is overwritten, then customCoordinates will be removed.\n\n\n- `customMetadata?: object`\n JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.\n\n\n- `description?: string`\n Optional text to describe the contents of the file.\n\n\n- `expire?: number`\n The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It should be in seconds. This field is only required for authentication when uploading a file from the client side.\n\n\n- `extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[]`\n Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.\n\n\n- `folder?: string`\n The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created.\n\nThe folder name can contain:\n\n - Alphanumeric Characters: `a-z` , `A-Z` , `0-9`\n - Special Characters: `/` , `_` , `-`\n\nUsing multiple `/` creates a nested folder.\n\n\n- `isPrivateFile?: boolean`\n Whether to mark the file as private or not.\n\nIf `true`, the file is marked as private and is accessible only using named transformation or signed URL.\n\n\n- `isPublished?: boolean`\n Whether to upload file as published or not.\n\nIf `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published.\n\nThe option to upload in draft state is only available in custom enterprise pricing plans.\n\n\n- `overwriteAITags?: boolean`\n If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags.\n\n\n- `overwriteCustomMetadata?: boolean`\n If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed.\n\n\n- `overwriteFile?: boolean`\n If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately.\n\n\n- `overwriteTags?: boolean`\n If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed.\n\n\n- `publicKey?: string`\n Your ImageKit.io public key. This field is only required for authentication when uploading a file from the client side.\n\n\n- `responseFields?: string[]`\n Array of response field keys to include in the API response body.\n\n\n- `signature?: string`\n HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn how to create a signature on the page below. This should be in lowercase.\n\nSignature must be calculated on the server-side. This field is only required for authentication when uploading a file from the client side.\n\n\n- `tags?: string[]`\n Set the tags while uploading the file.\nProvide an array of tag strings (e.g. `[\"tag1\", \"tag2\", \"tag3\"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed.\nIf this field is not specified and the file is overwritten, the existing tags will be removed.\n\n\n- `transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }`\n Configure pre-processing (`pre`) and post-processing (`post`) transformations.\n\n- `pre` — applied before the file is uploaded to the Media Library. \n Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress).\n\n- `post` — applied immediately after upload. \n Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay.\n\nYou can mix and match any combination of post-processing types.\n\n - `post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]`\n List of transformations to apply *after* the file is uploaded. \nEach item must match one of the following types:\n`transformation`, `gif-to-video`, `thumbnail`, `abs`.\n\n - `pre?: string`\n Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion.\n\n\n- `useUniqueFileName?: boolean`\n Whether to use a unique filename for this file or not.\n\nIf `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename.\n\nIf `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced.\n\n\n- `webhookUrl?: string`\n The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure.\n\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a successful upload.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnailUrl?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'fileName' });\n\nconsole.log(response);\n```", perLanguage: { - cli: { - method: 'files upload', - example: - "imagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name fileName", - }, - csharp: { - method: 'Files.Upload', - example: - 'FileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes("Example data"),\n FileName = "fileName",\n};\n\nvar response = await client.Files.Upload(parameters);\n\nConsole.WriteLine(response);', - }, - go: { - method: 'client.Files.Upload', + typescript: { + method: 'client.files.upload', example: - 'package main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("Example data"))),\n\t\tFileName: "fileName",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n', + "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);", }, - http: { + python: { + method: 'files.upload', example: - 'curl https://upload.imagekit.io/api/v1/files/upload \\\n -H \'Content-Type: multipart/form-data\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -F \'file=@/path/to/file\' \\\n -F fileName=fileName \\\n -F checks=\'"request.folder" : "marketing/"\n \' \\\n -F customMetadata=\'{"brand":"bar","color":"bar"}\' \\\n -F description=\'Running shoes\' \\\n -F extensions=\'[{"name":"remove-bg","options":{"add_shadow":true}},{"maxTags":5,"minConfidence":95,"name":"google-auto-tagging"},{"name":"ai-auto-description"},{"name":"ai-tasks","tasks":[{"instruction":"What types of clothing items are visible in this image?","type":"select_tags","vocabulary":["shirt","tshirt","dress","trousers","jacket"]},{"instruction":"Is this a luxury or high-end fashion item?","type":"yes_no","on_yes":{"add_tags":["luxury","premium"]}}]},{"id":"ext_abc123","name":"saved-extension"}]\' \\\n -F responseFields=\'["tags","customCoordinates","isPrivateFile"]\' \\\n -F tags=\'["t-shirt","round-neck","men"]\' \\\n -F transformation=\'{"post":[{"type":"thumbnail","value":"w-150,h-150"},{"protocol":"dash","type":"abs","value":"sr-240_360_480_720_1080"}]}\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.upload(\n file=b"Example data",\n file_name="fileName",\n)\nprint(response.video_codec)', }, java: { method: 'files().upload', @@ -388,36 +379,45 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUploadParams = FileUploadParams.builder()\n .file("Example data".byteInputStream())\n .fileName("fileName")\n .build()\n val response: FileUploadResponse = client.files().upload(params)\n}', }, - php: { - method: 'files->upload', - example: - "files->upload(\n file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),\n fileName: 'fileName',\n token: 'token',\n checks: \"\\\"request.folder\\\" : \\\"marketing/\\\"\\n\",\n customCoordinates: 'customCoordinates',\n customMetadata: ['brand' => 'bar', 'color' => 'bar'],\n description: 'Running shoes',\n expire: 0,\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n folder: 'folder',\n isPrivateFile: true,\n isPublished: true,\n overwriteAITags: true,\n overwriteCustomMetadata: true,\n overwriteFile: true,\n overwriteTags: true,\n publicKey: 'publicKey',\n responseFields: ['tags', 'customCoordinates', 'isPrivateFile'],\n signature: 'signature',\n tags: ['t-shirt', 'round-neck', 'men'],\n transformation: [\n 'post' => [\n ['type' => 'thumbnail', 'value' => 'w-150,h-150'],\n [\n 'protocol' => 'dash',\n 'type' => 'abs',\n 'value' => 'sr-240_360_480_720_1080',\n ],\n ],\n 'pre' => 'w-300,h-300,q-80',\n ],\n useUniqueFileName: true,\n webhookURL: 'https://example.com',\n);\n\nvar_dump($response);", - }, - python: { - method: 'files.upload', + go: { + method: 'client.Files.Upload', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.upload(\n file=b"Example data",\n file_name="fileName",\n)\nprint(response.video_codec)', + 'package main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("Example data"))),\n\t\tFileName: "fileName",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n', }, ruby: { method: 'files.upload', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.upload(file: StringIO.new("Example data"), file_name: "fileName")\n\nputs(response)', }, - typescript: { - method: 'client.files.upload', + cli: { + method: 'files upload', example: - "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);", + "imagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name fileName", }, - }, - }, - { - name: 'get', - endpoint: '/v1/files/{fileId}/details', - httpMethod: 'get', - summary: 'Get file details', - description: - 'This API returns an object with details or attributes about the current version of the file.', - stainlessPath: '(resource) files > (method) get', + php: { + method: 'files->upload', + example: + "files->upload(\n file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),\n fileName: 'fileName',\n token: 'token',\n checks: \"\\\"request.folder\\\" : \\\"marketing/\\\"\\n\",\n customCoordinates: 'customCoordinates',\n customMetadata: ['brand' => 'bar', 'color' => 'bar'],\n description: 'Running shoes',\n expire: 0,\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n folder: 'folder',\n isPrivateFile: true,\n isPublished: true,\n overwriteAITags: true,\n overwriteCustomMetadata: true,\n overwriteFile: true,\n overwriteTags: true,\n publicKey: 'publicKey',\n responseFields: ['tags', 'customCoordinates', 'isPrivateFile'],\n signature: 'signature',\n tags: ['t-shirt', 'round-neck', 'men'],\n transformation: [\n 'post' => [\n ['type' => 'thumbnail', 'value' => 'w-150,h-150'],\n [\n 'protocol' => 'dash',\n 'type' => 'abs',\n 'value' => 'sr-240_360_480_720_1080',\n ],\n ],\n 'pre' => 'w-300,h-300,q-80',\n ],\n useUniqueFileName: true,\n webhookURL: 'https://example.com',\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Upload', + example: + 'FileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes("Example data"),\n FileName = "fileName",\n};\n\nvar response = await client.Files.Upload(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://upload.imagekit.io/api/v1/files/upload \\\n -H \'Content-Type: multipart/form-data\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -F \'file=@/path/to/file\' \\\n -F fileName=fileName \\\n -F checks=\'"request.folder" : "marketing/"\n \' \\\n -F customMetadata=\'{"brand":"bar","color":"bar"}\' \\\n -F description=\'Running shoes\' \\\n -F extensions=\'[{"name":"remove-bg","options":{"add_shadow":true}},{"maxTags":5,"minConfidence":95,"name":"google-auto-tagging"},{"name":"ai-auto-description"},{"name":"ai-tasks","tasks":[{"instruction":"What types of clothing items are visible in this image?","type":"select_tags","vocabulary":["shirt","tshirt","dress","trousers","jacket"]},{"instruction":"Is this a luxury or high-end fashion item?","type":"yes_no","on_yes":{"add_tags":["luxury","premium"]}}]},{"id":"ext_abc123","name":"saved-extension"}]\' \\\n -F responseFields=\'["tags","customCoordinates","isPrivateFile"]\' \\\n -F tags=\'["t-shirt","round-neck","men"]\' \\\n -F transformation=\'{"post":[{"type":"thumbnail","value":"w-150,h-150"},{"protocol":"dash","type":"abs","value":"sr-240_360_480_720_1080"}]}\'', + }, + }, + }, + { + name: 'get', + endpoint: '/v1/files/{fileId}/details', + httpMethod: 'get', + summary: 'Get file details', + description: + 'This API returns an object with details or attributes about the current version of the file.', + stainlessPath: '(resource) files > (method) get', qualified: 'client.files.get', params: ['fileId: string;'], response: @@ -425,24 +425,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## get\n\n`client.files.get(fileId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/details`\n\nThis API returns an object with details or attributes about the current version of the file.\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.get('fileId');\n\nconsole.log(file);\n```", perLanguage: { - cli: { - method: 'files get', - example: - "imagekit files get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", - }, - csharp: { - method: 'Files.Get', - example: - 'FileGetParams parameters = new() { FileID = "fileId" };\n\nvar file = await client.Files.Get(parameters);\n\nConsole.WriteLine(file);', - }, - go: { - method: 'client.Files.Get', + typescript: { + method: 'client.files.get', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Get(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file.VideoCodec)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.get('fileId');\n\nconsole.log(file.videoCodec);", }, - http: { + python: { + method: 'files.get', example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/details \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.get(\n "fileId",\n)\nprint(file.video_codec)', }, java: { method: 'files().get', @@ -454,25 +445,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.FileGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val file: File = client.files().get("fileId")\n}', }, - php: { - method: 'files->get', - example: - "files->get('fileId');\n\nvar_dump($file);", - }, - python: { - method: 'files.get', + go: { + method: 'client.Files.Get', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.get(\n "fileId",\n)\nprint(file.video_codec)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Get(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file.VideoCodec)\n}\n', }, ruby: { method: 'files.get', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfile = image_kit.files.get("fileId")\n\nputs(file)', }, - typescript: { - method: 'client.files.get', + cli: { + method: 'files get', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.get('fileId');\n\nconsole.log(file.videoCodec);", + "imagekit files get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", + }, + php: { + method: 'files->get', + example: + "files->get('fileId');\n\nvar_dump($file);", + }, + csharp: { + method: 'Files.Get', + example: + 'FileGetParams parameters = new() { FileID = "fileId" };\n\nvar file = await client.Files.Get(parameters);\n\nConsole.WriteLine(file);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID/details \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -492,24 +492,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ response: "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", perLanguage: { - cli: { - method: 'files update', - example: - "imagekit files update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", - }, - csharp: { - method: 'Files.Update', - example: - 'FileUpdateParams parameters = new()\n{\n FileID = "fileId",\n UpdateFileRequest = new UpdateFileDetails()\n {\n CustomCoordinates = "10,10,100,100",\n CustomMetadata = new Dictionary()\n {\n { "brand", JsonSerializer.SerializeToElement("bar") },\n { "color", JsonSerializer.SerializeToElement("bar") },\n },\n Description = "description",\n Extensions =\n [\n new RemoveBg()\n {\n Options = new()\n {\n AddShadow = true,\n BgColor = "bg_color",\n BgImageUrl = "bg_image_url",\n Semitransparency = true,\n },\n },\n new AutoTaggingExtension()\n {\n MaxTags = 10,\n MinConfidence = 80,\n Name = Name.GoogleAutoTagging,\n },\n new AutoTaggingExtension()\n {\n MaxTags = 10,\n MinConfidence = 80,\n Name = Name.AwsAutoTagging,\n },\n new AIAutoDescription(),\n new AITasks(\n\n [\n new SelectTags()\n {\n Instruction = "What types of clothing items are visible?",\n MaxSelections = 1,\n MinSelections = 0,\n Vocabulary =\n [\n "shirt", "dress", "jacket"\n ],\n },\n ]\n ),\n new SavedExtension("ext_abc123"),\n ],\n RemoveAITags = new(\n\n [\n "car", "vehicle", "motorsports"\n ]\n ),\n Tags =\n [\n "tag1", "tag2"\n ],\n WebhookUrl = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a",\n },\n};\n\nvar file = await client.Files.Update(parameters);\n\nConsole.WriteLine(file);', - }, - go: { - method: 'client.Files.Update', + typescript: { + method: 'client.files.update', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Update(\n\t\tcontext.TODO(),\n\t\t"fileId",\n\t\timagekit.FileUpdateParams{\n\t\t\tUpdateFileRequest: imagekit.UpdateFileRequestUnionParam{\n\t\t\t\tOfUpdateFileDetails: &imagekit.UpdateFileRequestUpdateFileDetailsParam{},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.update('fileId');\n\nconsole.log(file);", }, - http: { + python: { + method: 'files.update', example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/details \\\n -X PATCH \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "extensions": [\n {\n "name": "remove-bg",\n "options": {\n "add_shadow": true\n }\n },\n {\n "maxTags": 5,\n "minConfidence": 95,\n "name": "google-auto-tagging"\n },\n {\n "name": "ai-auto-description"\n },\n {\n "name": "ai-tasks",\n "tasks": [\n {\n "instruction": "What types of clothing items are visible in this image?",\n "type": "select_tags",\n "vocabulary": [\n "shirt",\n "tshirt",\n "dress",\n "trousers",\n "jacket"\n ]\n },\n {\n "instruction": "Is this a luxury or high-end fashion item?",\n "type": "yes_no",\n "on_yes": {\n "add_tags": [\n "luxury",\n "premium"\n ]\n }\n }\n ]\n },\n {\n "id": "ext_abc123",\n "name": "saved-extension"\n }\n ],\n "tags": [\n "tag1",\n "tag2"\n ]\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.update(\n file_id="fileId",\n)\nprint(file)', }, java: { method: 'files().update', @@ -521,25 +512,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUpdateParams\nimport com.imagekit.api.models.files.FileUpdateResponse\nimport com.imagekit.api.models.files.UpdateFileRequest\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUpdateParams = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build()\n val file: FileUpdateResponse = client.files().update(params)\n}', }, - php: { - method: 'files->update', - example: - "files->update(\n 'fileId',\n customCoordinates: 'customCoordinates',\n customMetadata: ['foo' => 'bar'],\n description: 'description',\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n removeAITags: 'all',\n tags: ['tag1', 'tag2'],\n webhookURL: 'https://example.com',\n publish: ['isPublished' => true, 'includeFileVersions' => true],\n);\n\nvar_dump($file);", - }, - python: { - method: 'files.update', + go: { + method: 'client.Files.Update', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.update(\n file_id="fileId",\n)\nprint(file)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Update(\n\t\tcontext.TODO(),\n\t\t"fileId",\n\t\timagekit.FileUpdateParams{\n\t\t\tUpdateFileRequest: imagekit.UpdateFileRequestUnionParam{\n\t\t\t\tOfUpdateFileDetails: &imagekit.UpdateFileRequestUpdateFileDetailsParam{},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file)\n}\n', }, ruby: { method: 'files.update', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfile = image_kit.files.update("fileId", update_file_request: {})\n\nputs(file)', }, - typescript: { - method: 'client.files.update', + cli: { + method: 'files update', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.update('fileId');\n\nconsole.log(file);", + "imagekit files update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", + }, + php: { + method: 'files->update', + example: + "files->update(\n 'fileId',\n customCoordinates: 'customCoordinates',\n customMetadata: ['foo' => 'bar'],\n description: 'description',\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n removeAITags: 'all',\n tags: ['tag1', 'tag2'],\n webhookURL: 'https://example.com',\n publish: ['isPublished' => true, 'includeFileVersions' => true],\n);\n\nvar_dump($file);", + }, + csharp: { + method: 'Files.Update', + example: + 'FileUpdateParams parameters = new()\n{\n FileID = "fileId",\n UpdateFileRequest = new UpdateFileDetails()\n {\n CustomCoordinates = "10,10,100,100",\n CustomMetadata = new Dictionary()\n {\n { "brand", JsonSerializer.SerializeToElement("bar") },\n { "color", JsonSerializer.SerializeToElement("bar") },\n },\n Description = "description",\n Extensions =\n [\n new RemoveBg()\n {\n Options = new()\n {\n AddShadow = true,\n BgColor = "bg_color",\n BgImageUrl = "bg_image_url",\n Semitransparency = true,\n },\n },\n new AutoTaggingExtension()\n {\n MaxTags = 10,\n MinConfidence = 80,\n Name = Name.GoogleAutoTagging,\n },\n new AutoTaggingExtension()\n {\n MaxTags = 10,\n MinConfidence = 80,\n Name = Name.AwsAutoTagging,\n },\n new AIAutoDescription(),\n new AITasks(\n\n [\n new SelectTags()\n {\n Instruction = "What types of clothing items are visible?",\n MaxSelections = 1,\n MinSelections = 0,\n Vocabulary =\n [\n "shirt", "dress", "jacket"\n ],\n },\n ]\n ),\n new SavedExtension("ext_abc123"),\n ],\n RemoveAITags = new(\n\n [\n "car", "vehicle", "motorsports"\n ]\n ),\n Tags =\n [\n "tag1", "tag2"\n ],\n WebhookUrl = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a",\n },\n};\n\nvar file = await client.Files.Update(parameters);\n\nConsole.WriteLine(file);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID/details \\\n -X PATCH \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "extensions": [\n {\n "name": "remove-bg",\n "options": {\n "add_shadow": true\n }\n },\n {\n "maxTags": 5,\n "minConfidence": 95,\n "name": "google-auto-tagging"\n },\n {\n "name": "ai-auto-description"\n },\n {\n "name": "ai-tasks",\n "tasks": [\n {\n "instruction": "What types of clothing items are visible in this image?",\n "type": "select_tags",\n "vocabulary": [\n "shirt",\n "tshirt",\n "dress",\n "trousers",\n "jacket"\n ]\n },\n {\n "instruction": "Is this a luxury or high-end fashion item?",\n "type": "yes_no",\n "on_yes": {\n "add_tags": [\n "luxury",\n "premium"\n ]\n }\n }\n ]\n },\n {\n "id": "ext_abc123",\n "name": "saved-extension"\n }\n ],\n "tags": [\n "tag1",\n "tag2"\n ]\n }\'', }, }, }, @@ -556,24 +556,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## delete\n\n`client.files.delete(fileId: string): void`\n\n**delete** `/v1/files/{fileId}`\n\nThis API deletes the file and all its file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.files.delete('fileId')\n```", perLanguage: { - cli: { - method: 'files delete', - example: - "imagekit files delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", - }, - csharp: { - method: 'Files.Delete', - example: - 'FileDeleteParams parameters = new() { FileID = "fileId" };\n\nawait client.Files.Delete(parameters);', - }, - go: { - method: 'client.Files.Delete', + typescript: { + method: 'client.files.delete', example: - 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Files.Delete(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.files.delete('fileId');", }, - http: { + python: { + method: 'files.delete', example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.files.delete(\n "fileId",\n)', }, java: { method: 'files().delete', @@ -585,25 +576,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.files().delete("fileId")\n}', }, - php: { - method: 'files->delete', - example: - "files->delete('fileId');\n\nvar_dump($result);", - }, - python: { - method: 'files.delete', + go: { + method: 'client.Files.Delete', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.files.delete(\n "fileId",\n)', + 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Files.Delete(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'files.delete', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.files.delete("fileId")\n\nputs(result)', }, - typescript: { - method: 'client.files.delete', + cli: { + method: 'files delete', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.files.delete('fileId');", + "imagekit files delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", + }, + php: { + method: 'files->delete', + example: + "files->delete('fileId');\n\nvar_dump($result);", + }, + csharp: { + method: 'Files.Delete', + example: + 'FileDeleteParams parameters = new() { FileID = "fileId" };\n\nawait client.Files.Delete(parameters);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -621,24 +621,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## copy\n\n`client.files.copy(destinationPath: string, sourceFilePath: string, includeFileVersions?: boolean): { }`\n\n**post** `/v1/files/copy`\n\nThis will copy a file from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions (if `includeFileVersions` is set to true) will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the folder you want to copy the above file into.\n\n\n- `sourceFilePath: string`\n The full path of the file you want to copy.\n\n\n- `includeFileVersions?: boolean`\n Option to copy all versions of a file. By default, only the current version of the file is copied. When set to true, all versions of the file will be copied. Default value - `false`.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.copy({ destinationPath: '/folder/to/copy/into/', sourceFilePath: '/path/to/file.jpg' });\n\nconsole.log(response);\n```", perLanguage: { - cli: { - method: 'files copy', - example: - "imagekit files copy \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /folder/to/copy/into/ \\\n --source-file-path /path/to/file.jpg", - }, - csharp: { - method: 'Files.Copy', - example: - 'FileCopyParams parameters = new()\n{\n DestinationPath = "/folder/to/copy/into/",\n SourceFilePath = "/path/to/file.jpg",\n};\n\nvar response = await client.Files.Copy(parameters);\n\nConsole.WriteLine(response);', - }, - go: { - method: 'client.Files.Copy', + typescript: { + method: 'client.files.copy', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Copy(context.TODO(), imagekit.FileCopyParams{\n\t\tDestinationPath: "/folder/to/copy/into/",\n\t\tSourceFilePath: "/path/to/file.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.copy({\n destinationPath: '/folder/to/copy/into/',\n sourceFilePath: '/path/to/file.jpg',\n});\n\nconsole.log(response);", }, - http: { + python: { + method: 'files.copy', example: - 'curl https://api.imagekit.io/v1/files/copy \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/folder/to/copy/into/",\n "sourceFilePath": "/path/to/file.jpg"\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.copy(\n destination_path="/folder/to/copy/into/",\n source_file_path="/path/to/file.jpg",\n)\nprint(response)', }, java: { method: 'files().copy', @@ -650,25 +641,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileCopyParams\nimport com.imagekit.api.models.files.FileCopyResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileCopyParams = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build()\n val response: FileCopyResponse = client.files().copy(params)\n}', }, - php: { - method: 'files->copy', - example: - "files->copy(\n destinationPath: '/folder/to/copy/into/',\n sourceFilePath: '/path/to/file.jpg',\n includeFileVersions: false,\n);\n\nvar_dump($response);", - }, - python: { - method: 'files.copy', + go: { + method: 'client.Files.Copy', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.copy(\n destination_path="/folder/to/copy/into/",\n source_file_path="/path/to/file.jpg",\n)\nprint(response)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Copy(context.TODO(), imagekit.FileCopyParams{\n\t\tDestinationPath: "/folder/to/copy/into/",\n\t\tSourceFilePath: "/path/to/file.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response)\n}\n', }, ruby: { method: 'files.copy', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.copy(destination_path: "/folder/to/copy/into/", source_file_path: "/path/to/file.jpg")\n\nputs(response)', }, - typescript: { - method: 'client.files.copy', + cli: { + method: 'files copy', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.copy({\n destinationPath: '/folder/to/copy/into/',\n sourceFilePath: '/path/to/file.jpg',\n});\n\nconsole.log(response);", + "imagekit files copy \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /folder/to/copy/into/ \\\n --source-file-path /path/to/file.jpg", + }, + php: { + method: 'files->copy', + example: + "files->copy(\n destinationPath: '/folder/to/copy/into/',\n sourceFilePath: '/path/to/file.jpg',\n includeFileVersions: false,\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Copy', + example: + 'FileCopyParams parameters = new()\n{\n DestinationPath = "/folder/to/copy/into/",\n SourceFilePath = "/path/to/file.jpg",\n};\n\nvar response = await client.Files.Copy(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/copy \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/folder/to/copy/into/",\n "sourceFilePath": "/path/to/file.jpg"\n }\'', }, }, }, @@ -686,24 +686,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## move\n\n`client.files.move(destinationPath: string, sourceFilePath: string): { }`\n\n**post** `/v1/files/move`\n\nThis will move a file and all its versions from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the folder you want to move the above file into.\n\n\n- `sourceFilePath: string`\n The full path of the file you want to move.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.move({ destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg' });\n\nconsole.log(response);\n```", perLanguage: { - cli: { - method: 'files move', - example: - "imagekit files move \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /folder/to/move/into/ \\\n --source-file-path /path/to/file.jpg", - }, - csharp: { - method: 'Files.Move', - example: - 'FileMoveParams parameters = new()\n{\n DestinationPath = "/folder/to/move/into/",\n SourceFilePath = "/path/to/file.jpg",\n};\n\nvar response = await client.Files.Move(parameters);\n\nConsole.WriteLine(response);', - }, - go: { - method: 'client.Files.Move', + typescript: { + method: 'client.files.move', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Move(context.TODO(), imagekit.FileMoveParams{\n\t\tDestinationPath: "/folder/to/move/into/",\n\t\tSourceFilePath: "/path/to/file.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.move({\n destinationPath: '/folder/to/move/into/',\n sourceFilePath: '/path/to/file.jpg',\n});\n\nconsole.log(response);", }, - http: { + python: { + method: 'files.move', example: - 'curl https://api.imagekit.io/v1/files/move \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/folder/to/move/into/",\n "sourceFilePath": "/path/to/file.jpg"\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.move(\n destination_path="/folder/to/move/into/",\n source_file_path="/path/to/file.jpg",\n)\nprint(response)', }, java: { method: 'files().move', @@ -715,25 +706,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileMoveParams\nimport com.imagekit.api.models.files.FileMoveResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileMoveParams = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build()\n val response: FileMoveResponse = client.files().move(params)\n}', }, - php: { - method: 'files->move', - example: - "files->move(\n destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg'\n);\n\nvar_dump($response);", - }, - python: { - method: 'files.move', + go: { + method: 'client.Files.Move', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.move(\n destination_path="/folder/to/move/into/",\n source_file_path="/path/to/file.jpg",\n)\nprint(response)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Move(context.TODO(), imagekit.FileMoveParams{\n\t\tDestinationPath: "/folder/to/move/into/",\n\t\tSourceFilePath: "/path/to/file.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response)\n}\n', }, ruby: { method: 'files.move', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.move(destination_path: "/folder/to/move/into/", source_file_path: "/path/to/file.jpg")\n\nputs(response)', }, - typescript: { - method: 'client.files.move', + cli: { + method: 'files move', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.move({\n destinationPath: '/folder/to/move/into/',\n sourceFilePath: '/path/to/file.jpg',\n});\n\nconsole.log(response);", + "imagekit files move \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /folder/to/move/into/ \\\n --source-file-path /path/to/file.jpg", + }, + php: { + method: 'files->move', + example: + "files->move(\n destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg'\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Move', + example: + 'FileMoveParams parameters = new()\n{\n DestinationPath = "/folder/to/move/into/",\n SourceFilePath = "/path/to/file.jpg",\n};\n\nvar response = await client.Files.Move(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/move \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/folder/to/move/into/",\n "sourceFilePath": "/path/to/file.jpg"\n }\'', }, }, }, @@ -751,24 +751,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## rename\n\n`client.files.rename(filePath: string, newFileName: string, purgeCache?: boolean): { purgeRequestId?: string; }`\n\n**put** `/v1/files/rename`\n\nYou can rename an already existing file in the media library using rename file API. This operation would rename all file versions of the file. \n\nNote: The old URLs will stop working. The file/file version URLs cached on CDN will continue to work unless a purge is requested.\n\n\n### Parameters\n\n- `filePath: string`\n The full path of the file you want to rename.\n\n\n- `newFileName: string`\n The new name of the file. A filename can contain:\n\nAlphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, and numerals in other languages).\nSpecial Characters: `.`, `_`, and `-`.\n\nAny other character, including space, will be replaced by `_`.\n\n\n- `purgeCache?: boolean`\n Option to purge cache for the old file and its versions' URLs.\n\nWhen set to true, it will internally issue a purge cache request on CDN to remove cached content of old file and its versions. This purge request is counted against your monthly purge quota.\n\nNote: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard at the end). It will remove the file and its versions' URLs and any transformations made using query parameters on this file or its versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation.\n\n\n\nDefault value - `false`\n\n\n### Returns\n\n- `{ purgeRequestId?: string; }`\n\n - `purgeRequestId?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.rename({ filePath: '/path/to/file.jpg', newFileName: 'newFileName.jpg' });\n\nconsole.log(response);\n```", perLanguage: { - cli: { - method: 'files rename', - example: - "imagekit files rename \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-path /path/to/file.jpg \\\n --new-file-name newFileName.jpg", - }, - csharp: { - method: 'Files.Rename', - example: - 'FileRenameParams parameters = new()\n{\n FilePath = "/path/to/file.jpg",\n NewFileName = "newFileName.jpg",\n};\n\nvar response = await client.Files.Rename(parameters);\n\nConsole.WriteLine(response);', - }, - go: { - method: 'client.Files.Rename', + typescript: { + method: 'client.files.rename', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Rename(context.TODO(), imagekit.FileRenameParams{\n\t\tFilePath: "/path/to/file.jpg",\n\t\tNewFileName: "newFileName.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.PurgeRequestID)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.rename({\n filePath: '/path/to/file.jpg',\n newFileName: 'newFileName.jpg',\n});\n\nconsole.log(response.purgeRequestId);", }, - http: { + python: { + method: 'files.rename', example: - 'curl https://api.imagekit.io/v1/files/rename \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "filePath": "/path/to/file.jpg",\n "newFileName": "newFileName.jpg",\n "purgeCache": true\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.rename(\n file_path="/path/to/file.jpg",\n new_file_name="newFileName.jpg",\n)\nprint(response.purge_request_id)', }, java: { method: 'files().rename', @@ -780,25 +771,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileRenameParams\nimport com.imagekit.api.models.files.FileRenameResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileRenameParams = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build()\n val response: FileRenameResponse = client.files().rename(params)\n}', }, - php: { - method: 'files->rename', - example: - "files->rename(\n filePath: '/path/to/file.jpg',\n newFileName: 'newFileName.jpg',\n purgeCache: true,\n);\n\nvar_dump($response);", - }, - python: { - method: 'files.rename', + go: { + method: 'client.Files.Rename', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.rename(\n file_path="/path/to/file.jpg",\n new_file_name="newFileName.jpg",\n)\nprint(response.purge_request_id)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Rename(context.TODO(), imagekit.FileRenameParams{\n\t\tFilePath: "/path/to/file.jpg",\n\t\tNewFileName: "newFileName.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.PurgeRequestID)\n}\n', }, ruby: { method: 'files.rename', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.rename(file_path: "/path/to/file.jpg", new_file_name: "newFileName.jpg")\n\nputs(response)', }, - typescript: { - method: 'client.files.rename', + cli: { + method: 'files rename', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.rename({\n filePath: '/path/to/file.jpg',\n newFileName: 'newFileName.jpg',\n});\n\nconsole.log(response.purgeRequestId);", + "imagekit files rename \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-path /path/to/file.jpg \\\n --new-file-name newFileName.jpg", + }, + php: { + method: 'files->rename', + example: + "files->rename(\n filePath: '/path/to/file.jpg',\n newFileName: 'newFileName.jpg',\n purgeCache: true,\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Rename', + example: + 'FileRenameParams parameters = new()\n{\n FilePath = "/path/to/file.jpg",\n NewFileName = "newFileName.jpg",\n};\n\nvar response = await client.Files.Rename(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/rename \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "filePath": "/path/to/file.jpg",\n "newFileName": "newFileName.jpg",\n "purgeCache": true\n }\'', }, }, }, @@ -816,24 +816,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## delete\n\n`client.files.bulk.delete(fileIds: string[]): { successfullyDeletedFileIds?: string[]; }`\n\n**post** `/v1/files/batch/deleteByFileIds`\n\nThis API deletes multiple files and all their file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\nA maximum of 100 files can be deleted at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds which you want to delete.\n\n\n### Returns\n\n- `{ successfullyDeletedFileIds?: string[]; }`\n\n - `successfullyDeletedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst bulk = await client.files.bulk.delete({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] });\n\nconsole.log(bulk);\n```", perLanguage: { - cli: { - method: 'bulk delete', - example: - "imagekit files:bulk delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be", - }, - csharp: { - method: 'Files.Bulk.Delete', - example: - 'BulkDeleteParams parameters = new()\n{\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n};\n\nvar bulk = await client.Files.Bulk.Delete(parameters);\n\nConsole.WriteLine(bulk);', - }, - go: { - method: 'client.Files.Bulk.Delete', + typescript: { + method: 'client.files.bulk.delete', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tbulk, err := client.Files.Bulk.Delete(context.TODO(), imagekit.FileBulkDeleteParams{\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", bulk.SuccessfullyDeletedFileIDs)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst bulk = await client.files.bulk.delete({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n});\n\nconsole.log(bulk.successfullyDeletedFileIds);", }, - http: { + python: { + method: 'files.bulk.delete', example: - 'curl https://api.imagekit.io/v1/files/batch/deleteByFileIds \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ]\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nbulk = client.files.bulk.delete(\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n)\nprint(bulk.successfully_deleted_file_ids)', }, java: { method: 'files().bulk().delete', @@ -845,25 +836,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkDeleteParams\nimport com.imagekit.api.models.files.bulk.BulkDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkDeleteParams = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build()\n val bulk: BulkDeleteResponse = client.files().bulk().delete(params)\n}', }, - php: { - method: 'files->bulk->delete', - example: - "files->bulk->delete(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be']\n);\n\nvar_dump($bulk);", - }, - python: { - method: 'files.bulk.delete', + go: { + method: 'client.Files.Bulk.Delete', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nbulk = client.files.bulk.delete(\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n)\nprint(bulk.successfully_deleted_file_ids)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tbulk, err := client.Files.Bulk.Delete(context.TODO(), imagekit.FileBulkDeleteParams{\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", bulk.SuccessfullyDeletedFileIDs)\n}\n', }, ruby: { method: 'files.bulk.delete', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nbulk = image_kit.files.bulk.delete(file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"])\n\nputs(bulk)', }, - typescript: { - method: 'client.files.bulk.delete', + cli: { + method: 'bulk delete', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst bulk = await client.files.bulk.delete({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n});\n\nconsole.log(bulk.successfullyDeletedFileIds);", + "imagekit files:bulk delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be", + }, + php: { + method: 'files->bulk->delete', + example: + "files->bulk->delete(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be']\n);\n\nvar_dump($bulk);", + }, + csharp: { + method: 'Files.Bulk.Delete', + example: + 'BulkDeleteParams parameters = new()\n{\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n};\n\nvar bulk = await client.Files.Bulk.Delete(parameters);\n\nConsole.WriteLine(bulk);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/batch/deleteByFileIds \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ]\n }\'', }, }, }, @@ -881,24 +881,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## addTags\n\n`client.files.bulk.addTags(fileIds: string[], tags: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/addTags`\n\nThis API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds to which you want to add tags.\n\n\n- `tags: string[]`\n An array of tags that you want to add to the files.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.addTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] });\n\nconsole.log(response);\n```", perLanguage: { - cli: { - method: 'bulk addTags', - example: - "imagekit files:bulk add-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be \\\n --tag t-shirt \\\n --tag round-neck \\\n --tag sale2019", - }, - csharp: { - method: 'Files.Bulk.AddTags', - example: - 'BulkAddTagsParams parameters = new()\n{\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n Tags =\n [\n "t-shirt", "round-neck", "sale2019"\n ],\n};\n\nvar response = await client.Files.Bulk.AddTags(parameters);\n\nConsole.WriteLine(response);', - }, - go: { - method: 'client.Files.Bulk.AddTags', + typescript: { + method: 'client.files.bulk.addTags', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Bulk.AddTags(context.TODO(), imagekit.FileBulkAddTagsParams{\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t\tTags: []string{"t-shirt", "round-neck", "sale2019"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.SuccessfullyUpdatedFileIDs)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.addTags({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);", }, - http: { + python: { + method: 'files.bulk.add_tags', example: - 'curl https://api.imagekit.io/v1/files/addTags \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ],\n "tags": [\n "t-shirt",\n "round-neck",\n "sale2019"\n ]\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.add_tags(\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags=["t-shirt", "round-neck", "sale2019"],\n)\nprint(response.successfully_updated_file_ids)', }, java: { method: 'files().bulk().addTags', @@ -910,25 +901,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkAddTagsParams\nimport com.imagekit.api.models.files.bulk.BulkAddTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkAddTagsParams = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(listOf(\n "t-shirt",\n "round-neck",\n "sale2019",\n ))\n .build()\n val response: BulkAddTagsResponse = client.files().bulk().addTags(params)\n}', }, - php: { - method: 'files->bulk->addTags', - example: - "files->bulk->addTags(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n);\n\nvar_dump($response);", - }, - python: { - method: 'files.bulk.add_tags', + go: { + method: 'client.Files.Bulk.AddTags', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.add_tags(\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags=["t-shirt", "round-neck", "sale2019"],\n)\nprint(response.successfully_updated_file_ids)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Bulk.AddTags(context.TODO(), imagekit.FileBulkAddTagsParams{\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t\tTags: []string{"t-shirt", "round-neck", "sale2019"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.SuccessfullyUpdatedFileIDs)\n}\n', }, ruby: { method: 'files.bulk.add_tags', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.bulk.add_tags(\n file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags: ["t-shirt", "round-neck", "sale2019"]\n)\n\nputs(response)', }, - typescript: { - method: 'client.files.bulk.addTags', + cli: { + method: 'bulk addTags', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.addTags({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);", + "imagekit files:bulk add-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be \\\n --tag t-shirt \\\n --tag round-neck \\\n --tag sale2019", + }, + php: { + method: 'files->bulk->addTags', + example: + "files->bulk->addTags(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Bulk.AddTags', + example: + 'BulkAddTagsParams parameters = new()\n{\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n Tags =\n [\n "t-shirt", "round-neck", "sale2019"\n ],\n};\n\nvar response = await client.Files.Bulk.AddTags(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/addTags \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ],\n "tags": [\n "t-shirt",\n "round-neck",\n "sale2019"\n ]\n }\'', }, }, }, @@ -946,24 +946,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## removeTags\n\n`client.files.bulk.removeTags(fileIds: string[], tags: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/removeTags`\n\nThis API removes tags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds from which you want to remove tags.\n\n\n- `tags: string[]`\n An array of tags that you want to remove from the files.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.removeTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] });\n\nconsole.log(response);\n```", perLanguage: { - cli: { - method: 'bulk removeTags', - example: - "imagekit files:bulk remove-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be \\\n --tag t-shirt \\\n --tag round-neck \\\n --tag sale2019", - }, - csharp: { - method: 'Files.Bulk.RemoveTags', - example: - 'BulkRemoveTagsParams parameters = new()\n{\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n Tags =\n [\n "t-shirt", "round-neck", "sale2019"\n ],\n};\n\nvar response = await client.Files.Bulk.RemoveTags(parameters);\n\nConsole.WriteLine(response);', - }, - go: { - method: 'client.Files.Bulk.RemoveTags', + typescript: { + method: 'client.files.bulk.removeTags', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Bulk.RemoveTags(context.TODO(), imagekit.FileBulkRemoveTagsParams{\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t\tTags: []string{"t-shirt", "round-neck", "sale2019"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.SuccessfullyUpdatedFileIDs)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.removeTags({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);", }, - http: { + python: { + method: 'files.bulk.remove_tags', example: - 'curl https://api.imagekit.io/v1/files/removeTags \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ],\n "tags": [\n "t-shirt",\n "round-neck",\n "sale2019"\n ]\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.remove_tags(\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags=["t-shirt", "round-neck", "sale2019"],\n)\nprint(response.successfully_updated_file_ids)', }, java: { method: 'files().bulk().removeTags', @@ -975,25 +966,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsParams\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkRemoveTagsParams = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(listOf(\n "t-shirt",\n "round-neck",\n "sale2019",\n ))\n .build()\n val response: BulkRemoveTagsResponse = client.files().bulk().removeTags(params)\n}', }, - php: { - method: 'files->bulk->removeTags', - example: - "files->bulk->removeTags(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n);\n\nvar_dump($response);", - }, - python: { - method: 'files.bulk.remove_tags', + go: { + method: 'client.Files.Bulk.RemoveTags', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.remove_tags(\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags=["t-shirt", "round-neck", "sale2019"],\n)\nprint(response.successfully_updated_file_ids)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Bulk.RemoveTags(context.TODO(), imagekit.FileBulkRemoveTagsParams{\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t\tTags: []string{"t-shirt", "round-neck", "sale2019"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.SuccessfullyUpdatedFileIDs)\n}\n', }, ruby: { method: 'files.bulk.remove_tags', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.bulk.remove_tags(\n file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags: ["t-shirt", "round-neck", "sale2019"]\n)\n\nputs(response)', }, - typescript: { - method: 'client.files.bulk.removeTags', + cli: { + method: 'bulk removeTags', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.removeTags({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);", + "imagekit files:bulk remove-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be \\\n --tag t-shirt \\\n --tag round-neck \\\n --tag sale2019", + }, + php: { + method: 'files->bulk->removeTags', + example: + "files->bulk->removeTags(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Bulk.RemoveTags', + example: + 'BulkRemoveTagsParams parameters = new()\n{\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n Tags =\n [\n "t-shirt", "round-neck", "sale2019"\n ],\n};\n\nvar response = await client.Files.Bulk.RemoveTags(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/removeTags \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ],\n "tags": [\n "t-shirt",\n "round-neck",\n "sale2019"\n ]\n }\'', }, }, }, @@ -1011,24 +1011,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## removeAiTags\n\n`client.files.bulk.removeAITags(AITags: string[], fileIds: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/removeAITags`\n\nThis API removes AITags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `AITags: string[]`\n An array of AITags that you want to remove from the files.\n\n\n- `fileIds: string[]`\n An array of fileIds from which you want to remove AITags.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.removeAITags({ AITags: ['t-shirt', 'round-neck', 'sale2019'], fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] });\n\nconsole.log(response);\n```", perLanguage: { - cli: { - method: 'bulk removeAiTags', - example: - "imagekit files:bulk remove-ai-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --ai-tag t-shirt \\\n --ai-tag round-neck \\\n --ai-tag sale2019 \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be", - }, - csharp: { - method: 'Files.Bulk.RemoveAITags', - example: - 'BulkRemoveAITagsParams parameters = new()\n{\n AITags =\n [\n "t-shirt", "round-neck", "sale2019"\n ],\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n};\n\nvar response = await client.Files.Bulk.RemoveAITags(parameters);\n\nConsole.WriteLine(response);', - }, - go: { - method: 'client.Files.Bulk.RemoveAITags', + typescript: { + method: 'client.files.bulk.removeAITags', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Bulk.RemoveAITags(context.TODO(), imagekit.FileBulkRemoveAITagsParams{\n\t\tAITags: []string{"t-shirt", "round-neck", "sale2019"},\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.SuccessfullyUpdatedFileIDs)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.removeAITags({\n AITags: ['t-shirt', 'round-neck', 'sale2019'],\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);", }, - http: { + python: { + method: 'files.bulk.remove_ai_tags', example: - 'curl https://api.imagekit.io/v1/files/removeAITags \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "AITags": [\n "t-shirt",\n "round-neck",\n "sale2019"\n ],\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ]\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.remove_ai_tags(\n ai_tags=["t-shirt", "round-neck", "sale2019"],\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n)\nprint(response.successfully_updated_file_ids)', }, java: { method: 'files().bulk().removeAiTags', @@ -1040,25 +1031,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkRemoveAiTagsParams = BulkRemoveAiTagsParams.builder()\n .aiTags(listOf(\n "t-shirt",\n "round-neck",\n "sale2019",\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build()\n val response: BulkRemoveAiTagsResponse = client.files().bulk().removeAiTags(params)\n}', }, - php: { - method: 'files->bulk->removeAITags', - example: - "files->bulk->removeAITags(\n aiTags: ['t-shirt', 'round-neck', 'sale2019'],\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n);\n\nvar_dump($response);", - }, - python: { - method: 'files.bulk.remove_ai_tags', + go: { + method: 'client.Files.Bulk.RemoveAITags', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.remove_ai_tags(\n ai_tags=["t-shirt", "round-neck", "sale2019"],\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n)\nprint(response.successfully_updated_file_ids)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Bulk.RemoveAITags(context.TODO(), imagekit.FileBulkRemoveAITagsParams{\n\t\tAITags: []string{"t-shirt", "round-neck", "sale2019"},\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.SuccessfullyUpdatedFileIDs)\n}\n', }, ruby: { method: 'files.bulk.remove_ai_tags', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.bulk.remove_ai_tags(\n ai_tags: ["t-shirt", "round-neck", "sale2019"],\n file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"]\n)\n\nputs(response)', }, - typescript: { - method: 'client.files.bulk.removeAITags', + cli: { + method: 'bulk removeAiTags', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.removeAITags({\n AITags: ['t-shirt', 'round-neck', 'sale2019'],\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);", + "imagekit files:bulk remove-ai-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --ai-tag t-shirt \\\n --ai-tag round-neck \\\n --ai-tag sale2019 \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be", + }, + php: { + method: 'files->bulk->removeAITags', + example: + "files->bulk->removeAITags(\n aiTags: ['t-shirt', 'round-neck', 'sale2019'],\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Bulk.RemoveAITags', + example: + 'BulkRemoveAITagsParams parameters = new()\n{\n AITags =\n [\n "t-shirt", "round-neck", "sale2019"\n ],\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n};\n\nvar response = await client.Files.Bulk.RemoveAITags(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/removeAITags \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "AITags": [\n "t-shirt",\n "round-neck",\n "sale2019"\n ],\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ]\n }\'', }, }, }, @@ -1076,24 +1076,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## list\n\n`client.files.versions.list(fileId: string): object[]`\n\n**get** `/v1/files/{fileId}/versions`\n\nThis API returns details of all versions of a file.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst files = await client.files.versions.list('fileId');\n\nconsole.log(files);\n```", perLanguage: { - cli: { - method: 'versions list', - example: - "imagekit files:versions list \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", - }, - csharp: { - method: 'Files.Versions.List', - example: - 'VersionListParams parameters = new() { FileID = "fileId" };\n\nvar files = await client.Files.Versions.List(parameters);\n\nConsole.WriteLine(files);', - }, - go: { - method: 'client.Files.Versions.List', + typescript: { + method: 'client.files.versions.list', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfiles, err := client.Files.Versions.List(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", files)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst files = await client.files.versions.list('fileId');\n\nconsole.log(files);", }, - http: { + python: { + method: 'files.versions.list', example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfiles = client.files.versions.list(\n "fileId",\n)\nprint(files)', }, java: { method: 'files().versions().list', @@ -1105,25 +1096,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val files: List = client.files().versions().list("fileId")\n}', }, - php: { - method: 'files->versions->list', - example: - "files->versions->list('fileId');\n\nvar_dump($files);", - }, - python: { - method: 'files.versions.list', + go: { + method: 'client.Files.Versions.List', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfiles = client.files.versions.list(\n "fileId",\n)\nprint(files)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfiles, err := client.Files.Versions.List(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", files)\n}\n', }, ruby: { method: 'files.versions.list', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfiles = image_kit.files.versions.list("fileId")\n\nputs(files)', }, - typescript: { - method: 'client.files.versions.list', + cli: { + method: 'versions list', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst files = await client.files.versions.list('fileId');\n\nconsole.log(files);", + "imagekit files:versions list \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", + }, + php: { + method: 'files->versions->list', + example: + "files->versions->list('fileId');\n\nvar_dump($files);", + }, + csharp: { + method: 'Files.Versions.List', + example: + 'VersionListParams parameters = new() { FileID = "fileId" };\n\nvar files = await client.Files.Versions.List(parameters);\n\nConsole.WriteLine(files);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -1141,24 +1141,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## get\n\n`client.files.versions.get(fileId: string, versionId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/versions/{versionId}`\n\nThis API returns an object with details or attributes of a file version.\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.versions.get('versionId', { fileId: 'fileId' });\n\nconsole.log(file);\n```", perLanguage: { - cli: { - method: 'versions get', - example: - "imagekit files:versions get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId", - }, - csharp: { - method: 'Files.Versions.Get', - example: - 'VersionGetParams parameters = new()\n{\n FileID = "fileId",\n VersionID = "versionId",\n};\n\nvar file = await client.Files.Versions.Get(parameters);\n\nConsole.WriteLine(file);', - }, - go: { - method: 'client.Files.Versions.Get', + typescript: { + method: 'client.files.versions.get', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Versions.Get(\n\t\tcontext.TODO(),\n\t\t"versionId",\n\t\timagekit.FileVersionGetParams{\n\t\t\tFileID: "fileId",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file.VideoCodec)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.versions.get('versionId', { fileId: 'fileId' });\n\nconsole.log(file.videoCodec);", }, - http: { + python: { + method: 'files.versions.get', example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.versions.get(\n version_id="versionId",\n file_id="fileId",\n)\nprint(file.video_codec)', }, java: { method: 'files().versions().get', @@ -1170,25 +1161,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionGetParams = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build()\n val file: File = client.files().versions().get(params)\n}', }, - php: { - method: 'files->versions->get', - example: - "files->versions->get('versionId', fileID: 'fileId');\n\nvar_dump($file);", - }, - python: { - method: 'files.versions.get', + go: { + method: 'client.Files.Versions.Get', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.versions.get(\n version_id="versionId",\n file_id="fileId",\n)\nprint(file.video_codec)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Versions.Get(\n\t\tcontext.TODO(),\n\t\t"versionId",\n\t\timagekit.FileVersionGetParams{\n\t\t\tFileID: "fileId",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file.VideoCodec)\n}\n', }, ruby: { method: 'files.versions.get', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfile = image_kit.files.versions.get("versionId", file_id: "fileId")\n\nputs(file)', }, - typescript: { - method: 'client.files.versions.get', + cli: { + method: 'versions get', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.versions.get('versionId', { fileId: 'fileId' });\n\nconsole.log(file.videoCodec);", + "imagekit files:versions get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId", + }, + php: { + method: 'files->versions->get', + example: + "files->versions->get('versionId', fileID: 'fileId');\n\nvar_dump($file);", + }, + csharp: { + method: 'Files.Versions.Get', + example: + 'VersionGetParams parameters = new()\n{\n FileID = "fileId",\n VersionID = "versionId",\n};\n\nvar file = await client.Files.Versions.Get(parameters);\n\nConsole.WriteLine(file);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -1206,24 +1206,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## delete\n\n`client.files.versions.delete(fileId: string, versionId: string): { }`\n\n**delete** `/v1/files/{fileId}/versions/{versionId}`\n\nThis API deletes a non-current file version permanently. The API returns an empty response.\n\nNote: If you want to delete all versions of a file, use the delete file API.\n\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst version = await client.files.versions.delete('versionId', { fileId: 'fileId' });\n\nconsole.log(version);\n```", perLanguage: { - cli: { - method: 'versions delete', - example: - "imagekit files:versions delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId", - }, - csharp: { - method: 'Files.Versions.Delete', - example: - 'VersionDeleteParams parameters = new()\n{\n FileID = "fileId",\n VersionID = "versionId",\n};\n\nvar version = await client.Files.Versions.Delete(parameters);\n\nConsole.WriteLine(version);', - }, - go: { - method: 'client.Files.Versions.Delete', + typescript: { + method: 'client.files.versions.delete', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tversion, err := client.Files.Versions.Delete(\n\t\tcontext.TODO(),\n\t\t"versionId",\n\t\timagekit.FileVersionDeleteParams{\n\t\t\tFileID: "fileId",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", version)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst version = await client.files.versions.delete('versionId', { fileId: 'fileId' });\n\nconsole.log(version);", }, - http: { + python: { + method: 'files.versions.delete', example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nversion = client.files.versions.delete(\n version_id="versionId",\n file_id="fileId",\n)\nprint(version)', }, java: { method: 'files().versions().delete', @@ -1235,25 +1226,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.versions.VersionDeleteParams\nimport com.imagekit.api.models.files.versions.VersionDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionDeleteParams = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build()\n val version: VersionDeleteResponse = client.files().versions().delete(params)\n}', }, - php: { - method: 'files->versions->delete', - example: - "files->versions->delete('versionId', fileID: 'fileId');\n\nvar_dump($version);", - }, - python: { - method: 'files.versions.delete', + go: { + method: 'client.Files.Versions.Delete', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nversion = client.files.versions.delete(\n version_id="versionId",\n file_id="fileId",\n)\nprint(version)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tversion, err := client.Files.Versions.Delete(\n\t\tcontext.TODO(),\n\t\t"versionId",\n\t\timagekit.FileVersionDeleteParams{\n\t\t\tFileID: "fileId",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", version)\n}\n', }, ruby: { method: 'files.versions.delete', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nversion = image_kit.files.versions.delete("versionId", file_id: "fileId")\n\nputs(version)', }, - typescript: { - method: 'client.files.versions.delete', + cli: { + method: 'versions delete', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst version = await client.files.versions.delete('versionId', { fileId: 'fileId' });\n\nconsole.log(version);", + "imagekit files:versions delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId", + }, + php: { + method: 'files->versions->delete', + example: + "files->versions->delete('versionId', fileID: 'fileId');\n\nvar_dump($version);", + }, + csharp: { + method: 'Files.Versions.Delete', + example: + 'VersionDeleteParams parameters = new()\n{\n FileID = "fileId",\n VersionID = "versionId",\n};\n\nvar version = await client.Files.Versions.Delete(parameters);\n\nConsole.WriteLine(version);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -1271,24 +1271,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## restore\n\n`client.files.versions.restore(fileId: string, versionId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**put** `/v1/files/{fileId}/versions/{versionId}/restore`\n\nThis API restores a file version as the current file version.\n\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.versions.restore('versionId', { fileId: 'fileId' });\n\nconsole.log(file);\n```", perLanguage: { - cli: { - method: 'versions restore', - example: - "imagekit files:versions restore \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId", - }, - csharp: { - method: 'Files.Versions.Restore', - example: - 'VersionRestoreParams parameters = new()\n{\n FileID = "fileId",\n VersionID = "versionId",\n};\n\nvar file = await client.Files.Versions.Restore(parameters);\n\nConsole.WriteLine(file);', - }, - go: { - method: 'client.Files.Versions.Restore', + typescript: { + method: 'client.files.versions.restore', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Versions.Restore(\n\t\tcontext.TODO(),\n\t\t"versionId",\n\t\timagekit.FileVersionRestoreParams{\n\t\t\tFileID: "fileId",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file.VideoCodec)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.versions.restore('versionId', { fileId: 'fileId' });\n\nconsole.log(file.videoCodec);", }, - http: { + python: { + method: 'files.versions.restore', example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID/restore \\\n -X PUT \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.versions.restore(\n version_id="versionId",\n file_id="fileId",\n)\nprint(file.video_codec)', }, java: { method: 'files().versions().restore', @@ -1300,25 +1291,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionRestoreParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionRestoreParams = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build()\n val file: File = client.files().versions().restore(params)\n}', }, - php: { - method: 'files->versions->restore', - example: - "files->versions->restore('versionId', fileID: 'fileId');\n\nvar_dump($file);", - }, - python: { - method: 'files.versions.restore', + go: { + method: 'client.Files.Versions.Restore', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.versions.restore(\n version_id="versionId",\n file_id="fileId",\n)\nprint(file.video_codec)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Versions.Restore(\n\t\tcontext.TODO(),\n\t\t"versionId",\n\t\timagekit.FileVersionRestoreParams{\n\t\t\tFileID: "fileId",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file.VideoCodec)\n}\n', }, ruby: { method: 'files.versions.restore', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfile = image_kit.files.versions.restore("versionId", file_id: "fileId")\n\nputs(file)', }, - typescript: { - method: 'client.files.versions.restore', + cli: { + method: 'versions restore', + example: + "imagekit files:versions restore \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId", + }, + php: { + method: 'files->versions->restore', + example: + "files->versions->restore('versionId', fileID: 'fileId');\n\nvar_dump($file);", + }, + csharp: { + method: 'Files.Versions.Restore', + example: + 'VersionRestoreParams parameters = new()\n{\n FileID = "fileId",\n VersionID = "versionId",\n};\n\nvar file = await client.Files.Versions.Restore(parameters);\n\nConsole.WriteLine(file);', + }, + http: { example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.versions.restore('versionId', { fileId: 'fileId' });\n\nconsole.log(file.videoCodec);", + 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID/restore \\\n -X PUT \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -1337,24 +1337,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## get\n\n`client.files.metadata.get(fileId: string): { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/metadata`\n\nYou can programmatically get image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API.\n\nYou can also get the metadata in upload API response by passing `metadata` in `responseFields` parameter.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n JSON object containing metadata.\n\n - `audioCodec?: string`\n - `bitRate?: number`\n - `density?: number`\n - `duration?: number`\n - `exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }`\n - `format?: string`\n - `hasColorProfile?: boolean`\n - `hasTransparency?: boolean`\n - `height?: number`\n - `pHash?: string`\n - `quality?: number`\n - `size?: number`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst metadata = await client.files.metadata.get('fileId');\n\nconsole.log(metadata);\n```", perLanguage: { - cli: { - method: 'metadata get', - example: - "imagekit files:metadata get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", - }, - csharp: { - method: 'Files.Metadata.Get', - example: - 'MetadataGetParams parameters = new() { FileID = "fileId" };\n\nvar metadata = await client.Files.Metadata.Get(parameters);\n\nConsole.WriteLine(metadata);', - }, - go: { - method: 'client.Files.Metadata.Get', + typescript: { + method: 'client.files.metadata.get', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tmetadata, err := client.Files.Metadata.Get(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", metadata.VideoCodec)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst metadata = await client.files.metadata.get('fileId');\n\nconsole.log(metadata.videoCodec);", }, - http: { + python: { + method: 'files.metadata.get', example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/metadata \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nmetadata = client.files.metadata.get(\n "fileId",\n)\nprint(metadata.video_codec)', }, java: { method: 'files().metadata().get', @@ -1366,25 +1357,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.Metadata\nimport com.imagekit.api.models.files.metadata.MetadataGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val metadata: Metadata = client.files().metadata().get("fileId")\n}', }, - php: { - method: 'files->metadata->get', - example: - "files->metadata->get('fileId');\n\nvar_dump($metadata);", - }, - python: { - method: 'files.metadata.get', + go: { + method: 'client.Files.Metadata.Get', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nmetadata = client.files.metadata.get(\n "fileId",\n)\nprint(metadata.video_codec)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tmetadata, err := client.Files.Metadata.Get(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", metadata.VideoCodec)\n}\n', }, ruby: { method: 'files.metadata.get', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nmetadata = image_kit.files.metadata.get("fileId")\n\nputs(metadata)', }, - typescript: { - method: 'client.files.metadata.get', + cli: { + method: 'metadata get', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst metadata = await client.files.metadata.get('fileId');\n\nconsole.log(metadata.videoCodec);", + "imagekit files:metadata get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", + }, + php: { + method: 'files->metadata->get', + example: + "files->metadata->get('fileId');\n\nvar_dump($metadata);", + }, + csharp: { + method: 'Files.Metadata.Get', + example: + 'MetadataGetParams parameters = new() { FileID = "fileId" };\n\nvar metadata = await client.Files.Metadata.Get(parameters);\n\nConsole.WriteLine(metadata);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID/metadata \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -1403,24 +1403,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## getFromURL\n\n`client.files.metadata.getFromURL(url: string): { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n\n**get** `/v1/metadata`\n\nGet image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API.\n\n\n### Parameters\n\n- `url: string`\n Should be a valid file URL. It should be accessible using your ImageKit.io account.\n\n\n### Returns\n\n- `{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n JSON object containing metadata.\n\n - `audioCodec?: string`\n - `bitRate?: number`\n - `density?: number`\n - `duration?: number`\n - `exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }`\n - `format?: string`\n - `hasColorProfile?: boolean`\n - `hasTransparency?: boolean`\n - `height?: number`\n - `pHash?: string`\n - `quality?: number`\n - `size?: number`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst metadata = await client.files.metadata.getFromURL({ url: 'https://example.com' });\n\nconsole.log(metadata);\n```", perLanguage: { - cli: { - method: 'metadata getFromURL', - example: - "imagekit files:metadata get-from-url \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --url https://example.com", - }, - csharp: { - method: 'Files.Metadata.GetFromUrl', - example: - 'MetadataGetFromUrlParams parameters = new() { Url = "https://example.com" };\n\nvar metadata = await client.Files.Metadata.GetFromUrl(parameters);\n\nConsole.WriteLine(metadata);', - }, - go: { - method: 'client.Files.Metadata.GetFromURL', + typescript: { + method: 'client.files.metadata.getFromURL', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tmetadata, err := client.Files.Metadata.GetFromURL(context.TODO(), imagekit.FileMetadataGetFromURLParams{\n\t\tURL: "https://example.com",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", metadata.VideoCodec)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst metadata = await client.files.metadata.getFromURL({ url: 'https://example.com' });\n\nconsole.log(metadata.videoCodec);", }, - http: { + python: { + method: 'files.metadata.get_from_url', example: - 'curl https://api.imagekit.io/v1/metadata \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nmetadata = client.files.metadata.get_from_url(\n url="https://example.com",\n)\nprint(metadata.video_codec)', }, java: { method: 'files().metadata().getFromUrl', @@ -1432,25 +1423,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.Metadata\nimport com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: MetadataGetFromUrlParams = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build()\n val metadata: Metadata = client.files().metadata().getFromUrl(params)\n}', }, - php: { - method: 'files->metadata->getFromURL', - example: - "files->metadata->getFromURL(url: 'https://example.com');\n\nvar_dump($metadata);", - }, - python: { - method: 'files.metadata.get_from_url', + go: { + method: 'client.Files.Metadata.GetFromURL', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nmetadata = client.files.metadata.get_from_url(\n url="https://example.com",\n)\nprint(metadata.video_codec)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tmetadata, err := client.Files.Metadata.GetFromURL(context.TODO(), imagekit.FileMetadataGetFromURLParams{\n\t\tURL: "https://example.com",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", metadata.VideoCodec)\n}\n', }, ruby: { method: 'files.metadata.get_from_url', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nmetadata = image_kit.files.metadata.get_from_url(url: "https://example.com")\n\nputs(metadata)', }, - typescript: { - method: 'client.files.metadata.getFromURL', + cli: { + method: 'metadata getFromURL', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst metadata = await client.files.metadata.getFromURL({ url: 'https://example.com' });\n\nconsole.log(metadata.videoCodec);", + "imagekit files:metadata get-from-url \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --url https://example.com", + }, + php: { + method: 'files->metadata->getFromURL', + example: + "files->metadata->getFromURL(url: 'https://example.com');\n\nvar_dump($metadata);", + }, + csharp: { + method: 'Files.Metadata.GetFromUrl', + example: + 'MetadataGetFromUrlParams parameters = new() { Url = "https://example.com" };\n\nvar metadata = await client.Files.Metadata.GetFromUrl(parameters);\n\nConsole.WriteLine(metadata);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/metadata \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -1468,24 +1468,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## list\n\n`client.savedExtensions.list(): object[]`\n\n**get** `/v1/saved-extensions`\n\nThis API returns an array of all saved extensions for your account. Saved extensions allow you to save complex extension configurations and reuse them by referencing them by ID in upload or update file APIs.\n\n\n### Returns\n\n- `{ id?: string; config?: object | object | object | object; createdAt?: string; description?: string; name?: string; updatedAt?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtensions = await client.savedExtensions.list();\n\nconsole.log(savedExtensions);\n```", perLanguage: { - cli: { - method: 'savedExtensions list', - example: - "imagekit saved-extensions list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - csharp: { - method: 'SavedExtensions.List', - example: - 'SavedExtensionListParams parameters = new();\n\nvar savedExtensions = await client.SavedExtensions.List(parameters);\n\nConsole.WriteLine(savedExtensions);', - }, - go: { - method: 'client.SavedExtensions.List', + typescript: { + method: 'client.savedExtensions.list', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtensions, err := client.SavedExtensions.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtensions)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtensions = await client.savedExtensions.list();\n\nconsole.log(savedExtensions);", }, - http: { + python: { + method: 'saved_extensions.list', example: - 'curl https://api.imagekit.io/v1/saved-extensions \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extensions = client.saved_extensions.list()\nprint(saved_extensions)', }, java: { method: 'savedExtensions().list', @@ -1497,25 +1488,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtensions: List = client.savedExtensions().list()\n}', }, - php: { - method: 'savedExtensions->list', - example: - "savedExtensions->list();\n\nvar_dump($savedExtensions);", - }, - python: { - method: 'saved_extensions.list', + go: { + method: 'client.SavedExtensions.List', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extensions = client.saved_extensions.list()\nprint(saved_extensions)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtensions, err := client.SavedExtensions.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtensions)\n}\n', }, ruby: { method: 'saved_extensions.list', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nsaved_extensions = image_kit.saved_extensions.list\n\nputs(saved_extensions)', }, - typescript: { - method: 'client.savedExtensions.list', + cli: { + method: 'savedExtensions list', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtensions = await client.savedExtensions.list();\n\nconsole.log(savedExtensions);", + "imagekit saved-extensions list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'savedExtensions->list', + example: + "savedExtensions->list();\n\nvar_dump($savedExtensions);", + }, + csharp: { + method: 'SavedExtensions.List', + example: + 'SavedExtensionListParams parameters = new();\n\nvar savedExtensions = await client.SavedExtensions.List(parameters);\n\nConsole.WriteLine(savedExtensions);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/saved-extensions \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -1538,24 +1538,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## create\n\n`client.savedExtensions.create(config: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }, description: string, name: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**post** `/v1/saved-extensions`\n\nThis API creates a new saved extension. Saved extensions allow you to save complex extension configurations (like AI tasks) and reuse them by referencing the ID in upload or update file APIs.\n\n**Saved extension limit** \\\nYou can create a maximum of 100 saved extensions per account.\n\n\n### Parameters\n\n- `config: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n Configuration object for an extension (base extensions only, not saved extension references).\n\n- `description: string`\n Description of what the saved extension does.\n\n- `name: string`\n Name of the saved extension.\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.create({\n config: { name: 'remove-bg' },\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n});\n\nconsole.log(savedExtension);\n```", perLanguage: { - cli: { - method: 'savedExtensions create', - example: - "imagekit saved-extensions create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --config '{name: remove-bg}' \\\n --description 'Analyzes vehicle images for type, condition, and quality assessment' \\\n --name 'Car Quality Analysis'", - }, - csharp: { - method: 'SavedExtensions.Create', - example: - 'SavedExtensionCreateParams parameters = new()\n{\n Config = new RemoveBg()\n {\n Options = new()\n {\n AddShadow = true,\n BgColor = "bg_color",\n BgImageUrl = "bg_image_url",\n Semitransparency = true,\n },\n },\n Description = "Analyzes vehicle images for type, condition, and quality assessment",\n Name = "Car Quality Analysis",\n};\n\nvar savedExtension = await client.SavedExtensions.Create(parameters);\n\nConsole.WriteLine(savedExtension);', - }, - go: { - method: 'client.SavedExtensions.New', + typescript: { + method: 'client.savedExtensions.create', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n\t"github.com/imagekit-developer/imagekit-go/shared"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.New(context.TODO(), imagekit.SavedExtensionNewParams{\n\t\tConfig: shared.ExtensionConfigUnionParam{\n\t\t\tOfRemoveBg: &shared.ExtensionConfigRemoveBgParam{},\n\t\t},\n\t\tDescription: "Analyzes vehicle images for type, condition, and quality assessment",\n\t\tName: "Car Quality Analysis",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtension.ID)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.create({\n config: { name: 'remove-bg' },\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n});\n\nconsole.log(savedExtension.id);", }, - http: { + python: { + method: 'saved_extensions.create', example: - 'curl https://api.imagekit.io/v1/saved-extensions \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "config": {\n "name": "remove-bg"\n },\n "description": "Analyzes vehicle images for type, condition, and quality assessment",\n "name": "Car Quality Analysis"\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.create(\n config={\n "name": "remove-bg"\n },\n description="Analyzes vehicle images for type, condition, and quality assessment",\n name="Car Quality Analysis",\n)\nprint(saved_extension.id)', }, java: { method: 'savedExtensions().create', @@ -1567,25 +1558,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.ExtensionConfig\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionCreateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: SavedExtensionCreateParams = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build()\n val savedExtension: SavedExtension = client.savedExtensions().create(params)\n}', }, - php: { - method: 'savedExtensions->create', - example: - "savedExtensions->create(\n config: [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n);\n\nvar_dump($savedExtension);", - }, - python: { - method: 'saved_extensions.create', + go: { + method: 'client.SavedExtensions.New', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.create(\n config={\n "name": "remove-bg"\n },\n description="Analyzes vehicle images for type, condition, and quality assessment",\n name="Car Quality Analysis",\n)\nprint(saved_extension.id)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n\t"github.com/imagekit-developer/imagekit-go/shared"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.New(context.TODO(), imagekit.SavedExtensionNewParams{\n\t\tConfig: shared.ExtensionConfigUnionParam{\n\t\t\tOfRemoveBg: &shared.ExtensionConfigRemoveBgParam{},\n\t\t},\n\t\tDescription: "Analyzes vehicle images for type, condition, and quality assessment",\n\t\tName: "Car Quality Analysis",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtension.ID)\n}\n', }, ruby: { method: 'saved_extensions.create', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nsaved_extension = image_kit.saved_extensions.create(\n config: {name: :"remove-bg"},\n description: "Analyzes vehicle images for type, condition, and quality assessment",\n name: "Car Quality Analysis"\n)\n\nputs(saved_extension)', }, - typescript: { - method: 'client.savedExtensions.create', + cli: { + method: 'savedExtensions create', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.create({\n config: { name: 'remove-bg' },\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n});\n\nconsole.log(savedExtension.id);", + "imagekit saved-extensions create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --config '{name: remove-bg}' \\\n --description 'Analyzes vehicle images for type, condition, and quality assessment' \\\n --name 'Car Quality Analysis'", + }, + php: { + method: 'savedExtensions->create', + example: + "savedExtensions->create(\n config: [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n);\n\nvar_dump($savedExtension);", + }, + csharp: { + method: 'SavedExtensions.Create', + example: + 'SavedExtensionCreateParams parameters = new()\n{\n Config = new RemoveBg()\n {\n Options = new()\n {\n AddShadow = true,\n BgColor = "bg_color",\n BgImageUrl = "bg_image_url",\n Semitransparency = true,\n },\n },\n Description = "Analyzes vehicle images for type, condition, and quality assessment",\n Name = "Car Quality Analysis",\n};\n\nvar savedExtension = await client.SavedExtensions.Create(parameters);\n\nConsole.WriteLine(savedExtension);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/saved-extensions \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "config": {\n "name": "remove-bg"\n },\n "description": "Analyzes vehicle images for type, condition, and quality assessment",\n "name": "Car Quality Analysis"\n }\'', }, }, }, @@ -1603,24 +1603,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## get\n\n`client.savedExtensions.get(id: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**get** `/v1/saved-extensions/{id}`\n\nThis API returns details of a specific saved extension by ID.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.get('id');\n\nconsole.log(savedExtension);\n```", perLanguage: { - cli: { - method: 'savedExtensions get', - example: - "imagekit saved-extensions get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - csharp: { - method: 'SavedExtensions.Get', - example: - 'SavedExtensionGetParams parameters = new() { ID = "id" };\n\nvar savedExtension = await client.SavedExtensions.Get(parameters);\n\nConsole.WriteLine(savedExtension);', - }, - go: { - method: 'client.SavedExtensions.Get', + typescript: { + method: 'client.savedExtensions.get', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.Get(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtension.ID)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.get('id');\n\nconsole.log(savedExtension.id);", }, - http: { + python: { + method: 'saved_extensions.get', example: - 'curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.get(\n "id",\n)\nprint(saved_extension.id)', }, java: { method: 'savedExtensions().get', @@ -1632,25 +1623,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtension: SavedExtension = client.savedExtensions().get("id")\n}', }, - php: { - method: 'savedExtensions->get', - example: - "savedExtensions->get('id');\n\nvar_dump($savedExtension);", - }, - python: { - method: 'saved_extensions.get', + go: { + method: 'client.SavedExtensions.Get', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.get(\n "id",\n)\nprint(saved_extension.id)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.Get(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtension.ID)\n}\n', }, ruby: { method: 'saved_extensions.get', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nsaved_extension = image_kit.saved_extensions.get("id")\n\nputs(saved_extension)', }, - typescript: { - method: 'client.savedExtensions.get', + cli: { + method: 'savedExtensions get', + example: + "imagekit saved-extensions get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'savedExtensions->get', + example: + "savedExtensions->get('id');\n\nvar_dump($savedExtension);", + }, + csharp: { + method: 'SavedExtensions.Get', + example: + 'SavedExtensionGetParams parameters = new() { ID = "id" };\n\nvar savedExtension = await client.SavedExtensions.Get(parameters);\n\nConsole.WriteLine(savedExtension);', + }, + http: { example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.get('id');\n\nconsole.log(savedExtension.id);", + 'curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -1674,24 +1674,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## update\n\n`client.savedExtensions.update(id: string, config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }, description?: string, name?: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**patch** `/v1/saved-extensions/{id}`\n\nThis API updates an existing saved extension. You can update the name, description, or config.\n\n\n### Parameters\n\n- `id: string`\n\n- `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n Configuration object for an extension (base extensions only, not saved extension references).\n\n- `description?: string`\n Updated description of the saved extension.\n\n- `name?: string`\n Updated name of the saved extension.\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.update('id');\n\nconsole.log(savedExtension);\n```", perLanguage: { - cli: { - method: 'savedExtensions update', - example: - "imagekit saved-extensions update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - csharp: { - method: 'SavedExtensions.Update', - example: - 'SavedExtensionUpdateParams parameters = new() { ID = "id" };\n\nvar savedExtension = await client.SavedExtensions.Update(parameters);\n\nConsole.WriteLine(savedExtension);', - }, - go: { - method: 'client.SavedExtensions.Update', + typescript: { + method: 'client.savedExtensions.update', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.SavedExtensionUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtension.ID)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.update('id');\n\nconsole.log(savedExtension.id);", }, - http: { + python: { + method: 'saved_extensions.update', example: - "curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -X PATCH \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{}'", + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.update(\n id="id",\n)\nprint(saved_extension.id)', }, java: { method: 'savedExtensions().update', @@ -1703,25 +1694,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtension: SavedExtension = client.savedExtensions().update("id")\n}', }, - php: { - method: 'savedExtensions->update', - example: - "savedExtensions->update(\n 'id',\n config: [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n description: 'x',\n name: 'x',\n);\n\nvar_dump($savedExtension);", - }, - python: { - method: 'saved_extensions.update', + go: { + method: 'client.SavedExtensions.Update', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.update(\n id="id",\n)\nprint(saved_extension.id)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.SavedExtensionUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtension.ID)\n}\n', }, ruby: { method: 'saved_extensions.update', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nsaved_extension = image_kit.saved_extensions.update("id")\n\nputs(saved_extension)', }, - typescript: { - method: 'client.savedExtensions.update', + cli: { + method: 'savedExtensions update', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.update('id');\n\nconsole.log(savedExtension.id);", + "imagekit saved-extensions update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'savedExtensions->update', + example: + "savedExtensions->update(\n 'id',\n config: [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n description: 'x',\n name: 'x',\n);\n\nvar_dump($savedExtension);", + }, + csharp: { + method: 'SavedExtensions.Update', + example: + 'SavedExtensionUpdateParams parameters = new() { ID = "id" };\n\nvar savedExtension = await client.SavedExtensions.Update(parameters);\n\nConsole.WriteLine(savedExtension);', + }, + http: { + example: + "curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -X PATCH \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{}'", }, }, }, @@ -1737,24 +1737,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## delete\n\n`client.savedExtensions.delete(id: string): void`\n\n**delete** `/v1/saved-extensions/{id}`\n\nThis API deletes a saved extension permanently.\n\n\n### Parameters\n\n- `id: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.savedExtensions.delete('id')\n```", perLanguage: { - cli: { - method: 'savedExtensions delete', - example: - "imagekit saved-extensions delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - csharp: { - method: 'SavedExtensions.Delete', - example: - 'SavedExtensionDeleteParams parameters = new() { ID = "id" };\n\nawait client.SavedExtensions.Delete(parameters);', - }, - go: { - method: 'client.SavedExtensions.Delete', + typescript: { + method: 'client.savedExtensions.delete', example: - 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.SavedExtensions.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.savedExtensions.delete('id');", }, - http: { + python: { + method: 'saved_extensions.delete', example: - 'curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.saved_extensions.delete(\n "id",\n)', }, java: { method: 'savedExtensions().delete', @@ -1766,25 +1757,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.savedExtensions().delete("id")\n}', }, - php: { - method: 'savedExtensions->delete', - example: - "savedExtensions->delete('id');\n\nvar_dump($result);", - }, - python: { - method: 'saved_extensions.delete', + go: { + method: 'client.SavedExtensions.Delete', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.saved_extensions.delete(\n "id",\n)', + 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.SavedExtensions.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'saved_extensions.delete', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.saved_extensions.delete("id")\n\nputs(result)', }, - typescript: { - method: 'client.savedExtensions.delete', + cli: { + method: 'savedExtensions delete', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.savedExtensions.delete('id');", + "imagekit saved-extensions delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'savedExtensions->delete', + example: + "savedExtensions->delete('id');\n\nvar_dump($result);", + }, + csharp: { + method: 'SavedExtensions.Delete', + example: + 'SavedExtensionDeleteParams parameters = new() { ID = "id" };\n\nawait client.SavedExtensions.Delete(parameters);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -1811,23 +1811,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## list\n\n`client.assets.list(fileType?: 'all' | 'image' | 'non-image', limit?: number, path?: string, searchQuery?: string, skip?: number, sort?: string, type?: 'file' | 'file-version' | 'folder' | 'all'): object | object[]`\n\n**get** `/v1/files`\n\nThis API can list all the uploaded files and folders in your ImageKit.io media library. In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and provide this generated string as the value of the `searchQuery`.\n\n\n### Parameters\n\n- `fileType?: 'all' | 'image' | 'non-image'`\n Filter results by file type.\n\n- `all` — include all file types \n- `image` — include only image files \n- `non-image` — include only non-image files (e.g., JS, CSS, video)\n\n- `limit?: number`\n The maximum number of results to return in response.\n\n\n- `path?: string`\n Folder path if you want to limit the search within a specific folder. For example, `/sales-banner/` will only search in folder sales-banner.\n\nNote : If your use case involves searching within a folder as well as its subfolders, you can use `path` parameter in `searchQuery` with appropriate operator.\nCheckout [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) for more information.\n\n\n- `searchQuery?: string`\n Query string in a Lucene-like query language e.g. `createdAt > \"7d\"`.\n\nNote : When the searchQuery parameter is present, the following query parameters will have no effect on the result:\n\n1. `tags`\n2. `type`\n3. `name`\n\n[Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) from examples.\n\n\n- `skip?: number`\n The number of results to skip before returning results.\n\n\n- `sort?: string`\n Sort the results by one of the supported fields in ascending or descending order.\n\n- `type?: 'file' | 'file-version' | 'folder' | 'all'`\n Filter results by asset type.\n\n- `file` — returns only files \n- `file-version` — returns specific file versions \n- `folder` — returns only folders \n- `all` — returns both files and folders (excludes `file-version`)\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; } | { createdAt?: string; customMetadata?: object; folderId?: string; folderPath?: string; name?: string; type?: 'folder'; updatedAt?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst assets = await client.assets.list();\n\nconsole.log(assets);\n```", perLanguage: { - cli: { - method: 'assets list', - example: "imagekit assets list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - csharp: { - method: 'Assets.List', - example: - 'AssetListParams parameters = new();\n\nvar assets = await client.Assets.List(parameters);\n\nConsole.WriteLine(assets);', - }, - go: { - method: 'client.Assets.List', + typescript: { + method: 'client.assets.list', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tassets, err := client.Assets.List(context.TODO(), imagekit.AssetListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", assets)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst assets = await client.assets.list();\n\nconsole.log(assets);", }, - http: { + python: { + method: 'assets.list', example: - 'curl https://api.imagekit.io/v1/files \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nassets = client.assets.list()\nprint(assets)', }, java: { method: 'assets().list', @@ -1839,25 +1831,33 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.assets.AssetListParams\nimport com.imagekit.api.models.assets.AssetListResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val assets: List = client.assets().list()\n}', }, - php: { - method: 'assets->list', - example: - "assets->list(\n fileType: 'all',\n limit: 1,\n path: 'path',\n searchQuery: 'searchQuery',\n skip: 0,\n sort: 'ASC_NAME',\n type: 'file',\n);\n\nvar_dump($assets);", - }, - python: { - method: 'assets.list', + go: { + method: 'client.Assets.List', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nassets = client.assets.list()\nprint(assets)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tassets, err := client.Assets.List(context.TODO(), imagekit.AssetListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", assets)\n}\n', }, ruby: { method: 'assets.list', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nassets = image_kit.assets.list\n\nputs(assets)', }, - typescript: { - method: 'client.assets.list', + cli: { + method: 'assets list', + example: "imagekit assets list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'assets->list', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst assets = await client.assets.list();\n\nconsole.log(assets);", + "assets->list(\n fileType: 'all',\n limit: 1,\n path: 'path',\n searchQuery: 'searchQuery',\n skip: 0,\n sort: 'ASC_NAME',\n type: 'file',\n);\n\nvar_dump($assets);", + }, + csharp: { + method: 'Assets.List', + example: + 'AssetListParams parameters = new();\n\nvar assets = await client.Assets.List(parameters);\n\nConsole.WriteLine(assets);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -1875,24 +1875,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## create\n\n`client.cache.invalidation.create(url: string): { requestId?: string; }`\n\n**post** `/v1/files/purge`\n\nThis API will purge CDN cache and ImageKit.io's internal cache for a file. Note: Purge cache is an asynchronous process and it may take some time to reflect the changes.\n\n\n### Parameters\n\n- `url: string`\n The full URL of the file to be purged.\n\n\n### Returns\n\n- `{ requestId?: string; }`\n\n - `requestId?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst invalidation = await client.cache.invalidation.create({ url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg' });\n\nconsole.log(invalidation);\n```", perLanguage: { - cli: { - method: 'invalidation create', - example: - "imagekit cache:invalidation create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --url https://ik.imagekit.io/your_imagekit_id/default-image.jpg", - }, - csharp: { - method: 'Cache.Invalidation.Create', - example: - 'InvalidationCreateParams parameters = new()\n{\n Url = "https://ik.imagekit.io/your_imagekit_id/default-image.jpg"\n};\n\nvar invalidation = await client.Cache.Invalidation.Create(parameters);\n\nConsole.WriteLine(invalidation);', - }, - go: { - method: 'client.Cache.Invalidation.New', + typescript: { + method: 'client.cache.invalidation.create', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tinvalidation, err := client.Cache.Invalidation.New(context.TODO(), imagekit.CacheInvalidationNewParams{\n\t\tURL: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", invalidation.RequestID)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst invalidation = await client.cache.invalidation.create({\n url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg',\n});\n\nconsole.log(invalidation.requestId);", }, - http: { + python: { + method: 'cache.invalidation.create', example: - 'curl https://api.imagekit.io/v1/files/purge \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "url": "https://ik.imagekit.io/your_imagekit_id/default-image.jpg"\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ninvalidation = client.cache.invalidation.create(\n url="https://ik.imagekit.io/your_imagekit_id/default-image.jpg",\n)\nprint(invalidation.request_id)', }, java: { method: 'cache().invalidation().create', @@ -1904,25 +1895,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateParams\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: InvalidationCreateParams = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build()\n val invalidation: InvalidationCreateResponse = client.cache().invalidation().create(params)\n}', }, - php: { - method: 'cache->invalidation->create', - example: - "cache->invalidation->create(\n url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg'\n);\n\nvar_dump($invalidation);", - }, - python: { - method: 'cache.invalidation.create', + go: { + method: 'client.Cache.Invalidation.New', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ninvalidation = client.cache.invalidation.create(\n url="https://ik.imagekit.io/your_imagekit_id/default-image.jpg",\n)\nprint(invalidation.request_id)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tinvalidation, err := client.Cache.Invalidation.New(context.TODO(), imagekit.CacheInvalidationNewParams{\n\t\tURL: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", invalidation.RequestID)\n}\n', }, ruby: { method: 'cache.invalidation.create', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ninvalidation = image_kit.cache.invalidation.create(url: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n\nputs(invalidation)', }, - typescript: { - method: 'client.cache.invalidation.create', + cli: { + method: 'invalidation create', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst invalidation = await client.cache.invalidation.create({\n url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg',\n});\n\nconsole.log(invalidation.requestId);", + "imagekit cache:invalidation create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --url https://ik.imagekit.io/your_imagekit_id/default-image.jpg", + }, + php: { + method: 'cache->invalidation->create', + example: + "cache->invalidation->create(\n url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg'\n);\n\nvar_dump($invalidation);", + }, + csharp: { + method: 'Cache.Invalidation.Create', + example: + 'InvalidationCreateParams parameters = new()\n{\n Url = "https://ik.imagekit.io/your_imagekit_id/default-image.jpg"\n};\n\nvar invalidation = await client.Cache.Invalidation.Create(parameters);\n\nConsole.WriteLine(invalidation);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/purge \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "url": "https://ik.imagekit.io/your_imagekit_id/default-image.jpg"\n }\'', }, }, }, @@ -1939,24 +1939,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## get\n\n`client.cache.invalidation.get(requestId: string): { status?: 'Pending' | 'Completed'; }`\n\n**get** `/v1/files/purge/{requestId}`\n\nThis API returns the status of a purge cache request.\n\n\n### Parameters\n\n- `requestId: string`\n\n### Returns\n\n- `{ status?: 'Pending' | 'Completed'; }`\n\n - `status?: 'Pending' | 'Completed'`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst invalidation = await client.cache.invalidation.get('requestId');\n\nconsole.log(invalidation);\n```", perLanguage: { - cli: { - method: 'invalidation get', - example: - "imagekit cache:invalidation get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --request-id requestId", - }, - csharp: { - method: 'Cache.Invalidation.Get', - example: - 'InvalidationGetParams parameters = new() { RequestID = "requestId" };\n\nvar invalidation = await client.Cache.Invalidation.Get(parameters);\n\nConsole.WriteLine(invalidation);', - }, - go: { - method: 'client.Cache.Invalidation.Get', + typescript: { + method: 'client.cache.invalidation.get', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tinvalidation, err := client.Cache.Invalidation.Get(context.TODO(), "requestId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", invalidation.Status)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst invalidation = await client.cache.invalidation.get('requestId');\n\nconsole.log(invalidation.status);", }, - http: { + python: { + method: 'cache.invalidation.get', example: - 'curl https://api.imagekit.io/v1/files/purge/$REQUEST_ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ninvalidation = client.cache.invalidation.get(\n "requestId",\n)\nprint(invalidation.status)', }, java: { method: 'cache().invalidation().get', @@ -1968,25 +1959,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetParams\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val invalidation: InvalidationGetResponse = client.cache().invalidation().get("requestId")\n}', }, - php: { - method: 'cache->invalidation->get', + go: { + method: 'client.Cache.Invalidation.Get', example: - "cache->invalidation->get('requestId');\n\nvar_dump($invalidation);", + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tinvalidation, err := client.Cache.Invalidation.Get(context.TODO(), "requestId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", invalidation.Status)\n}\n', }, - python: { + ruby: { method: 'cache.invalidation.get', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ninvalidation = client.cache.invalidation.get(\n "requestId",\n)\nprint(invalidation.status)', + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ninvalidation = image_kit.cache.invalidation.get("requestId")\n\nputs(invalidation)', }, - ruby: { - method: 'cache.invalidation.get', + cli: { + method: 'invalidation get', + example: + "imagekit cache:invalidation get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --request-id requestId", + }, + php: { + method: 'cache->invalidation->get', + example: + "cache->invalidation->get('requestId');\n\nvar_dump($invalidation);", + }, + csharp: { + method: 'Cache.Invalidation.Get', example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ninvalidation = image_kit.cache.invalidation.get("requestId")\n\nputs(invalidation)', + 'InvalidationGetParams parameters = new() { RequestID = "requestId" };\n\nvar invalidation = await client.Cache.Invalidation.Get(parameters);\n\nConsole.WriteLine(invalidation);', }, - typescript: { - method: 'client.cache.invalidation.get', + http: { example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst invalidation = await client.cache.invalidation.get('requestId');\n\nconsole.log(invalidation.status);", + 'curl https://api.imagekit.io/v1/files/purge/$REQUEST_ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -2004,24 +2004,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## create\n\n`client.folders.create(folderName: string, parentFolderPath: string): { }`\n\n**post** `/v1/folder`\n\nThis will create a new folder. You can specify the folder name and location of the parent folder where this new folder should be created.\n\n\n### Parameters\n\n- `folderName: string`\n The folder will be created with this name. \n\nAll characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) will be replaced by an underscore i.e. `_`.\n\n\n- `parentFolderPath: string`\n The folder where the new folder should be created, for root use `/` else the path e.g. `containing/folder/`.\n\nNote: If any folder(s) is not present in the parentFolderPath parameter, it will be automatically created. For example, if you pass `/product/images/summer`, then `product`, `images`, and `summer` folders will be created if they don't already exist.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst folder = await client.folders.create({ folderName: 'summer', parentFolderPath: '/product/images/' });\n\nconsole.log(folder);\n```", perLanguage: { - cli: { - method: 'folders create', - example: - "imagekit folders create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-name summer \\\n --parent-folder-path /product/images/", - }, - csharp: { - method: 'Folders.Create', - example: - 'FolderCreateParams parameters = new()\n{\n FolderName = "summer",\n ParentFolderPath = "/product/images/",\n};\n\nvar folder = await client.Folders.Create(parameters);\n\nConsole.WriteLine(folder);', - }, - go: { - method: 'client.Folders.New', + typescript: { + method: 'client.folders.create', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfolder, err := client.Folders.New(context.TODO(), imagekit.FolderNewParams{\n\t\tFolderName: "summer",\n\t\tParentFolderPath: "/product/images/",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", folder)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst folder = await client.folders.create({\n folderName: 'summer',\n parentFolderPath: '/product/images/',\n});\n\nconsole.log(folder);", }, - http: { + python: { + method: 'folders.create', example: - 'curl https://api.imagekit.io/v1/folder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "folderName": "summer",\n "parentFolderPath": "/product/images/"\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfolder = client.folders.create(\n folder_name="summer",\n parent_folder_path="/product/images/",\n)\nprint(folder)', }, java: { method: 'folders().create', @@ -2033,25 +2024,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderCreateParams\nimport com.imagekit.api.models.folders.FolderCreateResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderCreateParams = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build()\n val folder: FolderCreateResponse = client.folders().create(params)\n}', }, - php: { - method: 'folders->create', - example: - "folders->create(\n folderName: 'summer', parentFolderPath: '/product/images/'\n);\n\nvar_dump($folder);", - }, - python: { - method: 'folders.create', + go: { + method: 'client.Folders.New', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfolder = client.folders.create(\n folder_name="summer",\n parent_folder_path="/product/images/",\n)\nprint(folder)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfolder, err := client.Folders.New(context.TODO(), imagekit.FolderNewParams{\n\t\tFolderName: "summer",\n\t\tParentFolderPath: "/product/images/",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", folder)\n}\n', }, ruby: { method: 'folders.create', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfolder = image_kit.folders.create(folder_name: "summer", parent_folder_path: "/product/images/")\n\nputs(folder)', }, - typescript: { - method: 'client.folders.create', + cli: { + method: 'folders create', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst folder = await client.folders.create({\n folderName: 'summer',\n parentFolderPath: '/product/images/',\n});\n\nconsole.log(folder);", + "imagekit folders create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-name summer \\\n --parent-folder-path /product/images/", + }, + php: { + method: 'folders->create', + example: + "folders->create(\n folderName: 'summer', parentFolderPath: '/product/images/'\n);\n\nvar_dump($folder);", + }, + csharp: { + method: 'Folders.Create', + example: + 'FolderCreateParams parameters = new()\n{\n FolderName = "summer",\n ParentFolderPath = "/product/images/",\n};\n\nvar folder = await client.Folders.Create(parameters);\n\nConsole.WriteLine(folder);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/folder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "folderName": "summer",\n "parentFolderPath": "/product/images/"\n }\'', }, }, }, @@ -2069,24 +2069,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## delete\n\n`client.folders.delete(folderPath: string): { }`\n\n**delete** `/v1/folder`\n\nThis will delete a folder and all its contents permanently. The API returns an empty response.\n\n\n### Parameters\n\n- `folderPath: string`\n Full path to the folder you want to delete. For example `/folder/to/delete/`.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst folder = await client.folders.delete({ folderPath: '/folder/to/delete/' });\n\nconsole.log(folder);\n```", perLanguage: { - cli: { - method: 'folders delete', - example: - "imagekit folders delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-path /folder/to/delete/", - }, - csharp: { - method: 'Folders.Delete', - example: - 'FolderDeleteParams parameters = new() { FolderPath = "/folder/to/delete/" };\n\nvar folder = await client.Folders.Delete(parameters);\n\nConsole.WriteLine(folder);', - }, - go: { - method: 'client.Folders.Delete', + typescript: { + method: 'client.folders.delete', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfolder, err := client.Folders.Delete(context.TODO(), imagekit.FolderDeleteParams{\n\t\tFolderPath: "/folder/to/delete/",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", folder)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst folder = await client.folders.delete({ folderPath: '/folder/to/delete/' });\n\nconsole.log(folder);", }, - http: { + python: { + method: 'folders.delete', example: - 'curl https://api.imagekit.io/v1/folder \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfolder = client.folders.delete(\n folder_path="/folder/to/delete/",\n)\nprint(folder)', }, java: { method: 'folders().delete', @@ -2098,25 +2089,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderDeleteParams\nimport com.imagekit.api.models.folders.FolderDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderDeleteParams = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build()\n val folder: FolderDeleteResponse = client.folders().delete(params)\n}', }, - php: { - method: 'folders->delete', - example: - "folders->delete(folderPath: '/folder/to/delete/');\n\nvar_dump($folder);", - }, - python: { - method: 'folders.delete', + go: { + method: 'client.Folders.Delete', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfolder = client.folders.delete(\n folder_path="/folder/to/delete/",\n)\nprint(folder)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfolder, err := client.Folders.Delete(context.TODO(), imagekit.FolderDeleteParams{\n\t\tFolderPath: "/folder/to/delete/",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", folder)\n}\n', }, ruby: { method: 'folders.delete', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfolder = image_kit.folders.delete(folder_path: "/folder/to/delete/")\n\nputs(folder)', }, - typescript: { - method: 'client.folders.delete', + cli: { + method: 'folders delete', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst folder = await client.folders.delete({ folderPath: '/folder/to/delete/' });\n\nconsole.log(folder);", + "imagekit folders delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-path /folder/to/delete/", + }, + php: { + method: 'folders->delete', + example: + "folders->delete(folderPath: '/folder/to/delete/');\n\nvar_dump($folder);", + }, + csharp: { + method: 'Folders.Delete', + example: + 'FolderDeleteParams parameters = new() { FolderPath = "/folder/to/delete/" };\n\nvar folder = await client.Folders.Delete(parameters);\n\nConsole.WriteLine(folder);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/folder \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -2134,24 +2134,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## copy\n\n`client.folders.copy(destinationPath: string, sourceFolderPath: string, includeVersions?: boolean): { jobId: string; }`\n\n**post** `/v1/bulkJobs/copyFolder`\n\nThis will copy one folder into another. The selected folder, its nested folders, files, and their versions (in `includeVersions` is set to true) are copied in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the destination folder where you want to copy the source folder into.\n\n\n- `sourceFolderPath: string`\n The full path to the source folder you want to copy.\n\n\n- `includeVersions?: boolean`\n Option to copy all versions of files that are nested inside the selected folder. By default, only the current version of each file will be copied. When set to true, all versions of each file will be copied. Default value - `false`.\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.copy({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' });\n\nconsole.log(response);\n```", perLanguage: { - cli: { - method: 'folders copy', - example: - "imagekit folders copy \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /path/of/destination/folder \\\n --source-folder-path /path/of/source/folder", - }, - csharp: { - method: 'Folders.Copy', - example: - 'FolderCopyParams parameters = new()\n{\n DestinationPath = "/path/of/destination/folder",\n SourceFolderPath = "/path/of/source/folder",\n};\n\nvar response = await client.Folders.Copy(parameters);\n\nConsole.WriteLine(response);', - }, - go: { - method: 'client.Folders.Copy', + typescript: { + method: 'client.folders.copy', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Folders.Copy(context.TODO(), imagekit.FolderCopyParams{\n\t\tDestinationPath: "/path/of/destination/folder",\n\t\tSourceFolderPath: "/path/of/source/folder",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.JobID)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.copy({\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n});\n\nconsole.log(response.jobId);", }, - http: { + python: { + method: 'folders.copy', example: - 'curl https://api.imagekit.io/v1/bulkJobs/copyFolder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/path/of/destination/folder",\n "sourceFolderPath": "/path/of/source/folder",\n "includeVersions": true\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.folders.copy(\n destination_path="/path/of/destination/folder",\n source_folder_path="/path/of/source/folder",\n)\nprint(response.job_id)', }, java: { method: 'folders().copy', @@ -2163,25 +2154,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderCopyParams\nimport com.imagekit.api.models.folders.FolderCopyResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderCopyParams = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build()\n val response: FolderCopyResponse = client.folders().copy(params)\n}', }, - php: { - method: 'folders->copy', - example: - "folders->copy(\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n includeVersions: true,\n);\n\nvar_dump($response);", - }, - python: { - method: 'folders.copy', + go: { + method: 'client.Folders.Copy', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.folders.copy(\n destination_path="/path/of/destination/folder",\n source_folder_path="/path/of/source/folder",\n)\nprint(response.job_id)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Folders.Copy(context.TODO(), imagekit.FolderCopyParams{\n\t\tDestinationPath: "/path/of/destination/folder",\n\t\tSourceFolderPath: "/path/of/source/folder",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.JobID)\n}\n', }, ruby: { method: 'folders.copy', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.folders.copy(\n destination_path: "/path/of/destination/folder",\n source_folder_path: "/path/of/source/folder"\n)\n\nputs(response)', }, - typescript: { - method: 'client.folders.copy', + cli: { + method: 'folders copy', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.copy({\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n});\n\nconsole.log(response.jobId);", + "imagekit folders copy \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /path/of/destination/folder \\\n --source-folder-path /path/of/source/folder", + }, + php: { + method: 'folders->copy', + example: + "folders->copy(\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n includeVersions: true,\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Folders.Copy', + example: + 'FolderCopyParams parameters = new()\n{\n DestinationPath = "/path/of/destination/folder",\n SourceFolderPath = "/path/of/source/folder",\n};\n\nvar response = await client.Folders.Copy(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/bulkJobs/copyFolder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/path/of/destination/folder",\n "sourceFolderPath": "/path/of/source/folder",\n "includeVersions": true\n }\'', }, }, }, @@ -2199,24 +2199,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## move\n\n`client.folders.move(destinationPath: string, sourceFolderPath: string): { jobId: string; }`\n\n**post** `/v1/bulkJobs/moveFolder`\n\nThis will move one folder into another. The selected folder, its nested folders, files, and their versions are moved in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the destination folder where you want to move the source folder into.\n\n\n- `sourceFolderPath: string`\n The full path to the source folder you want to move.\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.move({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' });\n\nconsole.log(response);\n```", perLanguage: { - cli: { - method: 'folders move', - example: - "imagekit folders move \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /path/of/destination/folder \\\n --source-folder-path /path/of/source/folder", - }, - csharp: { - method: 'Folders.Move', - example: - 'FolderMoveParams parameters = new()\n{\n DestinationPath = "/path/of/destination/folder",\n SourceFolderPath = "/path/of/source/folder",\n};\n\nvar response = await client.Folders.Move(parameters);\n\nConsole.WriteLine(response);', - }, - go: { - method: 'client.Folders.Move', + typescript: { + method: 'client.folders.move', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Folders.Move(context.TODO(), imagekit.FolderMoveParams{\n\t\tDestinationPath: "/path/of/destination/folder",\n\t\tSourceFolderPath: "/path/of/source/folder",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.JobID)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.move({\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n});\n\nconsole.log(response.jobId);", }, - http: { + python: { + method: 'folders.move', example: - 'curl https://api.imagekit.io/v1/bulkJobs/moveFolder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/path/of/destination/folder",\n "sourceFolderPath": "/path/of/source/folder"\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.folders.move(\n destination_path="/path/of/destination/folder",\n source_folder_path="/path/of/source/folder",\n)\nprint(response.job_id)', }, java: { method: 'folders().move', @@ -2228,25 +2219,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderMoveParams\nimport com.imagekit.api.models.folders.FolderMoveResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderMoveParams = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build()\n val response: FolderMoveResponse = client.folders().move(params)\n}', }, - php: { - method: 'folders->move', - example: - "folders->move(\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n);\n\nvar_dump($response);", - }, - python: { - method: 'folders.move', + go: { + method: 'client.Folders.Move', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.folders.move(\n destination_path="/path/of/destination/folder",\n source_folder_path="/path/of/source/folder",\n)\nprint(response.job_id)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Folders.Move(context.TODO(), imagekit.FolderMoveParams{\n\t\tDestinationPath: "/path/of/destination/folder",\n\t\tSourceFolderPath: "/path/of/source/folder",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.JobID)\n}\n', }, ruby: { method: 'folders.move', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.folders.move(\n destination_path: "/path/of/destination/folder",\n source_folder_path: "/path/of/source/folder"\n)\n\nputs(response)', }, - typescript: { - method: 'client.folders.move', + cli: { + method: 'folders move', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.move({\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n});\n\nconsole.log(response.jobId);", + "imagekit folders move \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /path/of/destination/folder \\\n --source-folder-path /path/of/source/folder", + }, + php: { + method: 'folders->move', + example: + "folders->move(\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Folders.Move', + example: + 'FolderMoveParams parameters = new()\n{\n DestinationPath = "/path/of/destination/folder",\n SourceFolderPath = "/path/of/source/folder",\n};\n\nvar response = await client.Folders.Move(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/bulkJobs/moveFolder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/path/of/destination/folder",\n "sourceFolderPath": "/path/of/source/folder"\n }\'', }, }, }, @@ -2264,24 +2264,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## rename\n\n`client.folders.rename(folderPath: string, newFolderName: string, purgeCache?: boolean): { jobId: string; }`\n\n**post** `/v1/bulkJobs/renameFolder`\n\nThis API allows you to rename an existing folder. The folder and all its nested assets and sub-folders will remain unchanged, but their paths will be updated to reflect the new folder name.\n\n\n### Parameters\n\n- `folderPath: string`\n The full path to the folder you want to rename.\n\n\n- `newFolderName: string`\n The new name for the folder.\n\nAll characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) and `-` will be replaced by an underscore i.e. `_`.\n\n\n- `purgeCache?: boolean`\n Option to purge cache for the old nested files and their versions' URLs.\n\nWhen set to true, it will internally issue a purge cache request on CDN to remove the cached content of the old nested files and their versions. There will only be one purge request for all the nested files, which will be counted against your monthly purge quota.\n\nNote: A purge cache request will be issued against `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This will remove all nested files, their versions' URLs, and any transformations made using query parameters on these files or their versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation.\n\nDefault value - `false`\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.rename({ folderPath: '/path/of/folder', newFolderName: 'new-folder-name' });\n\nconsole.log(response);\n```", perLanguage: { - cli: { - method: 'folders rename', - example: - "imagekit folders rename \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-path /path/of/folder \\\n --new-folder-name new-folder-name", - }, - csharp: { - method: 'Folders.Rename', - example: - 'FolderRenameParams parameters = new()\n{\n FolderPath = "/path/of/folder",\n NewFolderName = "new-folder-name",\n};\n\nvar response = await client.Folders.Rename(parameters);\n\nConsole.WriteLine(response);', - }, - go: { - method: 'client.Folders.Rename', + typescript: { + method: 'client.folders.rename', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Folders.Rename(context.TODO(), imagekit.FolderRenameParams{\n\t\tFolderPath: "/path/of/folder",\n\t\tNewFolderName: "new-folder-name",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.JobID)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.rename({\n folderPath: '/path/of/folder',\n newFolderName: 'new-folder-name',\n});\n\nconsole.log(response.jobId);", }, - http: { + python: { + method: 'folders.rename', example: - 'curl https://api.imagekit.io/v1/bulkJobs/renameFolder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "folderPath": "/path/of/folder",\n "newFolderName": "new-folder-name",\n "purgeCache": true\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.folders.rename(\n folder_path="/path/of/folder",\n new_folder_name="new-folder-name",\n)\nprint(response.job_id)', }, java: { method: 'folders().rename', @@ -2293,25 +2284,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderRenameParams\nimport com.imagekit.api.models.folders.FolderRenameResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderRenameParams = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build()\n val response: FolderRenameResponse = client.folders().rename(params)\n}', }, - php: { - method: 'folders->rename', + go: { + method: 'client.Folders.Rename', example: - "folders->rename(\n folderPath: '/path/of/folder',\n newFolderName: 'new-folder-name',\n purgeCache: true,\n);\n\nvar_dump($response);", + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Folders.Rename(context.TODO(), imagekit.FolderRenameParams{\n\t\tFolderPath: "/path/of/folder",\n\t\tNewFolderName: "new-folder-name",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.JobID)\n}\n', }, - python: { + ruby: { method: 'folders.rename', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.folders.rename(\n folder_path="/path/of/folder",\n new_folder_name="new-folder-name",\n)\nprint(response.job_id)', + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.folders.rename(folder_path: "/path/of/folder", new_folder_name: "new-folder-name")\n\nputs(response)', + }, + cli: { + method: 'folders rename', + example: + "imagekit folders rename \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-path /path/of/folder \\\n --new-folder-name new-folder-name", + }, + php: { + method: 'folders->rename', + example: + "folders->rename(\n folderPath: '/path/of/folder',\n newFolderName: 'new-folder-name',\n purgeCache: true,\n);\n\nvar_dump($response);", }, - ruby: { - method: 'folders.rename', + csharp: { + method: 'Folders.Rename', example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.folders.rename(folder_path: "/path/of/folder", new_folder_name: "new-folder-name")\n\nputs(response)', + 'FolderRenameParams parameters = new()\n{\n FolderPath = "/path/of/folder",\n NewFolderName = "new-folder-name",\n};\n\nvar response = await client.Folders.Rename(parameters);\n\nConsole.WriteLine(response);', }, - typescript: { - method: 'client.folders.rename', + http: { example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.rename({\n folderPath: '/path/of/folder',\n newFolderName: 'new-folder-name',\n});\n\nconsole.log(response.jobId);", + 'curl https://api.imagekit.io/v1/bulkJobs/renameFolder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "folderPath": "/path/of/folder",\n "newFolderName": "new-folder-name",\n "purgeCache": true\n }\'', }, }, }, @@ -2329,24 +2329,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## get\n\n`client.folders.job.get(jobId: string): { jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }`\n\n**get** `/v1/bulkJobs/{jobId}`\n\nThis API returns the status of a bulk job like copy and move folder operations.\n\n\n### Parameters\n\n- `jobId: string`\n\n### Returns\n\n- `{ jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }`\n\n - `jobId?: string`\n - `purgeRequestId?: string`\n - `status?: 'Pending' | 'Completed'`\n - `type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst job = await client.folders.job.get('jobId');\n\nconsole.log(job);\n```", perLanguage: { - cli: { - method: 'job get', - example: - "imagekit folders:job get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --job-id jobId", - }, - csharp: { - method: 'Folders.Job.Get', - example: - 'JobGetParams parameters = new() { JobID = "jobId" };\n\nvar job = await client.Folders.Job.Get(parameters);\n\nConsole.WriteLine(job);', - }, - go: { - method: 'client.Folders.Job.Get', + typescript: { + method: 'client.folders.job.get', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tjob, err := client.Folders.Job.Get(context.TODO(), "jobId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", job.JobID)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst job = await client.folders.job.get('jobId');\n\nconsole.log(job.jobId);", }, - http: { + python: { + method: 'folders.job.get', example: - 'curl https://api.imagekit.io/v1/bulkJobs/$JOB_ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\njob = client.folders.job.get(\n "jobId",\n)\nprint(job.job_id)', }, java: { method: 'folders().job().get', @@ -2358,25 +2349,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.job.JobGetParams\nimport com.imagekit.api.models.folders.job.JobGetResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val job: JobGetResponse = client.folders().job().get("jobId")\n}', }, - php: { - method: 'folders->job->get', - example: - "folders->job->get('jobId');\n\nvar_dump($job);", - }, - python: { - method: 'folders.job.get', + go: { + method: 'client.Folders.Job.Get', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\njob = client.folders.job.get(\n "jobId",\n)\nprint(job.job_id)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tjob, err := client.Folders.Job.Get(context.TODO(), "jobId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", job.JobID)\n}\n', }, ruby: { method: 'folders.job.get', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\njob = image_kit.folders.job.get("jobId")\n\nputs(job)', }, - typescript: { - method: 'client.folders.job.get', + cli: { + method: 'job get', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst job = await client.folders.job.get('jobId');\n\nconsole.log(job.jobId);", + "imagekit folders:job get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --job-id jobId", + }, + php: { + method: 'folders->job->get', + example: + "folders->job->get('jobId');\n\nvar_dump($job);", + }, + csharp: { + method: 'Folders.Job.Get', + example: + 'JobGetParams parameters = new() { JobID = "jobId" };\n\nvar job = await client.Folders.Job.Get(parameters);\n\nConsole.WriteLine(job);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/bulkJobs/$JOB_ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -2395,24 +2395,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## get\n\n`client.accounts.usage.get(endDate: string, startDate: string): { bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }`\n\n**get** `/v1/accounts/usage`\n\nGet the account usage information between two dates. Note that the API response includes data from the start date while excluding data from the end date. In other words, the data covers the period starting from the specified start date up to, but not including, the end date.\n\n\n### Parameters\n\n- `endDate: string`\n Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. The difference between `startDate` and `endDate` should be less than 90 days.\n\n- `startDate: string`\n Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. The difference between `startDate` and `endDate` should be less than 90 days.\n\n### Returns\n\n- `{ bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }`\n\n - `bandwidthBytes?: number`\n - `extensionUnitsCount?: number`\n - `mediaLibraryStorageBytes?: number`\n - `originalCacheStorageBytes?: number`\n - `videoProcessingUnitsCount?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst usage = await client.accounts.usage.get({ endDate: '2019-12-27', startDate: '2019-12-27' });\n\nconsole.log(usage);\n```", perLanguage: { - cli: { - method: 'usage get', - example: - "imagekit accounts:usage get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --end-date \"'2019-12-27'\" \\\n --start-date \"'2019-12-27'\"", - }, - csharp: { - method: 'Accounts.Usage.Get', - example: - 'UsageGetParams parameters = new()\n{\n EndDate = "2019-12-27",\n StartDate = "2019-12-27",\n};\n\nvar usage = await client.Accounts.Usage.Get(parameters);\n\nConsole.WriteLine(usage);', - }, - go: { - method: 'client.Accounts.Usage.Get', + typescript: { + method: 'client.accounts.usage.get', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tusage, err := client.Accounts.Usage.Get(context.TODO(), imagekit.AccountUsageGetParams{\n\t\tEndDate: time.Now(),\n\t\tStartDate: time.Now(),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", usage.BandwidthBytes)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst usage = await client.accounts.usage.get({ endDate: '2019-12-27', startDate: '2019-12-27' });\n\nconsole.log(usage.bandwidthBytes);", }, - http: { + python: { + method: 'accounts.usage.get', example: - 'curl https://api.imagekit.io/v1/accounts/usage \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom datetime import date\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nusage = client.accounts.usage.get(\n end_date=date.fromisoformat("2019-12-27"),\n start_date=date.fromisoformat("2019-12-27"),\n)\nprint(usage.bandwidth_bytes)', }, java: { method: 'accounts().usage().get', @@ -2424,25 +2415,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.usage.UsageGetParams\nimport com.imagekit.api.models.accounts.usage.UsageGetResponse\nimport java.time.LocalDate\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UsageGetParams = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build()\n val usage: UsageGetResponse = client.accounts().usage().get(params)\n}', }, - php: { - method: 'accounts->usage->get', - example: - "accounts->usage->get(\n endDate: '2019-12-27', startDate: '2019-12-27'\n);\n\nvar_dump($usage);", - }, - python: { - method: 'accounts.usage.get', + go: { + method: 'client.Accounts.Usage.Get', example: - 'import os\nfrom datetime import date\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nusage = client.accounts.usage.get(\n end_date=date.fromisoformat("2019-12-27"),\n start_date=date.fromisoformat("2019-12-27"),\n)\nprint(usage.bandwidth_bytes)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tusage, err := client.Accounts.Usage.Get(context.TODO(), imagekit.AccountUsageGetParams{\n\t\tEndDate: time.Now(),\n\t\tStartDate: time.Now(),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", usage.BandwidthBytes)\n}\n', }, ruby: { method: 'accounts.usage.get', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nusage = image_kit.accounts.usage.get(end_date: "2019-12-27", start_date: "2019-12-27")\n\nputs(usage)', }, - typescript: { - method: 'client.accounts.usage.get', + cli: { + method: 'usage get', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst usage = await client.accounts.usage.get({ endDate: '2019-12-27', startDate: '2019-12-27' });\n\nconsole.log(usage.bandwidthBytes);", + "imagekit accounts:usage get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --end-date \"'2019-12-27'\" \\\n --start-date \"'2019-12-27'\"", + }, + php: { + method: 'accounts->usage->get', + example: + "accounts->usage->get(\n endDate: '2019-12-27', startDate: '2019-12-27'\n);\n\nvar_dump($usage);", + }, + csharp: { + method: 'Accounts.Usage.Get', + example: + 'UsageGetParams parameters = new()\n{\n EndDate = "2019-12-27",\n StartDate = "2019-12-27",\n};\n\nvar usage = await client.Accounts.Usage.Get(parameters);\n\nConsole.WriteLine(usage);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/usage \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -2459,24 +2459,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## list\n\n`client.accounts.origins.list(): object | object | object | object | object | object | object | object[]`\n\n**get** `/v1/accounts/origins`\n\n**Note:** This API is currently in beta. \nReturns an array of all configured origins for the current account.\n\n\n### Returns\n\n- `{ id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst originResponses = await client.accounts.origins.list();\n\nconsole.log(originResponses);\n```", perLanguage: { - cli: { - method: 'origins list', - example: - "imagekit accounts:origins list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - csharp: { - method: 'Accounts.Origins.List', - example: - 'OriginListParams parameters = new();\n\nvar originResponses = await client.Accounts.Origins.List(parameters);\n\nConsole.WriteLine(originResponses);', - }, - go: { - method: 'client.Accounts.Origins.List', + typescript: { + method: 'client.accounts.origins.list', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponses, err := client.Accounts.Origins.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponses)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponses = await client.accounts.origins.list();\n\nconsole.log(originResponses);", }, - http: { + python: { + method: 'accounts.origins.list', example: - 'curl https://api.imagekit.io/v1/accounts/origins \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_responses = client.accounts.origins.list()\nprint(origin_responses)', }, java: { method: 'accounts().origins().list', @@ -2488,25 +2479,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginListParams\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val originResponses: List = client.accounts().origins().list()\n}', }, - php: { - method: 'accounts->origins->list', - example: - "accounts->origins->list();\n\nvar_dump($originResponses);", - }, - python: { - method: 'accounts.origins.list', + go: { + method: 'client.Accounts.Origins.List', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_responses = client.accounts.origins.list()\nprint(origin_responses)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponses, err := client.Accounts.Origins.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponses)\n}\n', }, ruby: { method: 'accounts.origins.list', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\norigin_responses = image_kit.accounts.origins.list\n\nputs(origin_responses)', }, - typescript: { - method: 'client.accounts.origins.list', + cli: { + method: 'origins list', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponses = await client.accounts.origins.list();\n\nconsole.log(originResponses);", + "imagekit accounts:origins list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'accounts->origins->list', + example: + "accounts->origins->list();\n\nvar_dump($originResponses);", + }, + csharp: { + method: 'Accounts.Origins.List', + example: + 'OriginListParams parameters = new();\n\nvar originResponses = await client.Accounts.Origins.List(parameters);\n\nConsole.WriteLine(originResponses);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/origins \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -2524,24 +2524,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ ], response: 'object | object | object | object | object | object | object | object', perLanguage: { - cli: { - method: 'origins create', - example: - "imagekit accounts:origins create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --access-key AKIAIOSFODNN7EXAMPLE \\\n --bucket product-images \\\n --name 'US S3 Storage' \\\n --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \\\n --type S3 \\\n --endpoint https://s3.eu-central-1.wasabisys.com \\\n --base-url https://images.example.com/assets \\\n --client-email service-account@project.iam.gserviceaccount.com \\\n --private-key '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...' \\\n --account-name account123 \\\n --container images \\\n --sas-token '?sv=2023-01-03&sr=c&sig=abc123' \\\n --client-id akeneo-client-id \\\n --client-secret akeneo-client-secret \\\n --password strongpassword123 \\\n --username integration-user", - }, - csharp: { - method: 'Accounts.Origins.Create', - example: - 'OriginCreateParams parameters = new()\n{\n OriginRequest = new S3()\n {\n AccessKey = "AKIATEST123",\n Bucket = "test-bucket",\n Name = "My S3 Origin",\n SecretKey = "secrettest123",\n BaseUrlForCanonicalHeader = "https://cdn.example.com",\n IncludeCanonicalHeader = false,\n Prefix = "images",\n },\n};\n\nvar originResponse = await client.Accounts.Origins.Create(parameters);\n\nConsole.WriteLine(originResponse);', - }, - go: { - method: 'client.Accounts.Origins.New', + typescript: { + method: 'client.accounts.origins.create', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.New(context.TODO(), imagekit.AccountOriginNewParams{\n\t\tOriginRequest: imagekit.OriginRequestUnionParam{\n\t\t\tOfS3: &imagekit.OriginRequestS3Param{\n\t\t\t\tAccessKey: "AKIATEST123",\n\t\t\t\tBucket: "test-bucket",\n\t\t\t\tName: "My S3 Origin",\n\t\t\t\tSecretKey: "secrettest123",\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponse)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.create({\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'product-images',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'S3',\n});\n\nconsole.log(originResponse);", }, - http: { + python: { + method: 'accounts.origins.create', example: - 'curl https://api.imagekit.io/v1/accounts/origins \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "accessKey": "AKIAIOSFODNN7EXAMPLE",\n "bucket": "product-images",\n "name": "US S3 Storage",\n "secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n "type": "S3",\n "baseUrlForCanonicalHeader": "https://cdn.example.com",\n "prefix": "raw-assets"\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.create(\n access_key="AKIAIOSFODNN7EXAMPLE",\n bucket="product-images",\n name="US S3 Storage",\n secret_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n type="S3",\n)\nprint(origin_response)', }, java: { method: 'accounts().origins().create', @@ -2553,25 +2544,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginCreateParams\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginRequest.S3 = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build()\n val originResponse: OriginResponse = client.accounts().origins().create(params)\n}', }, - php: { - method: 'accounts->origins->create', - example: - "accounts->origins->create(\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'gcs-media',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'AKENEO_PIM',\n baseURLForCanonicalHeader: 'https://cdn.example.com',\n includeCanonicalHeader: false,\n prefix: 'uploads',\n endpoint: 'https://s3.eu-central-1.wasabisys.com',\n s3ForcePathStyle: true,\n baseURL: 'https://akeneo.company.com',\n forwardHostHeaderToOrigin: false,\n clientEmail: 'service-account@project.iam.gserviceaccount.com',\n privateKey: '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...',\n accountName: 'account123',\n container: 'images',\n sasToken: '?sv=2023-01-03&sr=c&sig=abc123',\n clientID: 'akeneo-client-id',\n clientSecret: 'akeneo-client-secret',\n password: 'strongpassword123',\n username: 'integration-user',\n);\n\nvar_dump($originResponse);", - }, - python: { - method: 'accounts.origins.create', + go: { + method: 'client.Accounts.Origins.New', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.create(\n access_key="AKIAIOSFODNN7EXAMPLE",\n bucket="product-images",\n name="US S3 Storage",\n secret_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n type="S3",\n)\nprint(origin_response)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.New(context.TODO(), imagekit.AccountOriginNewParams{\n\t\tOriginRequest: imagekit.OriginRequestUnionParam{\n\t\t\tOfS3: &imagekit.OriginRequestS3Param{\n\t\t\t\tAccessKey: "AKIATEST123",\n\t\t\t\tBucket: "test-bucket",\n\t\t\t\tName: "My S3 Origin",\n\t\t\t\tSecretKey: "secrettest123",\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponse)\n}\n', }, ruby: { method: 'accounts.origins.create', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\norigin_response = image_kit.accounts.origins.create(\n origin_request: {accessKey: "AKIATEST123", bucket: "test-bucket", name: "My S3 Origin", secretKey: "secrettest123", type: :S3}\n)\n\nputs(origin_response)', }, - typescript: { - method: 'client.accounts.origins.create', + cli: { + method: 'origins create', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.create({\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'product-images',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'S3',\n});\n\nconsole.log(originResponse);", + "imagekit accounts:origins create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --access-key AKIAIOSFODNN7EXAMPLE \\\n --bucket product-images \\\n --name 'US S3 Storage' \\\n --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \\\n --type S3 \\\n --endpoint https://s3.eu-central-1.wasabisys.com \\\n --base-url https://images.example.com/assets \\\n --client-email service-account@project.iam.gserviceaccount.com \\\n --private-key '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...' \\\n --account-name account123 \\\n --container images \\\n --sas-token '?sv=2023-01-03&sr=c&sig=abc123' \\\n --client-id akeneo-client-id \\\n --client-secret akeneo-client-secret \\\n --password strongpassword123 \\\n --username integration-user", + }, + php: { + method: 'accounts->origins->create', + example: + "accounts->origins->create(\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'gcs-media',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'AKENEO_PIM',\n baseURLForCanonicalHeader: 'https://cdn.example.com',\n includeCanonicalHeader: false,\n prefix: 'uploads',\n endpoint: 'https://s3.eu-central-1.wasabisys.com',\n s3ForcePathStyle: true,\n baseURL: 'https://akeneo.company.com',\n forwardHostHeaderToOrigin: false,\n clientEmail: 'service-account@project.iam.gserviceaccount.com',\n privateKey: '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...',\n accountName: 'account123',\n container: 'images',\n sasToken: '?sv=2023-01-03&sr=c&sig=abc123',\n clientID: 'akeneo-client-id',\n clientSecret: 'akeneo-client-secret',\n password: 'strongpassword123',\n username: 'integration-user',\n);\n\nvar_dump($originResponse);", + }, + csharp: { + method: 'Accounts.Origins.Create', + example: + 'OriginCreateParams parameters = new()\n{\n OriginRequest = new S3()\n {\n AccessKey = "AKIATEST123",\n Bucket = "test-bucket",\n Name = "My S3 Origin",\n SecretKey = "secrettest123",\n BaseUrlForCanonicalHeader = "https://cdn.example.com",\n IncludeCanonicalHeader = false,\n Prefix = "images",\n },\n};\n\nvar originResponse = await client.Accounts.Origins.Create(parameters);\n\nConsole.WriteLine(originResponse);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/origins \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "accessKey": "AKIAIOSFODNN7EXAMPLE",\n "bucket": "product-images",\n "name": "US S3 Storage",\n "secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n "type": "S3",\n "baseUrlForCanonicalHeader": "https://cdn.example.com",\n "prefix": "raw-assets"\n }\'', }, }, }, @@ -2588,24 +2588,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## get\n\n`client.accounts.origins.get(id: string): { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }`\n\n**get** `/v1/accounts/origins/{id}`\n\n**Note:** This API is currently in beta. \nRetrieves the origin identified by `id`.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the origin. This is generated by ImageKit when you create a new origin.\n\n### Returns\n\n- `{ id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }`\n Origin object as returned by the API (sensitive fields removed).\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst originResponse = await client.accounts.origins.get('id');\n\nconsole.log(originResponse);\n```", perLanguage: { - cli: { - method: 'origins get', - example: - "imagekit accounts:origins get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - csharp: { - method: 'Accounts.Origins.Get', - example: - 'OriginGetParams parameters = new() { ID = "id" };\n\nvar originResponse = await client.Accounts.Origins.Get(parameters);\n\nConsole.WriteLine(originResponse);', - }, - go: { - method: 'client.Accounts.Origins.Get', + typescript: { + method: 'client.accounts.origins.get', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.Get(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponse)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.get('id');\n\nconsole.log(originResponse);", }, - http: { + python: { + method: 'accounts.origins.get', example: - 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.get(\n "id",\n)\nprint(origin_response)', }, java: { method: 'accounts().origins().get', @@ -2617,25 +2608,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginGetParams\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val originResponse: OriginResponse = client.accounts().origins().get("id")\n}', }, + go: { + method: 'client.Accounts.Origins.Get', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.Get(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponse)\n}\n', + }, + ruby: { + method: 'accounts.origins.get', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\norigin_response = image_kit.accounts.origins.get("id")\n\nputs(origin_response)', + }, + cli: { + method: 'origins get', + example: + "imagekit accounts:origins get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, php: { method: 'accounts->origins->get', example: "accounts->origins->get('id');\n\nvar_dump($originResponse);", }, - python: { - method: 'accounts.origins.get', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.get(\n "id",\n)\nprint(origin_response)', - }, - ruby: { - method: 'accounts.origins.get', + csharp: { + method: 'Accounts.Origins.Get', example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\norigin_response = image_kit.accounts.origins.get("id")\n\nputs(origin_response)', + 'OriginGetParams parameters = new() { ID = "id" };\n\nvar originResponse = await client.Accounts.Origins.Get(parameters);\n\nConsole.WriteLine(originResponse);', }, - typescript: { - method: 'client.accounts.origins.get', + http: { example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.get('id');\n\nconsole.log(originResponse);", + 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -2654,24 +2654,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ ], response: 'object | object | object | object | object | object | object | object', perLanguage: { - cli: { - method: 'origins update', - example: - "imagekit accounts:origins update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id \\\n --access-key AKIAIOSFODNN7EXAMPLE \\\n --bucket product-images \\\n --name 'US S3 Storage' \\\n --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \\\n --type S3 \\\n --endpoint https://s3.eu-central-1.wasabisys.com \\\n --base-url https://images.example.com/assets \\\n --client-email service-account@project.iam.gserviceaccount.com \\\n --private-key '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...' \\\n --account-name account123 \\\n --container images \\\n --sas-token '?sv=2023-01-03&sr=c&sig=abc123' \\\n --client-id akeneo-client-id \\\n --client-secret akeneo-client-secret \\\n --password strongpassword123 \\\n --username integration-user", - }, - csharp: { - method: 'Accounts.Origins.Update', - example: - 'OriginUpdateParams parameters = new()\n{\n ID = "id",\n OriginRequest = new S3()\n {\n AccessKey = "AKIATEST123",\n Bucket = "test-bucket",\n Name = "My S3 Origin",\n SecretKey = "secrettest123",\n BaseUrlForCanonicalHeader = "https://cdn.example.com",\n IncludeCanonicalHeader = false,\n Prefix = "images",\n },\n};\n\nvar originResponse = await client.Accounts.Origins.Update(parameters);\n\nConsole.WriteLine(originResponse);', - }, - go: { - method: 'client.Accounts.Origins.Update', + typescript: { + method: 'client.accounts.origins.update', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.AccountOriginUpdateParams{\n\t\t\tOriginRequest: imagekit.OriginRequestUnionParam{\n\t\t\t\tOfS3: &imagekit.OriginRequestS3Param{\n\t\t\t\t\tAccessKey: "AKIATEST123",\n\t\t\t\t\tBucket: "test-bucket",\n\t\t\t\t\tName: "My S3 Origin",\n\t\t\t\t\tSecretKey: "secrettest123",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponse)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.update('id', {\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'product-images',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'S3',\n});\n\nconsole.log(originResponse);", }, - http: { + python: { + method: 'accounts.origins.update', example: - 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "accessKey": "AKIAIOSFODNN7EXAMPLE",\n "bucket": "product-images",\n "name": "US S3 Storage",\n "secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n "type": "S3",\n "baseUrlForCanonicalHeader": "https://cdn.example.com",\n "prefix": "raw-assets"\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.update(\n id="id",\n access_key="AKIAIOSFODNN7EXAMPLE",\n bucket="product-images",\n name="US S3 Storage",\n secret_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n type="S3",\n)\nprint(origin_response)', }, java: { method: 'accounts().origins().update', @@ -2683,25 +2674,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\nimport com.imagekit.api.models.accounts.origins.OriginUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginUpdateParams = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build()\n val originResponse: OriginResponse = client.accounts().origins().update(params)\n}', }, - php: { - method: 'accounts->origins->update', - example: - "accounts->origins->update(\n 'id',\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'gcs-media',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'AKENEO_PIM',\n baseURLForCanonicalHeader: 'https://cdn.example.com',\n includeCanonicalHeader: false,\n prefix: 'uploads',\n endpoint: 'https://s3.eu-central-1.wasabisys.com',\n s3ForcePathStyle: true,\n baseURL: 'https://akeneo.company.com',\n forwardHostHeaderToOrigin: false,\n clientEmail: 'service-account@project.iam.gserviceaccount.com',\n privateKey: '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...',\n accountName: 'account123',\n container: 'images',\n sasToken: '?sv=2023-01-03&sr=c&sig=abc123',\n clientID: 'akeneo-client-id',\n clientSecret: 'akeneo-client-secret',\n password: 'strongpassword123',\n username: 'integration-user',\n);\n\nvar_dump($originResponse);", - }, - python: { - method: 'accounts.origins.update', + go: { + method: 'client.Accounts.Origins.Update', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.update(\n id="id",\n access_key="AKIAIOSFODNN7EXAMPLE",\n bucket="product-images",\n name="US S3 Storage",\n secret_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n type="S3",\n)\nprint(origin_response)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.AccountOriginUpdateParams{\n\t\t\tOriginRequest: imagekit.OriginRequestUnionParam{\n\t\t\t\tOfS3: &imagekit.OriginRequestS3Param{\n\t\t\t\t\tAccessKey: "AKIATEST123",\n\t\t\t\t\tBucket: "test-bucket",\n\t\t\t\t\tName: "My S3 Origin",\n\t\t\t\t\tSecretKey: "secrettest123",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponse)\n}\n', }, ruby: { method: 'accounts.origins.update', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\norigin_response = image_kit.accounts.origins.update(\n "id",\n origin_request: {accessKey: "AKIATEST123", bucket: "test-bucket", name: "My S3 Origin", secretKey: "secrettest123", type: :S3}\n)\n\nputs(origin_response)', }, - typescript: { - method: 'client.accounts.origins.update', + cli: { + method: 'origins update', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.update('id', {\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'product-images',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'S3',\n});\n\nconsole.log(originResponse);", + "imagekit accounts:origins update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id \\\n --access-key AKIAIOSFODNN7EXAMPLE \\\n --bucket product-images \\\n --name 'US S3 Storage' \\\n --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \\\n --type S3 \\\n --endpoint https://s3.eu-central-1.wasabisys.com \\\n --base-url https://images.example.com/assets \\\n --client-email service-account@project.iam.gserviceaccount.com \\\n --private-key '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...' \\\n --account-name account123 \\\n --container images \\\n --sas-token '?sv=2023-01-03&sr=c&sig=abc123' \\\n --client-id akeneo-client-id \\\n --client-secret akeneo-client-secret \\\n --password strongpassword123 \\\n --username integration-user", + }, + php: { + method: 'accounts->origins->update', + example: + "accounts->origins->update(\n 'id',\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'gcs-media',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'AKENEO_PIM',\n baseURLForCanonicalHeader: 'https://cdn.example.com',\n includeCanonicalHeader: false,\n prefix: 'uploads',\n endpoint: 'https://s3.eu-central-1.wasabisys.com',\n s3ForcePathStyle: true,\n baseURL: 'https://akeneo.company.com',\n forwardHostHeaderToOrigin: false,\n clientEmail: 'service-account@project.iam.gserviceaccount.com',\n privateKey: '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...',\n accountName: 'account123',\n container: 'images',\n sasToken: '?sv=2023-01-03&sr=c&sig=abc123',\n clientID: 'akeneo-client-id',\n clientSecret: 'akeneo-client-secret',\n password: 'strongpassword123',\n username: 'integration-user',\n);\n\nvar_dump($originResponse);", + }, + csharp: { + method: 'Accounts.Origins.Update', + example: + 'OriginUpdateParams parameters = new()\n{\n ID = "id",\n OriginRequest = new S3()\n {\n AccessKey = "AKIATEST123",\n Bucket = "test-bucket",\n Name = "My S3 Origin",\n SecretKey = "secrettest123",\n BaseUrlForCanonicalHeader = "https://cdn.example.com",\n IncludeCanonicalHeader = false,\n Prefix = "images",\n },\n};\n\nvar originResponse = await client.Accounts.Origins.Update(parameters);\n\nConsole.WriteLine(originResponse);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "accessKey": "AKIAIOSFODNN7EXAMPLE",\n "bucket": "product-images",\n "name": "US S3 Storage",\n "secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n "type": "S3",\n "baseUrlForCanonicalHeader": "https://cdn.example.com",\n "prefix": "raw-assets"\n }\'', }, }, }, @@ -2718,24 +2718,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## delete\n\n`client.accounts.origins.delete(id: string): void`\n\n**delete** `/v1/accounts/origins/{id}`\n\n**Note:** This API is currently in beta. \nPermanently removes the origin identified by `id`. If the origin is in use by any URL‑endpoints, the API will return an error.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the origin. This is generated by ImageKit when you create a new origin.\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.accounts.origins.delete('id')\n```", perLanguage: { - cli: { - method: 'origins delete', - example: - "imagekit accounts:origins delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - csharp: { - method: 'Accounts.Origins.Delete', - example: - 'OriginDeleteParams parameters = new() { ID = "id" };\n\nawait client.Accounts.Origins.Delete(parameters);', - }, - go: { - method: 'client.Accounts.Origins.Delete', + typescript: { + method: 'client.accounts.origins.delete', example: - 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Accounts.Origins.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.accounts.origins.delete('id');", }, - http: { + python: { + method: 'accounts.origins.delete', example: - 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.accounts.origins.delete(\n "id",\n)', }, java: { method: 'accounts().origins().delete', @@ -2747,25 +2738,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.accounts().origins().delete("id")\n}', }, - php: { - method: 'accounts->origins->delete', - example: - "accounts->origins->delete('id');\n\nvar_dump($result);", - }, - python: { - method: 'accounts.origins.delete', + go: { + method: 'client.Accounts.Origins.Delete', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.accounts.origins.delete(\n "id",\n)', + 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Accounts.Origins.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'accounts.origins.delete', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.accounts.origins.delete("id")\n\nputs(result)', }, - typescript: { - method: 'client.accounts.origins.delete', + cli: { + method: 'origins delete', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.accounts.origins.delete('id');", + "imagekit accounts:origins delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'accounts->origins->delete', + example: + "accounts->origins->delete('id');\n\nvar_dump($result);", + }, + csharp: { + method: 'Accounts.Origins.Delete', + example: + 'OriginDeleteParams parameters = new() { ID = "id" };\n\nawait client.Accounts.Origins.Delete(parameters);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -2783,24 +2783,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## list\n\n`client.accounts.urlEndpoints.list(): object[]`\n\n**get** `/v1/accounts/url-endpoints`\n\n**Note:** This API is currently in beta. \nReturns an array of all URL‑endpoints configured including the default URL-endpoint generated by ImageKit during account creation.\n\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponses = await client.accounts.urlEndpoints.list();\n\nconsole.log(urlEndpointResponses);\n```", perLanguage: { - cli: { - method: 'urlEndpoints list', - example: - "imagekit accounts:url-endpoints list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - csharp: { - method: 'Accounts.UrlEndpoints.List', - example: - 'UrlEndpointListParams parameters = new();\n\nvar urlEndpointResponses = await client.Accounts.UrlEndpoints.List(parameters);\n\nConsole.WriteLine(urlEndpointResponses);', - }, - go: { - method: 'client.Accounts.URLEndpoints.List', + typescript: { + method: 'client.accounts.urlEndpoints.list', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponses, err := client.Accounts.URLEndpoints.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponses)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponses = await client.accounts.urlEndpoints.list();\n\nconsole.log(urlEndpointResponses);", }, - http: { + python: { + method: 'accounts.url_endpoints.list', example: - 'curl https://api.imagekit.io/v1/accounts/url-endpoints \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_responses = client.accounts.url_endpoints.list()\nprint(url_endpoint_responses)', }, java: { method: 'accounts().urlEndpoints().list', @@ -2812,25 +2803,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val urlEndpointResponses: List = client.accounts().urlEndpoints().list()\n}', }, - php: { - method: 'accounts->urlEndpoints->list', - example: - "accounts->urlEndpoints->list();\n\nvar_dump($urlEndpointResponses);", - }, - python: { - method: 'accounts.url_endpoints.list', + go: { + method: 'client.Accounts.URLEndpoints.List', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_responses = client.accounts.url_endpoints.list()\nprint(url_endpoint_responses)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponses, err := client.Accounts.URLEndpoints.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponses)\n}\n', }, ruby: { method: 'accounts.url_endpoints.list', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nurl_endpoint_responses = image_kit.accounts.url_endpoints.list\n\nputs(url_endpoint_responses)', }, - typescript: { - method: 'client.accounts.urlEndpoints.list', + cli: { + method: 'urlEndpoints list', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponses = await client.accounts.urlEndpoints.list();\n\nconsole.log(urlEndpointResponses);", + "imagekit accounts:url-endpoints list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'accounts->urlEndpoints->list', + example: + "accounts->urlEndpoints->list();\n\nvar_dump($urlEndpointResponses);", + }, + csharp: { + method: 'Accounts.UrlEndpoints.List', + example: + 'UrlEndpointListParams parameters = new();\n\nvar urlEndpointResponses = await client.Accounts.UrlEndpoints.List(parameters);\n\nConsole.WriteLine(urlEndpointResponses);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/url-endpoints \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -2854,24 +2854,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## create\n\n`client.accounts.urlEndpoints.create(description: string, origins?: string[], urlPrefix?: string, urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**post** `/v1/accounts/url-endpoints`\n\n**Note:** This API is currently in beta. \nCreates a new URL‑endpoint and returns the resulting object.\n\n\n### Parameters\n\n- `description: string`\n Description of the URL endpoint.\n\n- `origins?: string[]`\n Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint.\n\n- `urlPrefix?: string`\n Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint).\n\n- `urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n Configuration for third-party URL rewriting.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.create({ description: 'My custom URL endpoint' });\n\nconsole.log(urlEndpointResponse);\n```", perLanguage: { - cli: { - method: 'urlEndpoints create', - example: - "imagekit accounts:url-endpoints create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --description 'My custom URL endpoint'", - }, - csharp: { - method: 'Accounts.UrlEndpoints.Create', - example: - 'UrlEndpointCreateParams parameters = new()\n{\n Description = "My custom URL endpoint"\n};\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Create(parameters);\n\nConsole.WriteLine(urlEndpointResponse);', - }, - go: { - method: 'client.Accounts.URLEndpoints.New', + typescript: { + method: 'client.accounts.urlEndpoints.create', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.New(context.TODO(), imagekit.AccountURLEndpointNewParams{\n\t\tURLEndpointRequest: imagekit.URLEndpointRequestParam{\n\t\t\tDescription: "My custom URL endpoint",\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponse.ID)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.create({\n description: 'My custom URL endpoint',\n});\n\nconsole.log(urlEndpointResponse.id);", }, - http: { + python: { + method: 'accounts.url_endpoints.create', example: - 'curl https://api.imagekit.io/v1/accounts/url-endpoints \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "description": "My custom URL endpoint",\n "origins": [\n "origin-id-1"\n ],\n "urlPrefix": "product-images"\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.create(\n description="My custom URL endpoint",\n)\nprint(url_endpoint_response.id)', }, java: { method: 'accounts().urlEndpoints().create', @@ -2883,25 +2874,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointRequest = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().create(params)\n}', }, - php: { - method: 'accounts->urlEndpoints->create', - example: - "accounts->urlEndpoints->create(\n description: 'My custom URL endpoint',\n origins: ['origin-id-1'],\n urlPrefix: 'product-images',\n urlRewriter: ['type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true],\n);\n\nvar_dump($urlEndpointResponse);", - }, - python: { - method: 'accounts.url_endpoints.create', + go: { + method: 'client.Accounts.URLEndpoints.New', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.create(\n description="My custom URL endpoint",\n)\nprint(url_endpoint_response.id)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.New(context.TODO(), imagekit.AccountURLEndpointNewParams{\n\t\tURLEndpointRequest: imagekit.URLEndpointRequestParam{\n\t\t\tDescription: "My custom URL endpoint",\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponse.ID)\n}\n', }, ruby: { method: 'accounts.url_endpoints.create', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.create(description: "My custom URL endpoint")\n\nputs(url_endpoint_response)', }, - typescript: { - method: 'client.accounts.urlEndpoints.create', + cli: { + method: 'urlEndpoints create', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.create({\n description: 'My custom URL endpoint',\n});\n\nconsole.log(urlEndpointResponse.id);", + "imagekit accounts:url-endpoints create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --description 'My custom URL endpoint'", + }, + php: { + method: 'accounts->urlEndpoints->create', + example: + "accounts->urlEndpoints->create(\n description: 'My custom URL endpoint',\n origins: ['origin-id-1'],\n urlPrefix: 'product-images',\n urlRewriter: ['type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true],\n);\n\nvar_dump($urlEndpointResponse);", + }, + csharp: { + method: 'Accounts.UrlEndpoints.Create', + example: + 'UrlEndpointCreateParams parameters = new()\n{\n Description = "My custom URL endpoint"\n};\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Create(parameters);\n\nConsole.WriteLine(urlEndpointResponse);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/url-endpoints \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "description": "My custom URL endpoint",\n "origins": [\n "origin-id-1"\n ],\n "urlPrefix": "product-images"\n }\'', }, }, }, @@ -2920,54 +2920,54 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## get\n\n`client.accounts.urlEndpoints.get(id: string): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**get** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nRetrieves the URL‑endpoint identified by `id`.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.get('id');\n\nconsole.log(urlEndpointResponse);\n```", perLanguage: { - cli: { - method: 'urlEndpoints get', + typescript: { + method: 'client.accounts.urlEndpoints.get', example: - "imagekit accounts:url-endpoints get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.get('id');\n\nconsole.log(urlEndpointResponse.id);", }, - csharp: { - method: 'Accounts.UrlEndpoints.Get', + python: { + method: 'accounts.url_endpoints.get', example: - 'UrlEndpointGetParams parameters = new() { ID = "id" };\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Get(parameters);\n\nConsole.WriteLine(urlEndpointResponse);', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.get(\n "id",\n)\nprint(url_endpoint_response.id)', + }, + java: { + method: 'accounts().urlEndpoints().get', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get("id");\n }\n}', + }, + kotlin: { + method: 'accounts().urlEndpoints().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().get("id")\n}', }, go: { method: 'client.Accounts.URLEndpoints.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.Get(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponse.ID)\n}\n', }, - http: { - example: - 'curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - java: { - method: 'accounts().urlEndpoints().get', + ruby: { + method: 'accounts.url_endpoints.get', example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get("id");\n }\n}', + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.get("id")\n\nputs(url_endpoint_response)', }, - kotlin: { - method: 'accounts().urlEndpoints().get', + cli: { + method: 'urlEndpoints get', example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().get("id")\n}', + "imagekit accounts:url-endpoints get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", }, php: { method: 'accounts->urlEndpoints->get', example: "accounts->urlEndpoints->get('id');\n\nvar_dump($urlEndpointResponse);", }, - python: { - method: 'accounts.url_endpoints.get', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.get(\n "id",\n)\nprint(url_endpoint_response.id)', - }, - ruby: { - method: 'accounts.url_endpoints.get', + csharp: { + method: 'Accounts.UrlEndpoints.Get', example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.get("id")\n\nputs(url_endpoint_response)', + 'UrlEndpointGetParams parameters = new() { ID = "id" };\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Get(parameters);\n\nConsole.WriteLine(urlEndpointResponse);', }, - typescript: { - method: 'client.accounts.urlEndpoints.get', + http: { example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.get('id');\n\nconsole.log(urlEndpointResponse.id);", + 'curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -2992,24 +2992,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## update\n\n`client.accounts.urlEndpoints.update(id: string, description: string, origins?: string[], urlPrefix?: string, urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**put** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nUpdates the URL‑endpoint identified by `id` and returns the updated object.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n- `description: string`\n Description of the URL endpoint.\n\n- `origins?: string[]`\n Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint.\n\n- `urlPrefix?: string`\n Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint).\n\n- `urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n Configuration for third-party URL rewriting.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.update('id', { description: 'My custom URL endpoint' });\n\nconsole.log(urlEndpointResponse);\n```", perLanguage: { - cli: { - method: 'urlEndpoints update', - example: - "imagekit accounts:url-endpoints update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id \\\n --description 'My custom URL endpoint'", - }, - csharp: { - method: 'Accounts.UrlEndpoints.Update', - example: - 'UrlEndpointUpdateParams parameters = new()\n{\n ID = "id",\n Description = "My custom URL endpoint",\n};\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Update(parameters);\n\nConsole.WriteLine(urlEndpointResponse);', - }, - go: { - method: 'client.Accounts.URLEndpoints.Update', + typescript: { + method: 'client.accounts.urlEndpoints.update', example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.AccountURLEndpointUpdateParams{\n\t\t\tURLEndpointRequest: imagekit.URLEndpointRequestParam{\n\t\t\t\tDescription: "My custom URL endpoint",\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponse.ID)\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.update('id', {\n description: 'My custom URL endpoint',\n});\n\nconsole.log(urlEndpointResponse.id);", }, - http: { + python: { + method: 'accounts.url_endpoints.update', example: - 'curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "description": "My custom URL endpoint",\n "origins": [\n "origin-id-1"\n ],\n "urlPrefix": "product-images"\n }\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.update(\n id="id",\n description="My custom URL endpoint",\n)\nprint(url_endpoint_response.id)', }, java: { method: 'accounts().urlEndpoints().update', @@ -3021,25 +3012,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointUpdateParams = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().update(params)\n}', }, - php: { - method: 'accounts->urlEndpoints->update', - example: - "accounts->urlEndpoints->update(\n 'id',\n description: 'My custom URL endpoint',\n origins: ['origin-id-1'],\n urlPrefix: 'product-images',\n urlRewriter: ['type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true],\n);\n\nvar_dump($urlEndpointResponse);", - }, - python: { - method: 'accounts.url_endpoints.update', + go: { + method: 'client.Accounts.URLEndpoints.Update', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.update(\n id="id",\n description="My custom URL endpoint",\n)\nprint(url_endpoint_response.id)', + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.AccountURLEndpointUpdateParams{\n\t\t\tURLEndpointRequest: imagekit.URLEndpointRequestParam{\n\t\t\t\tDescription: "My custom URL endpoint",\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponse.ID)\n}\n', }, ruby: { method: 'accounts.url_endpoints.update', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.update("id", description: "My custom URL endpoint")\n\nputs(url_endpoint_response)', }, - typescript: { - method: 'client.accounts.urlEndpoints.update', + cli: { + method: 'urlEndpoints update', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.update('id', {\n description: 'My custom URL endpoint',\n});\n\nconsole.log(urlEndpointResponse.id);", + "imagekit accounts:url-endpoints update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id \\\n --description 'My custom URL endpoint'", + }, + php: { + method: 'accounts->urlEndpoints->update', + example: + "accounts->urlEndpoints->update(\n 'id',\n description: 'My custom URL endpoint',\n origins: ['origin-id-1'],\n urlPrefix: 'product-images',\n urlRewriter: ['type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true],\n);\n\nvar_dump($urlEndpointResponse);", + }, + csharp: { + method: 'Accounts.UrlEndpoints.Update', + example: + 'UrlEndpointUpdateParams parameters = new()\n{\n ID = "id",\n Description = "My custom URL endpoint",\n};\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Update(parameters);\n\nConsole.WriteLine(urlEndpointResponse);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "description": "My custom URL endpoint",\n "origins": [\n "origin-id-1"\n ],\n "urlPrefix": "product-images"\n }\'', }, }, }, @@ -3056,24 +3056,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## delete\n\n`client.accounts.urlEndpoints.delete(id: string): void`\n\n**delete** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nDeletes the URL‑endpoint identified by `id`. You cannot delete the default URL‑endpoint created by ImageKit during account creation.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.accounts.urlEndpoints.delete('id')\n```", perLanguage: { - cli: { - method: 'urlEndpoints delete', - example: - "imagekit accounts:url-endpoints delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - csharp: { - method: 'Accounts.UrlEndpoints.Delete', - example: - 'UrlEndpointDeleteParams parameters = new() { ID = "id" };\n\nawait client.Accounts.UrlEndpoints.Delete(parameters);', - }, - go: { - method: 'client.Accounts.URLEndpoints.Delete', + typescript: { + method: 'client.accounts.urlEndpoints.delete', example: - 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Accounts.URLEndpoints.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.accounts.urlEndpoints.delete('id');", }, - http: { + python: { + method: 'accounts.url_endpoints.delete', example: - 'curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.accounts.url_endpoints.delete(\n "id",\n)', }, java: { method: 'accounts().urlEndpoints().delete', @@ -3085,25 +3076,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.accounts().urlEndpoints().delete("id")\n}', }, - php: { - method: 'accounts->urlEndpoints->delete', - example: - "accounts->urlEndpoints->delete('id');\n\nvar_dump($result);", - }, - python: { - method: 'accounts.url_endpoints.delete', + go: { + method: 'client.Accounts.URLEndpoints.Delete', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.accounts.url_endpoints.delete(\n "id",\n)', + 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Accounts.URLEndpoints.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'accounts.url_endpoints.delete', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.accounts.url_endpoints.delete("id")\n\nputs(result)', }, - typescript: { - method: 'client.accounts.urlEndpoints.delete', + cli: { + method: 'urlEndpoints delete', example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.accounts.urlEndpoints.delete('id');", + "imagekit accounts:url-endpoints delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'accounts->urlEndpoints->delete', + example: + "accounts->urlEndpoints->delete('id');\n\nvar_dump($result);", + }, + csharp: { + method: 'Accounts.UrlEndpoints.Delete', + example: + 'UrlEndpointDeleteParams parameters = new() { ID = "id" };\n\nawait client.Accounts.UrlEndpoints.Delete(parameters);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', }, }, }, @@ -3143,24 +3143,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ markdown: "## upload\n\n`client.beta.v2.files.upload(file: string, fileName: string, token?: string, checks?: string, customCoordinates?: string, customMetadata?: object, description?: string, extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[], folder?: string, isPrivateFile?: boolean, isPublished?: boolean, overwriteAITags?: boolean, overwriteCustomMetadata?: boolean, overwriteFile?: boolean, overwriteTags?: boolean, responseFields?: string[], tags?: string[], transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }, useUniqueFileName?: boolean, webhookUrl?: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: object; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: metadata; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**post** `/api/v2/files/upload`\n\nThe V2 API enhances security by verifying the entire payload using JWT. This API is in beta.\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) about how to implement secure client-side file upload.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files, and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n\n\n### Parameters\n\n- `file: string`\n The API accepts any of the following:\n\n- **Binary data** – send the raw bytes as `multipart/form-data`.\n- **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.\n- **Base64 string** – the file encoded as a Base64 data URI or plain Base64.\n\nWhen supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.\n\n\n- `fileName: string`\n The name with which the file has to be uploaded.\n\n\n- `token?: string`\n This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses it to authenticate and check that the upload request parameters have not been tampered with after the token has been generated. Learn how to create the token on the page below. This field is only required for authentication when uploading a file from the client side.\n\n\n**Note**: Sending a JWT that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new token.\n\n\n**⚠️Warning**: JWT must be generated on the server-side because it is generated using your account's private API key. This field is required for authentication when uploading a file from the client-side.\n\n\n- `checks?: string`\n Server-side checks to run on the asset.\nRead more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks).\n\n\n- `customCoordinates?: string`\n Define an important area in the image. This is only relevant for image type files.\n\n - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100`\n - Can be used with fo-customtransformation.\n - If this field is not specified and the file is overwritten, then customCoordinates will be removed.\n\n\n- `customMetadata?: object`\n JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.\n\n\n- `description?: string`\n Optional text to describe the contents of the file.\n\n\n- `extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[]`\n Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.\n\n\n- `folder?: string`\n The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created. Using multiple `/` creates a nested folder.\n\n\n- `isPrivateFile?: boolean`\n Whether to mark the file as private or not.\n\nIf `true`, the file is marked as private and is accessible only using named transformation or signed URL.\n\n\n- `isPublished?: boolean`\n Whether to upload file as published or not.\n\nIf `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published.\n\nThe option to upload in draft state is only available in custom enterprise pricing plans.\n\n\n- `overwriteAITags?: boolean`\n If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags.\n\n\n- `overwriteCustomMetadata?: boolean`\n If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed.\n\n\n- `overwriteFile?: boolean`\n If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately.\n\n\n- `overwriteTags?: boolean`\n If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed.\n\n\n- `responseFields?: string[]`\n Array of response field keys to include in the API response body.\n\n\n- `tags?: string[]`\n Set the tags while uploading the file.\nProvide an array of tag strings (e.g. `[\"tag1\", \"tag2\", \"tag3\"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed.\nIf this field is not specified and the file is overwritten, the existing tags will be removed.\n\n\n- `transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }`\n Configure pre-processing (`pre`) and post-processing (`post`) transformations.\n\n- `pre` — applied before the file is uploaded to the Media Library. \n Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress).\n\n- `post` — applied immediately after upload. \n Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay.\n\nYou can mix and match any combination of post-processing types.\n\n - `post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]`\n List of transformations to apply *after* the file is uploaded. \nEach item must match one of the following types:\n`transformation`, `gif-to-video`, `thumbnail`, `abs`.\n\n - `pre?: string`\n Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion.\n\n\n- `useUniqueFileName?: boolean`\n Whether to use a unique filename for this file or not.\n\nIf `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename.\n\nIf `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced.\n\n\n- `webhookUrl?: string`\n The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure.\n\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a successful upload.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnailUrl?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.beta.v2.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'fileName' });\n\nconsole.log(response);\n```", perLanguage: { - cli: { - method: 'files upload', - example: - "imagekit beta:v2:files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name fileName", - }, - csharp: { - method: 'Beta.V2.Files.Upload', - example: - 'FileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes("Example data"),\n FileName = "fileName",\n};\n\nvar response = await client.Beta.V2.Files.Upload(parameters);\n\nConsole.WriteLine(response);', - }, - go: { - method: 'client.Beta.V2.Files.Upload', + typescript: { + method: 'client.beta.v2.files.upload', example: - 'package main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Beta.V2.Files.Upload(context.TODO(), imagekit.BetaV2FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("Example data"))),\n\t\tFileName: "fileName",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n', + "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.beta.v2.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);", }, - http: { + python: { + method: 'beta.v2.files.upload', example: - 'curl https://upload.imagekit.io/api/v2/files/upload \\\n -H \'Content-Type: multipart/form-data\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -F \'file=@/path/to/file\' \\\n -F fileName=fileName \\\n -F checks=\'"request.folder" : "marketing/"\n \' \\\n -F customMetadata=\'{"brand":"bar","color":"bar"}\' \\\n -F description=\'Running shoes\' \\\n -F extensions=\'[{"name":"remove-bg","options":{"add_shadow":true}},{"maxTags":5,"minConfidence":95,"name":"google-auto-tagging"},{"name":"ai-auto-description"},{"name":"ai-tasks","tasks":[{"instruction":"What types of clothing items are visible in this image?","type":"select_tags","vocabulary":["shirt","tshirt","dress","trousers","jacket"]},{"instruction":"Is this a luxury or high-end fashion item?","type":"yes_no","on_yes":{"add_tags":["luxury","premium"]}}]},{"id":"ext_abc123","name":"saved-extension"}]\' \\\n -F responseFields=\'["tags","customCoordinates","isPrivateFile"]\' \\\n -F tags=\'["t-shirt","round-neck","men"]\' \\\n -F transformation=\'{"post":[{"type":"thumbnail","value":"w-150,h-150"},{"protocol":"dash","type":"abs","value":"sr-240_360_480_720_1080"}]}\'', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.beta.v2.files.upload(\n file=b"Example data",\n file_name="fileName",\n)\nprint(response.video_codec)', }, java: { method: 'beta().v2().files().upload', @@ -3172,25 +3163,34 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.beta.v2.files.FileUploadParams\nimport com.imagekit.api.models.beta.v2.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUploadParams = FileUploadParams.builder()\n .file("Example data".byteInputStream())\n .fileName("fileName")\n .build()\n val response: FileUploadResponse = client.beta().v2().files().upload(params)\n}', }, - php: { - method: 'beta->v2->files->upload', - example: - "beta->v2->files->upload(\n file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),\n fileName: 'fileName',\n token: 'token',\n checks: \"\\\"request.folder\\\" : \\\"marketing/\\\"\\n\",\n customCoordinates: 'customCoordinates',\n customMetadata: ['brand' => 'bar', 'color' => 'bar'],\n description: 'Running shoes',\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n folder: 'folder',\n isPrivateFile: true,\n isPublished: true,\n overwriteAITags: true,\n overwriteCustomMetadata: true,\n overwriteFile: true,\n overwriteTags: true,\n responseFields: ['tags', 'customCoordinates', 'isPrivateFile'],\n tags: ['t-shirt', 'round-neck', 'men'],\n transformation: [\n 'post' => [\n ['type' => 'thumbnail', 'value' => 'w-150,h-150'],\n [\n 'protocol' => 'dash',\n 'type' => 'abs',\n 'value' => 'sr-240_360_480_720_1080',\n ],\n ],\n 'pre' => 'w-300,h-300,q-80',\n ],\n useUniqueFileName: true,\n webhookURL: 'https://example.com',\n);\n\nvar_dump($response);", - }, - python: { - method: 'beta.v2.files.upload', + go: { + method: 'client.Beta.V2.Files.Upload', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.beta.v2.files.upload(\n file=b"Example data",\n file_name="fileName",\n)\nprint(response.video_codec)', + 'package main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Beta.V2.Files.Upload(context.TODO(), imagekit.BetaV2FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("Example data"))),\n\t\tFileName: "fileName",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n', }, ruby: { method: 'beta.v2.files.upload', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.beta.v2.files.upload(file: StringIO.new("Example data"), file_name: "fileName")\n\nputs(response)', }, - typescript: { - method: 'client.beta.v2.files.upload', + cli: { + method: 'files upload', example: - "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.beta.v2.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);", + "imagekit beta:v2:files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name fileName", + }, + php: { + method: 'beta->v2->files->upload', + example: + "beta->v2->files->upload(\n file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),\n fileName: 'fileName',\n token: 'token',\n checks: \"\\\"request.folder\\\" : \\\"marketing/\\\"\\n\",\n customCoordinates: 'customCoordinates',\n customMetadata: ['brand' => 'bar', 'color' => 'bar'],\n description: 'Running shoes',\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n folder: 'folder',\n isPrivateFile: true,\n isPublished: true,\n overwriteAITags: true,\n overwriteCustomMetadata: true,\n overwriteFile: true,\n overwriteTags: true,\n responseFields: ['tags', 'customCoordinates', 'isPrivateFile'],\n tags: ['t-shirt', 'round-neck', 'men'],\n transformation: [\n 'post' => [\n ['type' => 'thumbnail', 'value' => 'w-150,h-150'],\n [\n 'protocol' => 'dash',\n 'type' => 'abs',\n 'value' => 'sr-240_360_480_720_1080',\n ],\n ],\n 'pre' => 'w-300,h-300,q-80',\n ],\n useUniqueFileName: true,\n webhookURL: 'https://example.com',\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Beta.V2.Files.Upload', + example: + 'FileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes("Example data"),\n FileName = "fileName",\n};\n\nvar response = await client.Beta.V2.Files.Upload(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://upload.imagekit.io/api/v2/files/upload \\\n -H \'Content-Type: multipart/form-data\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -F \'file=@/path/to/file\' \\\n -F fileName=fileName \\\n -F checks=\'"request.folder" : "marketing/"\n \' \\\n -F customMetadata=\'{"brand":"bar","color":"bar"}\' \\\n -F description=\'Running shoes\' \\\n -F extensions=\'[{"name":"remove-bg","options":{"add_shadow":true}},{"maxTags":5,"minConfidence":95,"name":"google-auto-tagging"},{"name":"ai-auto-description"},{"name":"ai-tasks","tasks":[{"instruction":"What types of clothing items are visible in this image?","type":"select_tags","vocabulary":["shirt","tshirt","dress","trousers","jacket"]},{"instruction":"Is this a luxury or high-end fashion item?","type":"yes_no","on_yes":{"add_tags":["luxury","premium"]}}]},{"id":"ext_abc123","name":"saved-extension"}]\' \\\n -F responseFields=\'["tags","customCoordinates","isPrivateFile"]\' \\\n -F tags=\'["t-shirt","round-neck","men"]\' \\\n -F transformation=\'{"post":[{"type":"thumbnail","value":"w-150,h-150"},{"protocol":"dash","type":"abs","value":"sr-240_360_480_720_1080"}]}\'', }, }, }, @@ -3203,17 +3203,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ stainlessPath: '(resource) webhooks > (method) unwrap', qualified: 'client.webhooks.unwrap', perLanguage: { - cli: { + typescript: { + method: 'client.webhooks.unwrap', example: - "imagekit webhooks unwrap \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - csharp: { - example: 'WebhookUnwrapParams parameters = new();\n\nawait client.Webhooks.Unwrap(parameters);', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.webhooks.unwrap();", }, - go: { - method: 'client.Webhooks.Unwrap', + python: { + method: 'webhooks.unwrap', example: - 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Webhooks.Unwrap(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.webhooks.unwrap()', }, java: { example: @@ -3223,25 +3221,27 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.webhooks.WebhookUnwrapParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.webhooks().unwrap()\n}', }, - php: { - method: 'webhooks->unwrap', - example: - "webhooks->unwrap();\n\nvar_dump($result);", - }, - python: { - method: 'webhooks.unwrap', + go: { + method: 'client.Webhooks.Unwrap', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.webhooks.unwrap()', + 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Webhooks.Unwrap(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'webhooks.unwrap', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.webhooks.unwrap\n\nputs(result)', }, - typescript: { - method: 'client.webhooks.unwrap', + cli: { example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.webhooks.unwrap();", + "imagekit webhooks unwrap \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'webhooks->unwrap', + example: + "webhooks->unwrap();\n\nvar_dump($result);", + }, + csharp: { + example: 'WebhookUnwrapParams parameters = new();\n\nawait client.Webhooks.Unwrap(parameters);', }, }, }, @@ -3254,18 +3254,15 @@ const EMBEDDED_METHODS: MethodEntry[] = [ stainlessPath: '(resource) webhooks > (method) unsafe_unwrap', qualified: 'client.webhooks.unsafeUnwrap', perLanguage: { - cli: { - example: - "imagekit webhooks unsafe-unwrap \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - csharp: { + typescript: { + method: 'client.webhooks.unsafeUnwrap', example: - 'WebhookUnsafeUnwrapParams parameters = new();\n\nawait client.Webhooks.UnsafeUnwrap(parameters);', + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.webhooks.unsafeUnwrap();", }, - go: { - method: 'client.Webhooks.UnsafeUnwrap', + python: { + method: 'webhooks.unsafe_unwrap', example: - 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Webhooks.UnsafeUnwrap(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.webhooks.unsafe_unwrap()', }, java: { example: @@ -3275,25 +3272,28 @@ const EMBEDDED_METHODS: MethodEntry[] = [ example: 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.webhooks.WebhookUnsafeUnwrapParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.webhooks().unsafeUnwrap()\n}', }, - php: { - method: 'webhooks->unsafeUnwrap', - example: - "webhooks->unsafeUnwrap();\n\nvar_dump($result);", - }, - python: { - method: 'webhooks.unsafe_unwrap', + go: { + method: 'client.Webhooks.UnsafeUnwrap', example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.webhooks.unsafe_unwrap()', + 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Webhooks.UnsafeUnwrap(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'webhooks.unsafe_unwrap', example: 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.webhooks.unsafe_unwrap\n\nputs(result)', }, - typescript: { - method: 'client.webhooks.unsafeUnwrap', + cli: { example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.webhooks.unsafeUnwrap();", + "imagekit webhooks unsafe-unwrap \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'webhooks->unsafeUnwrap', + example: + "webhooks->unsafeUnwrap();\n\nvar_dump($result);", + }, + csharp: { + example: + 'WebhookUnsafeUnwrapParams parameters = new();\n\nawait client.Webhooks.UnsafeUnwrap(parameters);', }, }, }, From d7c26d76741fb611fc131806719aad0ee3696c4e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 15:53:23 +0000 Subject: [PATCH 17/36] chore(formatter): run prettier and eslint separately --- .prettierignore | 1 + eslint.config.mjs | 3 - package.json | 1 - .../worker-configuration.d.ts | 4 +- packages/mcp-server/jest.config.ts | 4 +- packages/mcp-server/src/auth.ts | 56 +- packages/mcp-server/src/code-tool-types.ts | 2 +- packages/mcp-server/src/code-tool-worker.ts | 116 +- packages/mcp-server/src/code-tool.ts | 145 +- packages/mcp-server/src/docs-search-tool.ts | 55 +- packages/mcp-server/src/http.ts | 68 +- packages/mcp-server/src/index.ts | 2 +- packages/mcp-server/src/instructions.ts | 20 +- packages/mcp-server/src/local-docs-search.ts | 5821 ++++++++--------- packages/mcp-server/src/methods.ts | 548 +- packages/mcp-server/src/options.ts | 47 +- packages/mcp-server/src/server.ts | 104 +- packages/mcp-server/src/types.ts | 80 +- scripts/fast-format | 6 +- scripts/format | 3 +- scripts/lint | 3 + src/api-promise.ts | 2 +- src/client.ts | 455 +- src/core/api-promise.ts | 9 +- src/core/error.ts | 46 +- src/error.ts | 2 +- src/index.ts | 16 +- src/internal/builtin-types.ts | 23 +- src/internal/detect-platform.ts | 6 +- src/internal/errors.ts | 14 +- src/internal/headers.ts | 4 +- src/internal/parse.ts | 12 +- src/internal/request-options.ts | 6 +- src/internal/shim-types.ts | 4 +- src/internal/shims.ts | 4 +- src/internal/to-file.ts | 14 +- src/internal/types.ts | 50 +- src/internal/utils/log.ts | 37 +- src/internal/utils/uuid.ts | 8 +- src/resource.ts | 2 +- src/resources/accounts/accounts.ts | 28 +- src/resources/accounts/index.ts | 22 +- src/resources/accounts/origins.ts | 59 +- src/resources/accounts/url-endpoints.ts | 35 +- src/resources/accounts/usage.ts | 5 +- src/resources/assets.ts | 28 +- src/resources/beta/beta.ts | 4 +- src/resources/beta/index.ts | 4 +- src/resources/beta/v2/files.ts | 47 +- src/resources/beta/v2/index.ts | 4 +- src/resources/beta/v2/v2.ts | 2 +- src/resources/cache/cache.ts | 9 +- src/resources/cache/index.ts | 9 +- src/resources/cache/invalidation.ts | 2 +- src/resources/custom-metadata-fields.ts | 18 +- src/resources/files/bulk.ts | 2 +- src/resources/files/files.ts | 90 +- src/resources/files/index.ts | 41 +- src/resources/files/metadata.ts | 4 +- src/resources/files/versions.ts | 25 +- src/resources/folders/folders.ts | 13 +- src/resources/folders/index.ts | 16 +- src/resources/folders/job.ts | 4 +- src/resources/saved-extensions.ts | 15 +- src/resources/shared.ts | 45 +- src/resources/webhooks.ts | 35 +- src/uploads.ts | 2 +- src/version.ts | 2 +- tests/api-resources/accounts/origins.test.ts | 62 +- .../accounts/url-endpoints.test.ts | 26 +- tests/api-resources/accounts/usage.test.ts | 2 +- tests/api-resources/assets.test.ts | 27 +- tests/api-resources/beta/v2/files.test.ts | 153 +- .../api-resources/cache/invalidation.test.ts | 10 +- .../custom-metadata-fields.test.ts | 77 +- tests/api-resources/files/bulk.test.ts | 40 +- tests/api-resources/files/files.test.ts | 195 +- tests/api-resources/files/metadata.test.ts | 2 +- tests/api-resources/files/versions.test.ts | 2 +- tests/api-resources/folders/folders.test.ts | 48 +- tests/api-resources/folders/job.test.ts | 2 +- tests/api-resources/saved-extensions.test.ts | 34 +- tests/api-resources/webhooks.test.ts | 35 +- tests/index.test.ts | 610 +- tests/stringifyQuery.test.ts | 42 +- yarn.lock | 32 - 86 files changed, 4257 insertions(+), 5515 deletions(-) diff --git a/.prettierignore b/.prettierignore index 7cc13dd1..6e7fb359 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,6 +2,7 @@ CHANGELOG.md /ecosystem-tests/*/** /node_modules /deno +/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts # don't format tsc output, will break source maps dist diff --git a/eslint.config.mjs b/eslint.config.mjs index c1a01a62..42741bdb 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,7 +1,6 @@ // @ts-check import tseslint from 'typescript-eslint'; import unusedImports from 'eslint-plugin-unused-imports'; -import prettier from 'eslint-plugin-prettier'; export default tseslint.config( { @@ -14,11 +13,9 @@ export default tseslint.config( plugins: { '@typescript-eslint': tseslint.plugin, 'unused-imports': unusedImports, - prettier, }, rules: { 'no-unused-vars': 'off', - 'prettier/prettier': 'error', 'unused-imports/no-unused-imports': 'error', 'no-restricted-imports': [ 'error', diff --git a/package.json b/package.json index 10029643..b1c22e58 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "@typescript-eslint/eslint-plugin": "8.31.1", "@typescript-eslint/parser": "8.31.1", "eslint": "^9.39.1", - "eslint-plugin-prettier": "^5.4.1", "eslint-plugin-unused-imports": "^4.1.4", "iconv-lite": "^0.6.3", "jest": "^29.4.0", diff --git a/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts b/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts index 432fe3e0..32da9a90 100644 --- a/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts +++ b/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts @@ -1,4 +1,4 @@ -/* eslint-disable */ + // Generated by Wrangler by running `wrangler types` (hash: fc286f4a60f8eb63b1e0d82ea1f34233) // Runtime types generated with workerd@1.20260124.0 2025-03-10 nodejs_compat declare namespace Cloudflare { @@ -29,7 +29,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -/* eslint-disable */ + // noinspection JSUnusedGlobalSymbols declare var onmessage: never; /** diff --git a/packages/mcp-server/jest.config.ts b/packages/mcp-server/jest.config.ts index c1a41722..6c1213f2 100644 --- a/packages/mcp-server/jest.config.ts +++ b/packages/mcp-server/jest.config.ts @@ -10,7 +10,9 @@ const config: JestConfigWithTsJest = { '^@imagekit/api-mcp$': '/src/index.ts', '^@imagekit/api-mcp/(.*)$': '/src/$1', }, - modulePathIgnorePatterns: ['/dist/'], + modulePathIgnorePatterns: [ + '/dist/', + ], testPathIgnorePatterns: ['scripts'], }; diff --git a/packages/mcp-server/src/auth.ts b/packages/mcp-server/src/auth.ts index 085cac43..f3c8810a 100644 --- a/packages/mcp-server/src/auth.ts +++ b/packages/mcp-server/src/auth.ts @@ -1,50 +1,36 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { IncomingMessage } from 'node:http'; -import { ClientOptions } from '@imagekit/nodejs'; +import { IncomingMessage } from 'node:http' +import { ClientOptions } from '@imagekit/nodejs' import { McpOptions } from './options'; -export const parseClientAuthHeaders = (req: IncomingMessage, required?: boolean): Partial => { - if (req.headers.authorization) { - const scheme = req.headers.authorization.split(' ')[0]!; - const value = req.headers.authorization.slice(scheme.length + 1); - switch (scheme) { - case 'Basic': - const rawValue = Buffer.from(value, 'base64').toString(); - return { - privateKey: rawValue.slice(0, rawValue.search(':')), - password: rawValue.slice(rawValue.search(':') + 1), - }; - default: - throw new Error( - 'Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Basic).', - ); - } - } else if (required) { - throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.'); +export const parseClientAuthHeaders = (req: IncomingMessage, required?: boolean): Partial => { if (req.headers.authorization) { + const scheme = req.headers.authorization.split(" ")[0]!; + const value = req.headers.authorization.slice(scheme.length + 1); + switch (scheme) { + case 'Basic': + const rawValue = Buffer.from(value, 'base64').toString(); + return { privateKey: rawValue.slice(0, rawValue.search(':')), password: rawValue.slice(rawValue.search(':') + 1) } + default: + throw new Error('Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Basic).'); } +} else if (required) { + throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.'); +} - const privateKey = - Array.isArray(req.headers['x-imagekit-private-key']) ? - req.headers['x-imagekit-private-key'][0] - : req.headers['x-imagekit-private-key']; - const password = - Array.isArray(req.headers['x-optional-imagekit-ignores-this']) ? - req.headers['x-optional-imagekit-ignores-this'][0] - : req.headers['x-optional-imagekit-ignores-this']; - return { privateKey, password }; -}; +const privateKey = Array.isArray(req.headers['x-imagekit-private-key']) ? req.headers['x-imagekit-private-key'][0] : req.headers['x-imagekit-private-key'] +const password = Array.isArray(req.headers['x-optional-imagekit-ignores-this']) ? req.headers['x-optional-imagekit-ignores-this'][0] : req.headers['x-optional-imagekit-ignores-this'] +return {privateKey, password}; } export const getStainlessApiKey = (req: IncomingMessage, mcpOptions: McpOptions): string | undefined => { // Try to get the key from the x-stainless-api-key header - const headerKey = - Array.isArray(req.headers['x-stainless-api-key']) ? - req.headers['x-stainless-api-key'][0] - : req.headers['x-stainless-api-key']; + const headerKey = Array.isArray(req.headers['x-stainless-api-key']) ? + req.headers['x-stainless-api-key'][0] + : req.headers['x-stainless-api-key']; if (headerKey && typeof headerKey === 'string') { return headerKey; } // Fall back to value set in the mcpOptions (e.g. from environment variable), if provided return mcpOptions.stainlessApiKey; -}; +} diff --git a/packages/mcp-server/src/code-tool-types.ts b/packages/mcp-server/src/code-tool-types.ts index c29cbd38..40acf26b 100644 --- a/packages/mcp-server/src/code-tool-types.ts +++ b/packages/mcp-server/src/code-tool-types.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { ClientOptions } from '@imagekit/nodejs'; +import { ClientOptions } from '@imagekit/nodejs' export type WorkerInput = { project_name: string; diff --git a/packages/mcp-server/src/code-tool-worker.ts b/packages/mcp-server/src/code-tool-worker.ts index 07b79f57..bb3ca749 100644 --- a/packages/mcp-server/src/code-tool-worker.ts +++ b/packages/mcp-server/src/code-tool-worker.ts @@ -59,8 +59,8 @@ function getTSDiagnostics(code: string): string[] { const codeWithImport = [ 'import { ImageKit } from "@imagekit/nodejs";', functionSource.type === 'declaration' ? - `async function run(${functionSource.client}: ImageKit)` - : `const run: (${functionSource.client}: ImageKit) => Promise =`, + `async function run(${functionSource.client}: ImageKit)` : + `const run: (${functionSource.client}: ImageKit) => Promise =`, functionSource.code, ].join('\n'); const sourcePath = path.resolve('code.ts'); @@ -108,55 +108,55 @@ function getTSDiagnostics(code: string): string[] { const fuse = new Fuse( [ - 'client.customMetadataFields.create', - 'client.customMetadataFields.delete', - 'client.customMetadataFields.list', - 'client.customMetadataFields.update', - 'client.files.copy', - 'client.files.delete', - 'client.files.get', - 'client.files.move', - 'client.files.rename', - 'client.files.update', - 'client.files.upload', - 'client.files.bulk.addTags', - 'client.files.bulk.delete', - 'client.files.bulk.removeAITags', - 'client.files.bulk.removeTags', - 'client.files.versions.delete', - 'client.files.versions.get', - 'client.files.versions.list', - 'client.files.versions.restore', - 'client.files.metadata.get', - 'client.files.metadata.getFromURL', - 'client.savedExtensions.create', - 'client.savedExtensions.delete', - 'client.savedExtensions.get', - 'client.savedExtensions.list', - 'client.savedExtensions.update', - 'client.assets.list', - 'client.cache.invalidation.create', - 'client.cache.invalidation.get', - 'client.folders.copy', - 'client.folders.create', - 'client.folders.delete', - 'client.folders.move', - 'client.folders.rename', - 'client.folders.job.get', - 'client.accounts.usage.get', - 'client.accounts.origins.create', - 'client.accounts.origins.delete', - 'client.accounts.origins.get', - 'client.accounts.origins.list', - 'client.accounts.origins.update', - 'client.accounts.urlEndpoints.create', - 'client.accounts.urlEndpoints.delete', - 'client.accounts.urlEndpoints.get', - 'client.accounts.urlEndpoints.list', - 'client.accounts.urlEndpoints.update', - 'client.beta.v2.files.upload', - 'client.webhooks.unsafeUnwrap', - 'client.webhooks.unwrap', + "client.customMetadataFields.create", + "client.customMetadataFields.delete", + "client.customMetadataFields.list", + "client.customMetadataFields.update", + "client.files.copy", + "client.files.delete", + "client.files.get", + "client.files.move", + "client.files.rename", + "client.files.update", + "client.files.upload", + "client.files.bulk.addTags", + "client.files.bulk.delete", + "client.files.bulk.removeAITags", + "client.files.bulk.removeTags", + "client.files.versions.delete", + "client.files.versions.get", + "client.files.versions.list", + "client.files.versions.restore", + "client.files.metadata.get", + "client.files.metadata.getFromURL", + "client.savedExtensions.create", + "client.savedExtensions.delete", + "client.savedExtensions.get", + "client.savedExtensions.list", + "client.savedExtensions.update", + "client.assets.list", + "client.cache.invalidation.create", + "client.cache.invalidation.get", + "client.folders.copy", + "client.folders.create", + "client.folders.delete", + "client.folders.move", + "client.folders.rename", + "client.folders.job.get", + "client.accounts.usage.get", + "client.accounts.origins.create", + "client.accounts.origins.delete", + "client.accounts.origins.get", + "client.accounts.origins.list", + "client.accounts.origins.update", + "client.accounts.urlEndpoints.create", + "client.accounts.urlEndpoints.delete", + "client.accounts.urlEndpoints.get", + "client.accounts.urlEndpoints.list", + "client.accounts.urlEndpoints.update", + "client.beta.v2.files.upload", + "client.webhooks.unsafeUnwrap", + "client.webhooks.unwrap" ], { threshold: 1, shouldSort: true }, ); @@ -239,12 +239,7 @@ function parseError(code: string, error: unknown): string | undefined { // Deno uses V8; the first ":LINE:COLUMN" is the top of stack. const lineNumber = error.stack?.match(/:([0-9]+):[0-9]+/)?.[1]; // -1 for the zero-based indexing - const line = - lineNumber && - code - .split('\n') - .at(parseInt(lineNumber, 10) - 1) - ?.trim(); + const line = lineNumber && code.split('\n').at(parseInt(lineNumber, 10) - 1)?.trim(); return line ? `${message}\n at line ${lineNumber}\n ${line}` : message; } catch { return message; @@ -256,9 +251,8 @@ const fetch = async (req: Request): Promise => { const runFunctionSource = code ? getRunFunctionSource(code) : null; if (!runFunctionSource) { - const message = - code ? - 'The code is missing a top-level `run` function.' + const message = code + ? 'The code is missing a top-level `run` function.' : 'The code argument is missing. Provide one containing a top-level `run` function.'; return Response.json( { @@ -303,7 +297,7 @@ const fetch = async (req: Request): Promise => { try { let run_ = async (client: any) => {}; run_ = (await tseval(`${code}\nexport default run;`)).default; - const result = await run_(makeSdkProxy(client, { path: ['client'] })); + const result = await run_(makeSdkProxy(client, { path: ["client"] })); return Response.json({ is_error: false, result, diff --git a/packages/mcp-server/src/code-tool.ts b/packages/mcp-server/src/code-tool.ts index 0d5a3ac3..e52ddc4d 100644 --- a/packages/mcp-server/src/code-tool.ts +++ b/packages/mcp-server/src/code-tool.ts @@ -1,16 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { - ContentBlock, - McpRequestContext, - McpTool, - Metadata, - ToolCallResult, - asErrorResult, - asTextContentResult, -} from './types'; +import { ContentBlock, McpRequestContext, McpTool, Metadata, ToolCallResult, asErrorResult, asTextContentResult } from './types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import { readEnv, requireValue } from './util'; +import { readEnv, requireValue } from "./util"; import { WorkerInput, WorkerOutput } from './code-tool-types'; import { getLogger } from './logger'; import { SdkMethod } from './methods'; @@ -52,13 +44,10 @@ Always type dynamic key-value stores explicitly as Record * @param codeExecutionMode - Whether to execute code in a local Deno environment or in a remote * sandbox environment hosted by Stainless. */ -export function codeTool({ - blockedMethods, - codeExecutionMode, -}: { - blockedMethods: SdkMethod[] | undefined; - codeExecutionMode: McpCodeExecutionMode; -}): McpTool { +export function codeTool( + {blockedMethods, codeExecutionMode}: + {blockedMethods: SdkMethod[] | undefined, codeExecutionMode: McpCodeExecutionMode}, +): McpTool { const metadata: Metadata = { resource: 'all', operation: 'write', tags: [] }; const tool: Tool = { name: 'execute', @@ -81,13 +70,10 @@ export function codeTool({ const logger = getLogger(); - const handler = async ({ - reqContext, - args, - }: { - reqContext: McpRequestContext; - args: any; - }): Promise => { + const handler = async ( + {reqContext, args}: + {reqContext: McpRequestContext, args: any}, + ): Promise => { const code = args.code as string; // Do very basic blocking of code that includes forbidden method names. // @@ -97,11 +83,7 @@ export function codeTool({ if (blockedMethods) { const blockedMatches = blockedMethods.filter((method) => code.includes(method.fullyQualifiedName)); if (blockedMatches.length > 0) { - return asErrorResult( - `The following methods have been blocked by the MCP server and cannot be used in code execution: ${blockedMatches - .map((m) => m.fullyQualifiedName) - .join(', ')}`, - ); + return asErrorResult(`The following methods have been blocked by the MCP server and cannot be used in code execution: ${blockedMatches.map((m) => m.fullyQualifiedName).join(', ')}`); } } @@ -126,46 +108,40 @@ export function codeTool({ 'Got code tool execution result', ); return result; - }; + } return { metadata, tool, handler }; } -const remoteStainlessHandler = async ({ - reqContext, - args, -}: { - reqContext: McpRequestContext; - args: any; -}): Promise => { +const remoteStainlessHandler = async ( + {reqContext, args}: + {reqContext: McpRequestContext, args: any}, +): Promise => { const code = args.code as string; const intent = args.intent as string | undefined; const client = reqContext.client; - const codeModeEndpoint = readEnv('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool'; + const codeModeEndpoint = readEnv("CODE_MODE_ENDPOINT_URL") ?? "https://api.stainless.com/api/ai/code-tool"; const localClientEnvs = { - IMAGEKIT_PRIVATE_KEY: requireValue( - readEnv('IMAGEKIT_PRIVATE_KEY') ?? client.privateKey, - 'set IMAGEKIT_PRIVATE_KEY environment variable or provide privateKey client option', - ), - OPTIONAL_IMAGEKIT_IGNORES_THIS: readEnv('OPTIONAL_IMAGEKIT_IGNORES_THIS') ?? client.password ?? undefined, - IMAGEKIT_WEBHOOK_SECRET: readEnv('IMAGEKIT_WEBHOOK_SECRET') ?? client.webhookSecret ?? undefined, - IMAGE_KIT_BASE_URL: readEnv('IMAGE_KIT_BASE_URL') ?? client.baseURL ?? undefined, - }; + IMAGEKIT_PRIVATE_KEY: requireValue(readEnv('IMAGEKIT_PRIVATE_KEY') ?? client.privateKey, 'set IMAGEKIT_PRIVATE_KEY environment variable or provide privateKey client option'), + OPTIONAL_IMAGEKIT_IGNORES_THIS: readEnv('OPTIONAL_IMAGEKIT_IGNORES_THIS') ?? client.password ?? undefined, + IMAGEKIT_WEBHOOK_SECRET: readEnv('IMAGEKIT_WEBHOOK_SECRET') ?? client.webhookSecret ?? undefined, + IMAGE_KIT_BASE_URL: readEnv('IMAGE_KIT_BASE_URL') ?? client.baseURL ?? undefined, +}; // Merge any upstream client envs from the request header, with upstream values taking precedence. const mergedClientEnvs = { ...localClientEnvs, ...reqContext.upstreamClientEnvs }; // Setting a Stainless API key authenticates requests to the code tool endpoint. const res = await fetch(codeModeEndpoint, { - method: 'POST', + method: "POST", headers: { - ...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }), - 'Content-Type': 'application/json', - 'x-stainless-mcp-client-envs': JSON.stringify(mergedClientEnvs), + ...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey, }), + "Content-Type": "application/json", + "x-stainless-mcp-client-envs": JSON.stringify(mergedClientEnvs), }, body: JSON.stringify({ - project_name: 'imagekit', + project_name: "imagekit", code, intent, client_opts: {}, @@ -174,18 +150,12 @@ const remoteStainlessHandler = async ({ if (!res.ok) { if (res.status === 404 && !reqContext.stainlessApiKey) { - throw new Error( - 'Could not access code tool for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.', - ); + throw new Error('Could not access code tool for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.'); } - throw new Error( - `${res.status}: ${ - res.statusText - } error when trying to contact Code Tool server. Details: ${await res.text()}`, - ); + throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`); } - const { is_error, result, log_lines, err_lines } = (await res.json()) as WorkerOutput; + const { is_error, result, log_lines, err_lines } = await res.json() as WorkerOutput; const hasLogs = log_lines.length > 0 || err_lines.length > 0; const output = { result, @@ -193,18 +163,17 @@ const remoteStainlessHandler = async ({ ...(err_lines.length > 0 && { err_lines }), }; if (is_error) { - return asErrorResult(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2)); + return asErrorResult( + typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2), + ); } return asTextContentResult(output); }; -const localDenoHandler = async ({ - reqContext, - args, -}: { - reqContext: McpRequestContext; - args: unknown; -}): Promise => { +const localDenoHandler = async ( + {reqContext, args} : + {reqContext: McpRequestContext, args: unknown}, +): Promise => { const fs = await import('node:fs'); const path = await import('node:path'); const url = await import('node:url'); @@ -229,20 +198,24 @@ const localDenoHandler = async ({ } catch { try { // Use deno binary in node_modules if it's found - const denoNodeModulesPath = path.resolve(packageNodeModulesPath, 'deno', 'bin.cjs'); + const denoNodeModulesPath = path.resolve( + packageNodeModulesPath, + 'deno', + 'bin.cjs', + ); await fs.promises.access(denoNodeModulesPath, fs.constants.X_OK); denoPath = denoNodeModulesPath; } catch { return asErrorResult( 'Deno is required for code execution but was not found. ' + - 'Install it from https://deno.land or run: npm install deno', + 'Install it from https://deno.land or run: npm install deno', ); } } const allowReadPaths = [ 'code-tool-worker.mjs', - `${workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, '$1')}/`, + `${workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, "$1")}/`, packageRoot, ]; @@ -276,7 +249,7 @@ const localDenoHandler = async ({ // Merge any upstream client envs into the Deno subprocess environment, // with the upstream env vars taking precedence. env: { ...process.env, ...reqContext.upstreamClientEnvs }, - }, + } }); try { @@ -288,13 +261,13 @@ const localDenoHandler = async ({ // Strip null/undefined values so that the worker SDK client can fall back to // reading from environment variables (including any upstreamClientEnvs). const opts = { - ...(client.baseURL != null ? { baseURL: client.baseURL } : undefined), - ...(client.privateKey != null ? { privateKey: client.privateKey } : undefined), - ...(client.password != null ? { password: client.password } : undefined), - ...(client.webhookSecret != null ? { webhookSecret: client.webhookSecret } : undefined), - defaultHeaders: { - 'X-Stainless-MCP': 'true', - }, + ...(client.baseURL != null ? { baseURL: client.baseURL } : undefined), + ...(client.privateKey != null ? { privateKey: client.privateKey } : undefined), + ...(client.password != null ? { password: client.password } : undefined), + ...(client.webhookSecret != null ? { webhookSecret: client.webhookSecret } : undefined), + defaultHeaders: { + 'X-Stainless-MCP': 'true', + }, } satisfies Partial as ClientOptions; const req = worker.request( @@ -341,12 +314,11 @@ const localDenoHandler = async ({ if (resp.status === 200) { const { result, log_lines, err_lines } = (await resp.json()) as WorkerOutput; const returnOutput: ContentBlock | null = - result == null ? null : ( - { + result == null ? null + : { type: 'text', text: typeof result === 'string' ? result : JSON.stringify(result), - } - ); + }; const logOutput: ContentBlock | null = log_lines.length === 0 ? null @@ -367,12 +339,11 @@ const localDenoHandler = async ({ } else { const { result, log_lines, err_lines } = (await resp.json()) as WorkerOutput; const messageOutput: ContentBlock | null = - result == null ? null : ( - { + result == null ? null + : { type: 'text', text: typeof result === 'string' ? result : JSON.stringify(result), - } - ); + }; const logOutput: ContentBlock | null = log_lines.length === 0 ? null diff --git a/packages/mcp-server/src/docs-search-tool.ts b/packages/mcp-server/src/docs-search-tool.ts index 25c9c7ea..8e9ff4e6 100644 --- a/packages/mcp-server/src/docs-search-tool.ts +++ b/packages/mcp-server/src/docs-search-tool.ts @@ -14,8 +14,7 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'search_docs', - description: - 'Search SDK documentation to find methods, parameters, and usage examples for interacting with the API. Use this before writing code when you need to discover the right approach.', + description: 'Search SDK documentation to find methods, parameters, and usage examples for interacting with the API. Use this before writing code when you need to discover the right approach.', inputSchema: { type: 'object', properties: { @@ -32,7 +31,7 @@ export const tool: Tool = { type: 'string', description: 'The amount of detail to return.', enum: ['default', 'verbose'], - }, + } }, required: ['query', 'language'], }, @@ -41,8 +40,7 @@ export const tool: Tool = { }, }; -const docsSearchURL = - process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/imagekit/docs/search'; +const docsSearchURL = process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/imagekit/docs/search' let _localSearch: LocalDocsSearch | undefined; @@ -67,27 +65,30 @@ async function searchLocal(args: Record): Promise { }).results; } -async function searchRemote(args: Record, reqContext: McpRequestContext): Promise { +async function searchRemote( + args: Record, + reqContext: McpRequestContext, +): Promise { const body = args as any; const query = new URLSearchParams(body).toString(); const startTime = Date.now(); - const result = await fetch(`${docsSearchURL}?${query}`, { - headers: { - ...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }), - ...(reqContext.mcpSessionId && { 'x-stainless-mcp-session-id': reqContext.mcpSessionId }), - ...(reqContext.mcpClientInfo && { - 'x-stainless-mcp-client-info': JSON.stringify(reqContext.mcpClientInfo), - }), + const result = await fetch( + `${docsSearchURL}?${query}`, + { + headers: { + ...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }), + ...(reqContext.mcpSessionId && { 'x-stainless-mcp-session-id': reqContext.mcpSessionId }), + ...(reqContext.mcpClientInfo && { 'x-stainless-mcp-client-info': JSON.stringify(reqContext.mcpClientInfo) }), + }, }, - }); + ); const logger = getLogger(); if (!result.ok) { const errorText = await result.text(); - logger.warn( - { + logger.warn({ durationMs: Date.now() - startTime, query: body.query, status: result.status, @@ -98,19 +99,14 @@ async function searchRemote(args: Record, reqContext: McpReques ); if (result.status === 404 && !reqContext.stainlessApiKey) { - throw new Error( - 'Could not find docs for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.', - ); + throw new Error('Could not find docs for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.'); } - throw new Error( - `${result.status}: ${result.statusText} when using doc search tool. Details: ${errorText}`, - ); + throw new Error(`${result.status}: ${result.statusText} when using doc search tool. Details: ${errorText}`); } const resultBody = await result.json(); - logger.info( - { + logger.info({ durationMs: Date.now() - startTime, query: body.query, }, @@ -119,13 +115,10 @@ async function searchRemote(args: Record, reqContext: McpReques return resultBody; } -export const handler = async ({ - reqContext, - args, -}: { - reqContext: McpRequestContext; - args: Record | undefined; -}) => { +export const handler = async ( + { reqContext, args }: + { reqContext: McpRequestContext; args: Record | undefined }, +) => { const body = args ?? {}; if (_localSearch) { diff --git a/packages/mcp-server/src/http.ts b/packages/mcp-server/src/http.ts index 08c31bed..f1db5047 100644 --- a/packages/mcp-server/src/http.ts +++ b/packages/mcp-server/src/http.ts @@ -1,7 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { McpServer } from '@modelcontextprotocol/sdk/server/mcp'; -import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'; +import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js' import { ClientOptions } from '@imagekit/nodejs'; import express from 'express'; import pino from 'pino'; @@ -24,7 +24,7 @@ const newServer = async ({ }): Promise => { const stainlessApiKey = getStainlessApiKey(req, mcpOptions); const customInstructionsPath = mcpOptions.customInstructionsPath; - const server = await newMcpServer({ stainlessApiKey, customInstructionsPath }); + const server = await newMcpServer({stainlessApiKey, customInstructionsPath}); const authOptions = parseClientAuthHeaders(req, false); @@ -65,13 +65,15 @@ const newServer = async ({ ); } } catch (error) { - getLogger().warn({ error }, 'Failed to parse x-stainless-mcp-client-permissions header'); + getLogger().warn( + { error }, + 'Failed to parse x-stainless-mcp-client-permissions header', + ); } } - const mcpClientInfo = - typeof req.body?.params?.clientInfo?.name === 'string' ? - { name: req.body.params.clientInfo.name, version: String(req.body.params.clientInfo.version ?? '') } + const mcpClientInfo = typeof req.body?.params?.clientInfo?.name === 'string' + ? { name: req.body.params.clientInfo.name, version: String(req.body.params.clientInfo.version ?? '') } : undefined; await initMcpServer({ @@ -88,7 +90,10 @@ const newServer = async ({ }); if (mcpClientInfo) { - getLogger().info({ mcpSessionId: (req as any).mcpSessionId, mcpClientInfo }, 'MCP client connected'); + getLogger().info( + { mcpSessionId: (req as any).mcpSessionId, mcpClientInfo }, + 'MCP client connected', + ); } return server; @@ -128,7 +133,7 @@ const del = async (req: express.Request, res: express.Response) => { const redactHeaders = (headers: Record) => { const hiddenHeaders = /auth|cookie|key|token|x-stainless-mcp-client-envs/i; const filtered = { ...headers }; - Object.keys(filtered).forEach((key) => { + Object.keys(filtered).forEach(key => { if (hiddenHeaders.test(key)) { filtered[key] = '[REDACTED]'; } @@ -181,17 +186,17 @@ export const streamableHTTPApp = ({ req: pino.stdSerializers.wrapRequestSerializer((req) => { return { ...req, - headers: redactHeaders(req.raw.headers), + headers: redactHeaders(req.raw.headers) }; }), res: pino.stdSerializers.wrapResponseSerializer((res) => { return { ...res, - headers: redactHeaders(res.headers), + headers: redactHeaders(res.headers) }; }), - }, - }), + } + }) ); app.get('/health', async (req: express.Request, res: express.Response) => { @@ -204,24 +209,23 @@ export const streamableHTTPApp = ({ return app; }; -export const launchStreamableHTTPServer = async ({ - mcpOptions, - port, -}: { - mcpOptions: McpOptions; - port: number | string | undefined; -}) => { - const app = streamableHTTPApp({ mcpOptions }); - const server = app.listen(port); - const address = server.address(); - - const logger = getLogger(); - - if (typeof address === 'string') { - logger.info(`MCP Server running on streamable HTTP at ${address}`); - } else if (address !== null) { - logger.info(`MCP Server running on streamable HTTP on port ${address.port}`); - } else { - logger.info(`MCP Server running on streamable HTTP on port ${port}`); +export const launchStreamableHTTPServer = async( + {mcpOptions, port}: { + mcpOptions: McpOptions, + port: number | string | undefined, + } +) => { + const app = streamableHTTPApp({ mcpOptions }); + const server = app.listen(port); + const address = server.address(); + + const logger = getLogger(); + + if (typeof address === 'string') { + logger.info(`MCP Server running on streamable HTTP at ${address}`); + } else if (address !== null) { + logger.info(`MCP Server running on streamable HTTP on port ${address.port}`); + } else { + logger.info(`MCP Server running on streamable HTTP on port ${port}`); + } } -}; diff --git a/packages/mcp-server/src/index.ts b/packages/mcp-server/src/index.ts index 5bca4a60..6306dc26 100644 --- a/packages/mcp-server/src/index.ts +++ b/packages/mcp-server/src/index.ts @@ -17,7 +17,7 @@ async function main() { const selectedTools = await selectToolsOrError(options); getLogger().info( - { tools: selectedTools.map((e) => e.tool.name) }, + {tools: selectedTools.map((e) => e.tool.name)}, `MCP Server starting with ${selectedTools.length} tools`, ); diff --git a/packages/mcp-server/src/instructions.ts b/packages/mcp-server/src/instructions.ts index ffe655a0..523a7b5d 100644 --- a/packages/mcp-server/src/instructions.ts +++ b/packages/mcp-server/src/instructions.ts @@ -60,24 +60,24 @@ async function fetchLatestInstructionsFromApi(stainlessApiKey: string | undefine // Setting the stainless API key is optional, but may be required // to authenticate requests to the Stainless API. const response = await fetch( - readEnv('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/imagekit', + readEnv("CODE_MODE_INSTRUCTIONS_URL") ?? + 'https://api.stainless.com/api/ai/instructions/imagekit', { - method: 'GET', - headers: { ...(stainlessApiKey && { Authorization: stainlessApiKey }) }, - }, - ); + method: "GET", + headers: { ...( stainlessApiKey && { Authorization: stainlessApiKey } ) } + } + ) let instructions: string | undefined; if (!response.ok) { getLogger().warn( - 'Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...', - ); + "Warning: failed to retrieve MCP server instructions. Proceeding with default instructions..." + ) - instructions = - '\n This is the imagekit MCP server.\n\n Available tools:\n - search_docs: Search SDK documentation to find the right methods and parameters.\n - execute: Run TypeScript code against a pre-authenticated SDK client. Define an async run(client) function.\n\n Workflow:\n - If unsure about the API, call search_docs first.\n - Write complete solutions in a single execute call when possible. For large datasets, use API filters to narrow results or paginate within a single execute block.\n - If execute returns an error, read the error and fix your code rather than retrying the same approach.\n - Variables do not persist between execute calls. Return or log all data you need.\n - Individual HTTP requests to the API have a 30-second timeout. If a request times out, try a smaller query or add filters.\n - Code execution has a total timeout of approximately 5 minutes. If your code times out, simplify it or break it into smaller steps.\n '; + instructions = "\n This is the imagekit MCP server.\n\n Available tools:\n - search_docs: Search SDK documentation to find the right methods and parameters.\n - execute: Run TypeScript code against a pre-authenticated SDK client. Define an async run(client) function.\n\n Workflow:\n - If unsure about the API, call search_docs first.\n - Write complete solutions in a single execute call when possible. For large datasets, use API filters to narrow results or paginate within a single execute block.\n - If execute returns an error, read the error and fix your code rather than retrying the same approach.\n - Variables do not persist between execute calls. Return or log all data you need.\n - Individual HTTP requests to the API have a 30-second timeout. If a request times out, try a smaller query or add filters.\n - Code execution has a total timeout of approximately 5 minutes. If your code times out, simplify it or break it into smaller steps.\n "; } - instructions ??= ((await response.json()) as { instructions: string }).instructions; + instructions ??= (await response.json() as { instructions: string }).instructions; return instructions; } diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 828a0523..1df6d6ad 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -51,3305 +51,2787 @@ type SearchResult = { const EMBEDDED_METHODS: MethodEntry[] = [ { - name: 'create', - endpoint: '/v1/customMetadataFields', - httpMethod: 'post', - summary: 'Create new field', - description: - 'This API creates a new custom metadata field. Once a custom metadata field is created either through this API or using the dashboard UI, its value can be set on the assets. The value of a field for an asset can be set using the media library UI or programmatically through upload or update assets API.\n', - stainlessPath: '(resource) customMetadataFields > (method) create', - qualified: 'client.customMetadataFields.create', - params: [ - 'label: string;', - 'name: string;', - "schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; };", + "name": "create", + "endpoint": "/v1/customMetadataFields", + "httpMethod": "post", + "summary": "Create new field", + "description": "This API creates a new custom metadata field. Once a custom metadata field is created either through this API or using the dashboard UI, its value can be set on the assets. The value of a field for an asset can be set using the media library UI or programmatically through upload or update assets API.\n", + "stainlessPath": "(resource) customMetadataFields > (method) create", + "qualified": "client.customMetadataFields.create", + "params": [ + "label: string;", + "name: string;", + "schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; };" ], - response: - "{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }", - markdown: - "## create\n\n`client.customMetadataFields.create(label: string, name: string, schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }): { id: string; label: string; name: string; schema: object; }`\n\n**post** `/v1/customMetadataFields`\n\nThis API creates a new custom metadata field. Once a custom metadata field is created either through this API or using the dashboard UI, its value can be set on the assets. The value of a field for an asset can be set using the media library UI or programmatically through upload or update assets API.\n\n\n### Parameters\n\n- `label: string`\n Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI.\n\n- `name: string`\n API name of the custom metadata field. This should be unique across all (including deleted) custom metadata fields.\n\n- `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n - `type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'`\n Type of the custom metadata field.\n - `defaultValue?: string | number | boolean | string | number | boolean[]`\n The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field.\n\n - `isValueRequired?: boolean`\n Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body.\n\n - `maxLength?: number`\n Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `maxValue?: string | number`\n Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `minLength?: number`\n Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `minValue?: string | number`\n Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `selectOptions?: string | number | boolean[]`\n An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }`\n Object containing details of a custom metadata field.\n\n - `id: string`\n - `label: string`\n - `name: string`\n - `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.create({\n label: 'price',\n name: 'price',\n schema: { type: 'Number' },\n});\n\nconsole.log(customMetadataField);\n```", - perLanguage: { - typescript: { - method: 'client.customMetadataFields.create', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.create({\n label: 'price',\n name: 'price',\n schema: {\n type: 'Number',\n minValue: 1000,\n maxValue: 3000,\n },\n});\n\nconsole.log(customMetadataField.id);", - }, - python: { - method: 'custom_metadata_fields.create', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.create(\n label="price",\n name="price",\n schema={\n "type": "Number",\n "min_value": 1000,\n "max_value": 3000,\n },\n)\nprint(custom_metadata_field.id)', - }, - java: { - method: 'customMetadataFields().create', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build();\n CustomMetadataField customMetadataField = client.customMetadataFields().create(params);\n }\n}', - }, - kotlin: { - method: 'customMetadataFields().create', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: CustomMetadataFieldCreateParams = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build()\n val customMetadataField: CustomMetadataField = client.customMetadataFields().create(params)\n}', - }, - go: { - method: 'client.CustomMetadataFields.New', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.New(context.TODO(), imagekit.CustomMetadataFieldNewParams{\n\t\tLabel: "price",\n\t\tName: "price",\n\t\tSchema: imagekit.CustomMetadataFieldNewParamsSchema{\n\t\t\tType: "Number",\n\t\t\tMinValue: imagekit.CustomMetadataFieldNewParamsSchemaMinValueUnion{\n\t\t\t\tOfFloat: imagekit.Float(1000),\n\t\t\t},\n\t\t\tMaxValue: imagekit.CustomMetadataFieldNewParamsSchemaMaxValueUnion{\n\t\t\t\tOfFloat: imagekit.Float(3000),\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataField.ID)\n}\n', - }, - ruby: { - method: 'custom_metadata_fields.create', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.create(label: "price", name: "price", schema: {type: :Number})\n\nputs(custom_metadata_field)', - }, - cli: { - method: 'customMetadataFields create', - example: - "imagekit custom-metadata-fields create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --label price \\\n --name price \\\n --schema '{type: Number}'", - }, - php: { - method: 'customMetadataFields->create', - example: - "customMetadataFields->create(\n label: 'price',\n name: 'price',\n schema: [\n 'type' => 'Number',\n 'defaultValue' => [true, 10, 'Hello'],\n 'isValueRequired' => true,\n 'maxLength' => 0,\n 'maxValue' => 3000,\n 'minLength' => 0,\n 'minValue' => 1000,\n 'selectOptions' => ['small', 'medium', 'large', 30, 40, true],\n ],\n);\n\nvar_dump($customMetadataField);", - }, - csharp: { - method: 'CustomMetadataFields.Create', - example: - 'CustomMetadataFieldCreateParams parameters = new()\n{\n Label = "price",\n Name = "price",\n Schema = new()\n {\n Type = Type.Number,\n DefaultValue = new(\n\n [\n new DefaultValueItem(true),\n new DefaultValueItem(10),\n new DefaultValueItem("Hello"),\n ]\n ),\n IsValueRequired = true,\n MaxLength = 0,\n MaxValue = 3000,\n MinLength = 0,\n MinValue = 1000,\n SelectOptions =\n [\n "small", "medium", "large", 30, 40, true\n ],\n },\n};\n\nvar customMetadataField = await client.CustomMetadataFields.Create(parameters);\n\nConsole.WriteLine(customMetadataField);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/customMetadataFields \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "label": "price",\n "name": "price",\n "schema": {\n "type": "Number",\n "maxValue": 3000,\n "minValue": 1000\n }\n }\'', - }, - }, + "response": "{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }", + "markdown": "## create\n\n`client.customMetadataFields.create(label: string, name: string, schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }): { id: string; label: string; name: string; schema: object; }`\n\n**post** `/v1/customMetadataFields`\n\nThis API creates a new custom metadata field. Once a custom metadata field is created either through this API or using the dashboard UI, its value can be set on the assets. The value of a field for an asset can be set using the media library UI or programmatically through upload or update assets API.\n\n\n### Parameters\n\n- `label: string`\n Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI.\n\n- `name: string`\n API name of the custom metadata field. This should be unique across all (including deleted) custom metadata fields.\n\n- `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n - `type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'`\n Type of the custom metadata field.\n - `defaultValue?: string | number | boolean | string | number | boolean[]`\n The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field.\n\n - `isValueRequired?: boolean`\n Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body.\n\n - `maxLength?: number`\n Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `maxValue?: string | number`\n Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `minLength?: number`\n Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `minValue?: string | number`\n Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `selectOptions?: string | number | boolean[]`\n An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }`\n Object containing details of a custom metadata field.\n\n - `id: string`\n - `label: string`\n - `name: string`\n - `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.create({\n label: 'price',\n name: 'price',\n schema: { type: 'Number' },\n});\n\nconsole.log(customMetadataField);\n```", + "perLanguage": { + "typescript": { + "method": "client.customMetadataFields.create", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.create({\n label: 'price',\n name: 'price',\n schema: {\n type: 'Number',\n minValue: 1000,\n maxValue: 3000,\n },\n});\n\nconsole.log(customMetadataField.id);" + }, + "python": { + "method": "custom_metadata_fields.create", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.create(\n label=\"price\",\n name=\"price\",\n schema={\n \"type\": \"Number\",\n \"min_value\": 1000,\n \"max_value\": 3000,\n },\n)\nprint(custom_metadata_field.id)" + }, + "java": { + "method": "customMetadataFields().create", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder()\n .label(\"price\")\n .name(\"price\")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build();\n CustomMetadataField customMetadataField = client.customMetadataFields().create(params);\n }\n}" + }, + "kotlin": { + "method": "customMetadataFields().create", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: CustomMetadataFieldCreateParams = CustomMetadataFieldCreateParams.builder()\n .label(\"price\")\n .name(\"price\")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build()\n val customMetadataField: CustomMetadataField = client.customMetadataFields().create(params)\n}" + }, + "go": { + "method": "client.CustomMetadataFields.New", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.New(context.TODO(), imagekit.CustomMetadataFieldNewParams{\n\t\tLabel: \"price\",\n\t\tName: \"price\",\n\t\tSchema: imagekit.CustomMetadataFieldNewParamsSchema{\n\t\t\tType: \"Number\",\n\t\t\tMinValue: imagekit.CustomMetadataFieldNewParamsSchemaMinValueUnion{\n\t\t\t\tOfFloat: imagekit.Float(1000),\n\t\t\t},\n\t\t\tMaxValue: imagekit.CustomMetadataFieldNewParamsSchemaMaxValueUnion{\n\t\t\t\tOfFloat: imagekit.Float(3000),\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", customMetadataField.ID)\n}\n" + }, + "ruby": { + "method": "custom_metadata_fields.create", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.create(label: \"price\", name: \"price\", schema: {type: :Number})\n\nputs(custom_metadata_field)" + }, + "cli": { + "method": "customMetadataFields create", + "example": "imagekit custom-metadata-fields create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --label price \\\n --name price \\\n --schema '{type: Number}'" + }, + "php": { + "method": "customMetadataFields->create", + "example": "customMetadataFields->create(\n label: 'price',\n name: 'price',\n schema: [\n 'type' => 'Number',\n 'defaultValue' => [true, 10, 'Hello'],\n 'isValueRequired' => true,\n 'maxLength' => 0,\n 'maxValue' => 3000,\n 'minLength' => 0,\n 'minValue' => 1000,\n 'selectOptions' => ['small', 'medium', 'large', 30, 40, true],\n ],\n);\n\nvar_dump($customMetadataField);" + }, + "csharp": { + "method": "CustomMetadataFields.Create", + "example": "CustomMetadataFieldCreateParams parameters = new()\n{\n Label = \"price\",\n Name = \"price\",\n Schema = new()\n {\n Type = Type.Number,\n DefaultValue = new(\n\n [\n new DefaultValueItem(true),\n new DefaultValueItem(10),\n new DefaultValueItem(\"Hello\"),\n ]\n ),\n IsValueRequired = true,\n MaxLength = 0,\n MaxValue = 3000,\n MinLength = 0,\n MinValue = 1000,\n SelectOptions =\n [\n \"small\", \"medium\", \"large\", 30, 40, true\n ],\n },\n};\n\nvar customMetadataField = await client.CustomMetadataFields.Create(parameters);\n\nConsole.WriteLine(customMetadataField);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/customMetadataFields \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"label\": \"price\",\n \"name\": \"price\",\n \"schema\": {\n \"type\": \"Number\",\n \"maxValue\": 3000,\n \"minValue\": 1000\n }\n }'" + } + } }, { - name: 'list', - endpoint: '/v1/customMetadataFields', - httpMethod: 'get', - summary: 'List all fields', - description: - 'This API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response.\n\nYou can also filter results by a specific folder path to retrieve custom metadata fields applicable at that location. This path-specific filtering is useful when using the **Path policy** feature to determine which custom metadata fields are selected for a given path.\n', - stainlessPath: '(resource) customMetadataFields > (method) list', - qualified: 'client.customMetadataFields.list', - params: ['folderPath?: string;', 'includeDeleted?: boolean;'], - response: - "{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }[]", - markdown: - "## list\n\n`client.customMetadataFields.list(folderPath?: string, includeDeleted?: boolean): object[]`\n\n**get** `/v1/customMetadataFields`\n\nThis API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response.\n\nYou can also filter results by a specific folder path to retrieve custom metadata fields applicable at that location. This path-specific filtering is useful when using the **Path policy** feature to determine which custom metadata fields are selected for a given path.\n\n\n### Parameters\n\n- `folderPath?: string`\n The folder path (e.g., `/path/to/folder`) for which to retrieve applicable custom metadata fields. Useful for determining path-specific field selections when the [Path policy](https://imagekit.io/docs/dam/path-policy) feature is in use.\n\n\n- `includeDeleted?: boolean`\n Set it to `true` to include deleted field objects in the API response.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataFields = await client.customMetadataFields.list();\n\nconsole.log(customMetadataFields);\n```", - perLanguage: { - typescript: { - method: 'client.customMetadataFields.list', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataFields = await client.customMetadataFields.list();\n\nconsole.log(customMetadataFields);", - }, - python: { - method: 'custom_metadata_fields.list', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_fields = client.custom_metadata_fields.list()\nprint(custom_metadata_fields)', - }, - java: { - method: 'customMetadataFields().list', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List customMetadataFields = client.customMetadataFields().list();\n }\n}', - }, - kotlin: { - method: 'customMetadataFields().list', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataFields: List = client.customMetadataFields().list()\n}', - }, - go: { - method: 'client.CustomMetadataFields.List', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataFields, err := client.CustomMetadataFields.List(context.TODO(), imagekit.CustomMetadataFieldListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataFields)\n}\n', - }, - ruby: { - method: 'custom_metadata_fields.list', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ncustom_metadata_fields = image_kit.custom_metadata_fields.list\n\nputs(custom_metadata_fields)', - }, - cli: { - method: 'customMetadataFields list', - example: - "imagekit custom-metadata-fields list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - php: { - method: 'customMetadataFields->list', - example: - "customMetadataFields->list(\n folderPath: 'folderPath', includeDeleted: true\n);\n\nvar_dump($customMetadataFields);", - }, - csharp: { - method: 'CustomMetadataFields.List', - example: - 'CustomMetadataFieldListParams parameters = new();\n\nvar customMetadataFields = await client.CustomMetadataFields.List(parameters);\n\nConsole.WriteLine(customMetadataFields);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/customMetadataFields \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "list", + "endpoint": "/v1/customMetadataFields", + "httpMethod": "get", + "summary": "List all fields", + "description": "This API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response.\n\nYou can also filter results by a specific folder path to retrieve custom metadata fields applicable at that location. This path-specific filtering is useful when using the **Path policy** feature to determine which custom metadata fields are selected for a given path.\n", + "stainlessPath": "(resource) customMetadataFields > (method) list", + "qualified": "client.customMetadataFields.list", + "params": [ + "folderPath?: string;", + "includeDeleted?: boolean;" + ], + "response": "{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }[]", + "markdown": "## list\n\n`client.customMetadataFields.list(folderPath?: string, includeDeleted?: boolean): object[]`\n\n**get** `/v1/customMetadataFields`\n\nThis API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response.\n\nYou can also filter results by a specific folder path to retrieve custom metadata fields applicable at that location. This path-specific filtering is useful when using the **Path policy** feature to determine which custom metadata fields are selected for a given path.\n\n\n### Parameters\n\n- `folderPath?: string`\n The folder path (e.g., `/path/to/folder`) for which to retrieve applicable custom metadata fields. Useful for determining path-specific field selections when the [Path policy](https://imagekit.io/docs/dam/path-policy) feature is in use.\n\n\n- `includeDeleted?: boolean`\n Set it to `true` to include deleted field objects in the API response.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataFields = await client.customMetadataFields.list();\n\nconsole.log(customMetadataFields);\n```", + "perLanguage": { + "typescript": { + "method": "client.customMetadataFields.list", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataFields = await client.customMetadataFields.list();\n\nconsole.log(customMetadataFields);" + }, + "python": { + "method": "custom_metadata_fields.list", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\ncustom_metadata_fields = client.custom_metadata_fields.list()\nprint(custom_metadata_fields)" + }, + "java": { + "method": "customMetadataFields().list", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List customMetadataFields = client.customMetadataFields().list();\n }\n}" + }, + "kotlin": { + "method": "customMetadataFields().list", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataFields: List = client.customMetadataFields().list()\n}" + }, + "go": { + "method": "client.CustomMetadataFields.List", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tcustomMetadataFields, err := client.CustomMetadataFields.List(context.TODO(), imagekit.CustomMetadataFieldListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", customMetadataFields)\n}\n" + }, + "ruby": { + "method": "custom_metadata_fields.list", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\ncustom_metadata_fields = image_kit.custom_metadata_fields.list\n\nputs(custom_metadata_fields)" + }, + "cli": { + "method": "customMetadataFields list", + "example": "imagekit custom-metadata-fields list \\\n --private-key 'My Private Key' \\\n --password 'My Password'" + }, + "php": { + "method": "customMetadataFields->list", + "example": "customMetadataFields->list(\n folderPath: 'folderPath', includeDeleted: true\n);\n\nvar_dump($customMetadataFields);" + }, + "csharp": { + "method": "CustomMetadataFields.List", + "example": "CustomMetadataFieldListParams parameters = new();\n\nvar customMetadataFields = await client.CustomMetadataFields.List(parameters);\n\nConsole.WriteLine(customMetadataFields);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/customMetadataFields \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'update', - endpoint: '/v1/customMetadataFields/{id}', - httpMethod: 'patch', - summary: 'Update existing field', - description: 'This API updates the label or schema of an existing custom metadata field.\n', - stainlessPath: '(resource) customMetadataFields > (method) update', - qualified: 'client.customMetadataFields.update', - params: [ - 'id: string;', - 'label?: string;', - 'schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; };', + "name": "update", + "endpoint": "/v1/customMetadataFields/{id}", + "httpMethod": "patch", + "summary": "Update existing field", + "description": "This API updates the label or schema of an existing custom metadata field.\n", + "stainlessPath": "(resource) customMetadataFields > (method) update", + "qualified": "client.customMetadataFields.update", + "params": [ + "id: string;", + "label?: string;", + "schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; };" ], - response: - "{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }", - markdown: - "## update\n\n`client.customMetadataFields.update(id: string, label?: string, schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }): { id: string; label: string; name: string; schema: object; }`\n\n**patch** `/v1/customMetadataFields/{id}`\n\nThis API updates the label or schema of an existing custom metadata field.\n\n\n### Parameters\n\n- `id: string`\n\n- `label?: string`\n Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI. This parameter is required if `schema` is not provided.\n\n- `schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n An object that describes the rules for the custom metadata key. This parameter is required if `label` is not provided. Note: `type` cannot be updated and will be ignored if sent with the `schema`. The schema will be validated as per the existing `type`.\n\n - `defaultValue?: string | number | boolean | string | number | boolean[]`\n The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field.\n\n - `isValueRequired?: boolean`\n Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body.\n\n - `maxLength?: number`\n Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `maxValue?: string | number`\n Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `minLength?: number`\n Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `minValue?: string | number`\n Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `selectOptions?: string | number | boolean[]`\n An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }`\n Object containing details of a custom metadata field.\n\n - `id: string`\n - `label: string`\n - `name: string`\n - `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.update('id');\n\nconsole.log(customMetadataField);\n```", - perLanguage: { - typescript: { - method: 'client.customMetadataFields.update', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.update('id', {\n label: 'price',\n schema: { minValue: 1000, maxValue: 3000 },\n});\n\nconsole.log(customMetadataField.id);", - }, - python: { - method: 'custom_metadata_fields.update', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.update(\n id="id",\n label="price",\n schema={\n "min_value": 1000,\n "max_value": 3000,\n },\n)\nprint(custom_metadata_field.id)', - }, - java: { - method: 'customMetadataFields().update', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataField customMetadataField = client.customMetadataFields().update("id");\n }\n}', - }, - kotlin: { - method: 'customMetadataFields().update', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataField: CustomMetadataField = client.customMetadataFields().update("id")\n}', - }, - go: { - method: 'client.CustomMetadataFields.Update', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.CustomMetadataFieldUpdateParams{\n\t\t\tLabel: imagekit.String("price"),\n\t\t\tSchema: imagekit.CustomMetadataFieldUpdateParamsSchema{\n\t\t\t\tMinValue: imagekit.CustomMetadataFieldUpdateParamsSchemaMinValueUnion{\n\t\t\t\t\tOfFloat: imagekit.Float(1000),\n\t\t\t\t},\n\t\t\t\tMaxValue: imagekit.CustomMetadataFieldUpdateParamsSchemaMaxValueUnion{\n\t\t\t\t\tOfFloat: imagekit.Float(3000),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataField.ID)\n}\n', - }, - ruby: { - method: 'custom_metadata_fields.update', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.update("id")\n\nputs(custom_metadata_field)', - }, - cli: { - method: 'customMetadataFields update', - example: - "imagekit custom-metadata-fields update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - php: { - method: 'customMetadataFields->update', - example: - "customMetadataFields->update(\n 'id',\n label: 'price',\n schema: [\n 'defaultValue' => [true, 10, 'Hello'],\n 'isValueRequired' => true,\n 'maxLength' => 0,\n 'maxValue' => 3000,\n 'minLength' => 0,\n 'minValue' => 1000,\n 'selectOptions' => ['small', 'medium', 'large', 30, 40, true],\n ],\n);\n\nvar_dump($customMetadataField);", - }, - csharp: { - method: 'CustomMetadataFields.Update', - example: - 'CustomMetadataFieldUpdateParams parameters = new() { ID = "id" };\n\nvar customMetadataField = await client.CustomMetadataFields.Update(parameters);\n\nConsole.WriteLine(customMetadataField);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/customMetadataFields/$ID \\\n -X PATCH \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "response": "{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }", + "markdown": "## update\n\n`client.customMetadataFields.update(id: string, label?: string, schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }): { id: string; label: string; name: string; schema: object; }`\n\n**patch** `/v1/customMetadataFields/{id}`\n\nThis API updates the label or schema of an existing custom metadata field.\n\n\n### Parameters\n\n- `id: string`\n\n- `label?: string`\n Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI. This parameter is required if `schema` is not provided.\n\n- `schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n An object that describes the rules for the custom metadata key. This parameter is required if `label` is not provided. Note: `type` cannot be updated and will be ignored if sent with the `schema`. The schema will be validated as per the existing `type`.\n\n - `defaultValue?: string | number | boolean | string | number | boolean[]`\n The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field.\n\n - `isValueRequired?: boolean`\n Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body.\n\n - `maxLength?: number`\n Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `maxValue?: string | number`\n Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `minLength?: number`\n Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `minValue?: string | number`\n Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `selectOptions?: string | number | boolean[]`\n An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }`\n Object containing details of a custom metadata field.\n\n - `id: string`\n - `label: string`\n - `name: string`\n - `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.update('id');\n\nconsole.log(customMetadataField);\n```", + "perLanguage": { + "typescript": { + "method": "client.customMetadataFields.update", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.update('id', {\n label: 'price',\n schema: { minValue: 1000, maxValue: 3000 },\n});\n\nconsole.log(customMetadataField.id);" + }, + "python": { + "method": "custom_metadata_fields.update", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.update(\n id=\"id\",\n label=\"price\",\n schema={\n \"min_value\": 1000,\n \"max_value\": 3000,\n },\n)\nprint(custom_metadata_field.id)" + }, + "java": { + "method": "customMetadataFields().update", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataField customMetadataField = client.customMetadataFields().update(\"id\");\n }\n}" + }, + "kotlin": { + "method": "customMetadataFields().update", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataField: CustomMetadataField = client.customMetadataFields().update(\"id\")\n}" + }, + "go": { + "method": "client.CustomMetadataFields.Update", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.Update(\n\t\tcontext.TODO(),\n\t\t\"id\",\n\t\timagekit.CustomMetadataFieldUpdateParams{\n\t\t\tLabel: imagekit.String(\"price\"),\n\t\t\tSchema: imagekit.CustomMetadataFieldUpdateParamsSchema{\n\t\t\t\tMinValue: imagekit.CustomMetadataFieldUpdateParamsSchemaMinValueUnion{\n\t\t\t\t\tOfFloat: imagekit.Float(1000),\n\t\t\t\t},\n\t\t\t\tMaxValue: imagekit.CustomMetadataFieldUpdateParamsSchemaMaxValueUnion{\n\t\t\t\t\tOfFloat: imagekit.Float(3000),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", customMetadataField.ID)\n}\n" + }, + "ruby": { + "method": "custom_metadata_fields.update", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.update(\"id\")\n\nputs(custom_metadata_field)" + }, + "cli": { + "method": "customMetadataFields update", + "example": "imagekit custom-metadata-fields update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" + }, + "php": { + "method": "customMetadataFields->update", + "example": "customMetadataFields->update(\n 'id',\n label: 'price',\n schema: [\n 'defaultValue' => [true, 10, 'Hello'],\n 'isValueRequired' => true,\n 'maxLength' => 0,\n 'maxValue' => 3000,\n 'minLength' => 0,\n 'minValue' => 1000,\n 'selectOptions' => ['small', 'medium', 'large', 30, 40, true],\n ],\n);\n\nvar_dump($customMetadataField);" + }, + "csharp": { + "method": "CustomMetadataFields.Update", + "example": "CustomMetadataFieldUpdateParams parameters = new() { ID = \"id\" };\n\nvar customMetadataField = await client.CustomMetadataFields.Update(parameters);\n\nConsole.WriteLine(customMetadataField);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/customMetadataFields/$ID \\\n -X PATCH \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'delete', - endpoint: '/v1/customMetadataFields/{id}', - httpMethod: 'delete', - summary: 'Delete a field', - description: - 'This API deletes a custom metadata field. Even after deleting a custom metadata field, you cannot create any new custom metadata field with the same name.\n', - stainlessPath: '(resource) customMetadataFields > (method) delete', - qualified: 'client.customMetadataFields.delete', - params: ['id: string;'], - response: '{ }', - markdown: - "## delete\n\n`client.customMetadataFields.delete(id: string): { }`\n\n**delete** `/v1/customMetadataFields/{id}`\n\nThis API deletes a custom metadata field. Even after deleting a custom metadata field, you cannot create any new custom metadata field with the same name.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.delete('id');\n\nconsole.log(customMetadataField);\n```", - perLanguage: { - typescript: { - method: 'client.customMetadataFields.delete', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.delete('id');\n\nconsole.log(customMetadataField);", - }, - python: { - method: 'custom_metadata_fields.delete', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.delete(\n "id",\n)\nprint(custom_metadata_field)', - }, - java: { - method: 'customMetadataFields().delete', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteParams;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldDeleteResponse customMetadataField = client.customMetadataFields().delete("id");\n }\n}', - }, - kotlin: { - method: 'customMetadataFields().delete', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataField: CustomMetadataFieldDeleteResponse = client.customMetadataFields().delete("id")\n}', - }, - go: { - method: 'client.CustomMetadataFields.Delete', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataField)\n}\n', - }, - ruby: { - method: 'custom_metadata_fields.delete', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.delete("id")\n\nputs(custom_metadata_field)', - }, - cli: { - method: 'customMetadataFields delete', - example: - "imagekit custom-metadata-fields delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - php: { - method: 'customMetadataFields->delete', - example: - "customMetadataFields->delete('id');\n\nvar_dump($customMetadataField);", - }, - csharp: { - method: 'CustomMetadataFields.Delete', - example: - 'CustomMetadataFieldDeleteParams parameters = new() { ID = "id" };\n\nvar customMetadataField = await client.CustomMetadataFields.Delete(parameters);\n\nConsole.WriteLine(customMetadataField);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/customMetadataFields/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "delete", + "endpoint": "/v1/customMetadataFields/{id}", + "httpMethod": "delete", + "summary": "Delete a field", + "description": "This API deletes a custom metadata field. Even after deleting a custom metadata field, you cannot create any new custom metadata field with the same name.\n", + "stainlessPath": "(resource) customMetadataFields > (method) delete", + "qualified": "client.customMetadataFields.delete", + "params": [ + "id: string;" + ], + "response": "{ }", + "markdown": "## delete\n\n`client.customMetadataFields.delete(id: string): { }`\n\n**delete** `/v1/customMetadataFields/{id}`\n\nThis API deletes a custom metadata field. Even after deleting a custom metadata field, you cannot create any new custom metadata field with the same name.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.delete('id');\n\nconsole.log(customMetadataField);\n```", + "perLanguage": { + "typescript": { + "method": "client.customMetadataFields.delete", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.delete('id');\n\nconsole.log(customMetadataField);" + }, + "python": { + "method": "custom_metadata_fields.delete", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.delete(\n \"id\",\n)\nprint(custom_metadata_field)" + }, + "java": { + "method": "customMetadataFields().delete", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteParams;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldDeleteResponse customMetadataField = client.customMetadataFields().delete(\"id\");\n }\n}" + }, + "kotlin": { + "method": "customMetadataFields().delete", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataField: CustomMetadataFieldDeleteResponse = client.customMetadataFields().delete(\"id\")\n}" + }, + "go": { + "method": "client.CustomMetadataFields.Delete", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.Delete(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", customMetadataField)\n}\n" + }, + "ruby": { + "method": "custom_metadata_fields.delete", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.delete(\"id\")\n\nputs(custom_metadata_field)" + }, + "cli": { + "method": "customMetadataFields delete", + "example": "imagekit custom-metadata-fields delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" + }, + "php": { + "method": "customMetadataFields->delete", + "example": "customMetadataFields->delete('id');\n\nvar_dump($customMetadataField);" + }, + "csharp": { + "method": "CustomMetadataFields.Delete", + "example": "CustomMetadataFieldDeleteParams parameters = new() { ID = \"id\" };\n\nvar customMetadataField = await client.CustomMetadataFields.Delete(parameters);\n\nConsole.WriteLine(customMetadataField);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/customMetadataFields/$ID \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'upload', - endpoint: '/api/v1/files/upload', - httpMethod: 'post', - summary: 'Upload file V1', - description: - 'ImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token`, `signature`, and `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) about how to implement client-side file upload.\n\nThe [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the entire payload using JWT.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n', - stainlessPath: '(resource) files > (method) upload', - qualified: 'client.files.upload', - params: [ - 'file: string;', - 'fileName: string;', - 'token?: string;', - 'checks?: string;', - 'customCoordinates?: string;', - 'customMetadata?: object;', - 'description?: string;', - 'expire?: number;', + "name": "upload", + "endpoint": "/api/v1/files/upload", + "httpMethod": "post", + "summary": "Upload file V1", + "description": "ImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token`, `signature`, and `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) about how to implement client-side file upload.\n\nThe [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the entire payload using JWT.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n", + "stainlessPath": "(resource) files > (method) upload", + "qualified": "client.files.upload", + "params": [ + "file: string;", + "fileName: string;", + "token?: string;", + "checks?: string;", + "customCoordinates?: string;", + "customMetadata?: object;", + "description?: string;", + "expire?: number;", "extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[];", - 'folder?: string;', - 'isPrivateFile?: boolean;', - 'isPublished?: boolean;', - 'overwriteAITags?: boolean;', - 'overwriteCustomMetadata?: boolean;', - 'overwriteFile?: boolean;', - 'overwriteTags?: boolean;', - 'publicKey?: string;', - 'responseFields?: string[];', - 'signature?: string;', - 'tags?: string[];', + "folder?: string;", + "isPrivateFile?: boolean;", + "isPublished?: boolean;", + "overwriteAITags?: boolean;", + "overwriteCustomMetadata?: boolean;", + "overwriteFile?: boolean;", + "overwriteTags?: boolean;", + "publicKey?: string;", + "responseFields?: string[];", + "signature?: string;", + "tags?: string[];", "transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; };", - 'useUniqueFileName?: boolean;', - 'webhookUrl?: string;', + "useUniqueFileName?: boolean;", + "webhookUrl?: string;" ], - response: - "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", - markdown: - "## upload\n\n`client.files.upload(file: string, fileName: string, token?: string, checks?: string, customCoordinates?: string, customMetadata?: object, description?: string, expire?: number, extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[], folder?: string, isPrivateFile?: boolean, isPublished?: boolean, overwriteAITags?: boolean, overwriteCustomMetadata?: boolean, overwriteFile?: boolean, overwriteTags?: boolean, publicKey?: string, responseFields?: string[], signature?: string, tags?: string[], transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }, useUniqueFileName?: boolean, webhookUrl?: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: object; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: metadata; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**post** `/api/v1/files/upload`\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token`, `signature`, and `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) about how to implement client-side file upload.\n\nThe [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the entire payload using JWT.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n\n\n### Parameters\n\n- `file: string`\n The API accepts any of the following:\n\n- **Binary data** – send the raw bytes as `multipart/form-data`.\n- **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.\n- **Base64 string** – the file encoded as a Base64 data URI or plain Base64.\n\nWhen supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.\n\n\n- `fileName: string`\n The name with which the file has to be uploaded.\nThe file name can contain:\n\n - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`.\n - Special Characters: `.`, `-`\n\nAny other character including space will be replaced by `_`\n\n\n- `token?: string`\n A unique value that the ImageKit.io server will use to recognize and prevent subsequent retries for the same request. We suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. This field is only required for authentication when uploading a file from the client side.\n\n**Note**: Sending a value that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new value for this field.\n\n\n- `checks?: string`\n Server-side checks to run on the asset.\nRead more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks).\n\n\n- `customCoordinates?: string`\n Define an important area in the image. This is only relevant for image type files.\n\n - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100`\n - Can be used with fo-customtransformation.\n - If this field is not specified and the file is overwritten, then customCoordinates will be removed.\n\n\n- `customMetadata?: object`\n JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.\n\n\n- `description?: string`\n Optional text to describe the contents of the file.\n\n\n- `expire?: number`\n The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It should be in seconds. This field is only required for authentication when uploading a file from the client side.\n\n\n- `extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[]`\n Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.\n\n\n- `folder?: string`\n The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created.\n\nThe folder name can contain:\n\n - Alphanumeric Characters: `a-z` , `A-Z` , `0-9`\n - Special Characters: `/` , `_` , `-`\n\nUsing multiple `/` creates a nested folder.\n\n\n- `isPrivateFile?: boolean`\n Whether to mark the file as private or not.\n\nIf `true`, the file is marked as private and is accessible only using named transformation or signed URL.\n\n\n- `isPublished?: boolean`\n Whether to upload file as published or not.\n\nIf `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published.\n\nThe option to upload in draft state is only available in custom enterprise pricing plans.\n\n\n- `overwriteAITags?: boolean`\n If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags.\n\n\n- `overwriteCustomMetadata?: boolean`\n If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed.\n\n\n- `overwriteFile?: boolean`\n If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately.\n\n\n- `overwriteTags?: boolean`\n If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed.\n\n\n- `publicKey?: string`\n Your ImageKit.io public key. This field is only required for authentication when uploading a file from the client side.\n\n\n- `responseFields?: string[]`\n Array of response field keys to include in the API response body.\n\n\n- `signature?: string`\n HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn how to create a signature on the page below. This should be in lowercase.\n\nSignature must be calculated on the server-side. This field is only required for authentication when uploading a file from the client side.\n\n\n- `tags?: string[]`\n Set the tags while uploading the file.\nProvide an array of tag strings (e.g. `[\"tag1\", \"tag2\", \"tag3\"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed.\nIf this field is not specified and the file is overwritten, the existing tags will be removed.\n\n\n- `transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }`\n Configure pre-processing (`pre`) and post-processing (`post`) transformations.\n\n- `pre` — applied before the file is uploaded to the Media Library. \n Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress).\n\n- `post` — applied immediately after upload. \n Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay.\n\nYou can mix and match any combination of post-processing types.\n\n - `post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]`\n List of transformations to apply *after* the file is uploaded. \nEach item must match one of the following types:\n`transformation`, `gif-to-video`, `thumbnail`, `abs`.\n\n - `pre?: string`\n Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion.\n\n\n- `useUniqueFileName?: boolean`\n Whether to use a unique filename for this file or not.\n\nIf `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename.\n\nIf `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced.\n\n\n- `webhookUrl?: string`\n The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure.\n\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a successful upload.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnailUrl?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'fileName' });\n\nconsole.log(response);\n```", - perLanguage: { - typescript: { - method: 'client.files.upload', - example: - "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);", - }, - python: { - method: 'files.upload', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.upload(\n file=b"Example data",\n file_name="fileName",\n)\nprint(response.video_codec)', - }, - java: { - method: 'files().upload', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.files().upload(params);\n }\n}', - }, - kotlin: { - method: 'files().upload', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUploadParams = FileUploadParams.builder()\n .file("Example data".byteInputStream())\n .fileName("fileName")\n .build()\n val response: FileUploadResponse = client.files().upload(params)\n}', - }, - go: { - method: 'client.Files.Upload', - example: - 'package main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("Example data"))),\n\t\tFileName: "fileName",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n', - }, - ruby: { - method: 'files.upload', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.upload(file: StringIO.new("Example data"), file_name: "fileName")\n\nputs(response)', - }, - cli: { - method: 'files upload', - example: - "imagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name fileName", - }, - php: { - method: 'files->upload', - example: - "files->upload(\n file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),\n fileName: 'fileName',\n token: 'token',\n checks: \"\\\"request.folder\\\" : \\\"marketing/\\\"\\n\",\n customCoordinates: 'customCoordinates',\n customMetadata: ['brand' => 'bar', 'color' => 'bar'],\n description: 'Running shoes',\n expire: 0,\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n folder: 'folder',\n isPrivateFile: true,\n isPublished: true,\n overwriteAITags: true,\n overwriteCustomMetadata: true,\n overwriteFile: true,\n overwriteTags: true,\n publicKey: 'publicKey',\n responseFields: ['tags', 'customCoordinates', 'isPrivateFile'],\n signature: 'signature',\n tags: ['t-shirt', 'round-neck', 'men'],\n transformation: [\n 'post' => [\n ['type' => 'thumbnail', 'value' => 'w-150,h-150'],\n [\n 'protocol' => 'dash',\n 'type' => 'abs',\n 'value' => 'sr-240_360_480_720_1080',\n ],\n ],\n 'pre' => 'w-300,h-300,q-80',\n ],\n useUniqueFileName: true,\n webhookURL: 'https://example.com',\n);\n\nvar_dump($response);", - }, - csharp: { - method: 'Files.Upload', - example: - 'FileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes("Example data"),\n FileName = "fileName",\n};\n\nvar response = await client.Files.Upload(parameters);\n\nConsole.WriteLine(response);', - }, - http: { - example: - 'curl https://upload.imagekit.io/api/v1/files/upload \\\n -H \'Content-Type: multipart/form-data\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -F \'file=@/path/to/file\' \\\n -F fileName=fileName \\\n -F checks=\'"request.folder" : "marketing/"\n \' \\\n -F customMetadata=\'{"brand":"bar","color":"bar"}\' \\\n -F description=\'Running shoes\' \\\n -F extensions=\'[{"name":"remove-bg","options":{"add_shadow":true}},{"maxTags":5,"minConfidence":95,"name":"google-auto-tagging"},{"name":"ai-auto-description"},{"name":"ai-tasks","tasks":[{"instruction":"What types of clothing items are visible in this image?","type":"select_tags","vocabulary":["shirt","tshirt","dress","trousers","jacket"]},{"instruction":"Is this a luxury or high-end fashion item?","type":"yes_no","on_yes":{"add_tags":["luxury","premium"]}}]},{"id":"ext_abc123","name":"saved-extension"}]\' \\\n -F responseFields=\'["tags","customCoordinates","isPrivateFile"]\' \\\n -F tags=\'["t-shirt","round-neck","men"]\' \\\n -F transformation=\'{"post":[{"type":"thumbnail","value":"w-150,h-150"},{"protocol":"dash","type":"abs","value":"sr-240_360_480_720_1080"}]}\'', - }, - }, + "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", + "markdown": "## upload\n\n`client.files.upload(file: string, fileName: string, token?: string, checks?: string, customCoordinates?: string, customMetadata?: object, description?: string, expire?: number, extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[], folder?: string, isPrivateFile?: boolean, isPublished?: boolean, overwriteAITags?: boolean, overwriteCustomMetadata?: boolean, overwriteFile?: boolean, overwriteTags?: boolean, publicKey?: string, responseFields?: string[], signature?: string, tags?: string[], transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }, useUniqueFileName?: boolean, webhookUrl?: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: object; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: metadata; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**post** `/api/v1/files/upload`\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token`, `signature`, and `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) about how to implement client-side file upload.\n\nThe [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the entire payload using JWT.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n\n\n### Parameters\n\n- `file: string`\n The API accepts any of the following:\n\n- **Binary data** – send the raw bytes as `multipart/form-data`.\n- **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.\n- **Base64 string** – the file encoded as a Base64 data URI or plain Base64.\n\nWhen supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.\n\n\n- `fileName: string`\n The name with which the file has to be uploaded.\nThe file name can contain:\n\n - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`.\n - Special Characters: `.`, `-`\n\nAny other character including space will be replaced by `_`\n\n\n- `token?: string`\n A unique value that the ImageKit.io server will use to recognize and prevent subsequent retries for the same request. We suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. This field is only required for authentication when uploading a file from the client side.\n\n**Note**: Sending a value that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new value for this field.\n\n\n- `checks?: string`\n Server-side checks to run on the asset.\nRead more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks).\n\n\n- `customCoordinates?: string`\n Define an important area in the image. This is only relevant for image type files.\n\n - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100`\n - Can be used with fo-customtransformation.\n - If this field is not specified and the file is overwritten, then customCoordinates will be removed.\n\n\n- `customMetadata?: object`\n JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.\n\n\n- `description?: string`\n Optional text to describe the contents of the file.\n\n\n- `expire?: number`\n The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It should be in seconds. This field is only required for authentication when uploading a file from the client side.\n\n\n- `extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[]`\n Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.\n\n\n- `folder?: string`\n The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created.\n\nThe folder name can contain:\n\n - Alphanumeric Characters: `a-z` , `A-Z` , `0-9`\n - Special Characters: `/` , `_` , `-`\n\nUsing multiple `/` creates a nested folder.\n\n\n- `isPrivateFile?: boolean`\n Whether to mark the file as private or not.\n\nIf `true`, the file is marked as private and is accessible only using named transformation or signed URL.\n\n\n- `isPublished?: boolean`\n Whether to upload file as published or not.\n\nIf `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published.\n\nThe option to upload in draft state is only available in custom enterprise pricing plans.\n\n\n- `overwriteAITags?: boolean`\n If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags.\n\n\n- `overwriteCustomMetadata?: boolean`\n If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed.\n\n\n- `overwriteFile?: boolean`\n If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately.\n\n\n- `overwriteTags?: boolean`\n If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed.\n\n\n- `publicKey?: string`\n Your ImageKit.io public key. This field is only required for authentication when uploading a file from the client side.\n\n\n- `responseFields?: string[]`\n Array of response field keys to include in the API response body.\n\n\n- `signature?: string`\n HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn how to create a signature on the page below. This should be in lowercase.\n\nSignature must be calculated on the server-side. This field is only required for authentication when uploading a file from the client side.\n\n\n- `tags?: string[]`\n Set the tags while uploading the file.\nProvide an array of tag strings (e.g. `[\"tag1\", \"tag2\", \"tag3\"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed.\nIf this field is not specified and the file is overwritten, the existing tags will be removed.\n\n\n- `transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }`\n Configure pre-processing (`pre`) and post-processing (`post`) transformations.\n\n- `pre` — applied before the file is uploaded to the Media Library. \n Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress).\n\n- `post` — applied immediately after upload. \n Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay.\n\nYou can mix and match any combination of post-processing types.\n\n - `post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]`\n List of transformations to apply *after* the file is uploaded. \nEach item must match one of the following types:\n`transformation`, `gif-to-video`, `thumbnail`, `abs`.\n\n - `pre?: string`\n Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion.\n\n\n- `useUniqueFileName?: boolean`\n Whether to use a unique filename for this file or not.\n\nIf `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename.\n\nIf `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced.\n\n\n- `webhookUrl?: string`\n The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure.\n\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a successful upload.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnailUrl?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'fileName' });\n\nconsole.log(response);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.upload", + "example": "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);" + }, + "python": { + "method": "files.upload", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.upload(\n file=b\"Example data\",\n file_name=\"fileName\",\n)\nprint(response.video_codec)" + }, + "java": { + "method": "files().upload", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream(\"Example data\".getBytes()))\n .fileName(\"fileName\")\n .build();\n FileUploadResponse response = client.files().upload(params);\n }\n}" + }, + "kotlin": { + "method": "files().upload", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUploadParams = FileUploadParams.builder()\n .file(\"Example data\".byteInputStream())\n .fileName(\"fileName\")\n .build()\n val response: FileUploadResponse = client.files().upload(params)\n}" + }, + "go": { + "method": "client.Files.Upload", + "example": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\tFileName: \"fileName\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.VideoCodec)\n}\n" + }, + "ruby": { + "method": "files.upload", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.upload(file: StringIO.new(\"Example data\"), file_name: \"fileName\")\n\nputs(response)" + }, + "cli": { + "method": "files upload", + "example": "imagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name fileName" + }, + "php": { + "method": "files->upload", + "example": "files->upload(\n file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),\n fileName: 'fileName',\n token: 'token',\n checks: \"\\\"request.folder\\\" : \\\"marketing/\\\"\\n\",\n customCoordinates: 'customCoordinates',\n customMetadata: ['brand' => 'bar', 'color' => 'bar'],\n description: 'Running shoes',\n expire: 0,\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n folder: 'folder',\n isPrivateFile: true,\n isPublished: true,\n overwriteAITags: true,\n overwriteCustomMetadata: true,\n overwriteFile: true,\n overwriteTags: true,\n publicKey: 'publicKey',\n responseFields: ['tags', 'customCoordinates', 'isPrivateFile'],\n signature: 'signature',\n tags: ['t-shirt', 'round-neck', 'men'],\n transformation: [\n 'post' => [\n ['type' => 'thumbnail', 'value' => 'w-150,h-150'],\n [\n 'protocol' => 'dash',\n 'type' => 'abs',\n 'value' => 'sr-240_360_480_720_1080',\n ],\n ],\n 'pre' => 'w-300,h-300,q-80',\n ],\n useUniqueFileName: true,\n webhookURL: 'https://example.com',\n);\n\nvar_dump($response);" + }, + "csharp": { + "method": "Files.Upload", + "example": "FileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes(\"Example data\"),\n FileName = \"fileName\",\n};\n\nvar response = await client.Files.Upload(parameters);\n\nConsole.WriteLine(response);" + }, + "http": { + "example": "curl https://upload.imagekit.io/api/v1/files/upload \\\n -H 'Content-Type: multipart/form-data' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -F 'file=@/path/to/file' \\\n -F fileName=fileName \\\n -F checks='\"request.folder\" : \"marketing/\"\n ' \\\n -F customMetadata='{\"brand\":\"bar\",\"color\":\"bar\"}' \\\n -F description='Running shoes' \\\n -F extensions='[{\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true}},{\"maxTags\":5,\"minConfidence\":95,\"name\":\"google-auto-tagging\"},{\"name\":\"ai-auto-description\"},{\"name\":\"ai-tasks\",\"tasks\":[{\"instruction\":\"What types of clothing items are visible in this image?\",\"type\":\"select_tags\",\"vocabulary\":[\"shirt\",\"tshirt\",\"dress\",\"trousers\",\"jacket\"]},{\"instruction\":\"Is this a luxury or high-end fashion item?\",\"type\":\"yes_no\",\"on_yes\":{\"add_tags\":[\"luxury\",\"premium\"]}}]},{\"id\":\"ext_abc123\",\"name\":\"saved-extension\"}]' \\\n -F responseFields='[\"tags\",\"customCoordinates\",\"isPrivateFile\"]' \\\n -F tags='[\"t-shirt\",\"round-neck\",\"men\"]' \\\n -F transformation='{\"post\":[{\"type\":\"thumbnail\",\"value\":\"w-150,h-150\"},{\"protocol\":\"dash\",\"type\":\"abs\",\"value\":\"sr-240_360_480_720_1080\"}]}'" + } + } }, { - name: 'get', - endpoint: '/v1/files/{fileId}/details', - httpMethod: 'get', - summary: 'Get file details', - description: - 'This API returns an object with details or attributes about the current version of the file.', - stainlessPath: '(resource) files > (method) get', - qualified: 'client.files.get', - params: ['fileId: string;'], - response: - "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", - markdown: - "## get\n\n`client.files.get(fileId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/details`\n\nThis API returns an object with details or attributes about the current version of the file.\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.get('fileId');\n\nconsole.log(file);\n```", - perLanguage: { - typescript: { - method: 'client.files.get', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.get('fileId');\n\nconsole.log(file.videoCodec);", - }, - python: { - method: 'files.get', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.get(\n "fileId",\n)\nprint(file.video_codec)', - }, - java: { - method: 'files().get', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.FileGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n File file = client.files().get("fileId");\n }\n}', - }, - kotlin: { - method: 'files().get', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.FileGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val file: File = client.files().get("fileId")\n}', - }, - go: { - method: 'client.Files.Get', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Get(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file.VideoCodec)\n}\n', - }, - ruby: { - method: 'files.get', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfile = image_kit.files.get("fileId")\n\nputs(file)', - }, - cli: { - method: 'files get', - example: - "imagekit files get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", - }, - php: { - method: 'files->get', - example: - "files->get('fileId');\n\nvar_dump($file);", - }, - csharp: { - method: 'Files.Get', - example: - 'FileGetParams parameters = new() { FileID = "fileId" };\n\nvar file = await client.Files.Get(parameters);\n\nConsole.WriteLine(file);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/details \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "get", + "endpoint": "/v1/files/{fileId}/details", + "httpMethod": "get", + "summary": "Get file details", + "description": "This API returns an object with details or attributes about the current version of the file.", + "stainlessPath": "(resource) files > (method) get", + "qualified": "client.files.get", + "params": [ + "fileId: string;" + ], + "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", + "markdown": "## get\n\n`client.files.get(fileId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/details`\n\nThis API returns an object with details or attributes about the current version of the file.\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.get('fileId');\n\nconsole.log(file);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.get", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.get('fileId');\n\nconsole.log(file.videoCodec);" + }, + "python": { + "method": "files.get", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfile = client.files.get(\n \"fileId\",\n)\nprint(file.video_codec)" + }, + "java": { + "method": "files().get", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.FileGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n File file = client.files().get(\"fileId\");\n }\n}" + }, + "kotlin": { + "method": "files().get", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.FileGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val file: File = client.files().get(\"fileId\")\n}" + }, + "go": { + "method": "client.Files.Get", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfile, err := client.Files.Get(context.TODO(), \"fileId\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", file.VideoCodec)\n}\n" + }, + "ruby": { + "method": "files.get", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfile = image_kit.files.get(\"fileId\")\n\nputs(file)" + }, + "cli": { + "method": "files get", + "example": "imagekit files get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId" + }, + "php": { + "method": "files->get", + "example": "files->get('fileId');\n\nvar_dump($file);" + }, + "csharp": { + "method": "Files.Get", + "example": "FileGetParams parameters = new() { FileID = \"fileId\" };\n\nvar file = await client.Files.Get(parameters);\n\nConsole.WriteLine(file);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/details \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'update', - endpoint: '/v1/files/{fileId}/details', - httpMethod: 'patch', - summary: 'Update file details', - description: - 'This API updates the details or attributes of the current version of the file. You can update `tags`, `customCoordinates`, `customMetadata`, publication status, remove existing `AITags` and apply extensions using this API.\n', - stainlessPath: '(resource) files > (method) update', - qualified: 'client.files.update', - params: [ - 'fileId: string;', - "UpdateFileRequest: { customCoordinates?: string; customMetadata?: object; description?: string; extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[]; removeAITags?: string[] | 'all'; tags?: string[]; webhookUrl?: string; } | { publish?: { isPublished: boolean; includeFileVersions?: boolean; }; };", + "name": "update", + "endpoint": "/v1/files/{fileId}/details", + "httpMethod": "patch", + "summary": "Update file details", + "description": "This API updates the details or attributes of the current version of the file. You can update `tags`, `customCoordinates`, `customMetadata`, publication status, remove existing `AITags` and apply extensions using this API.\n", + "stainlessPath": "(resource) files > (method) update", + "qualified": "client.files.update", + "params": [ + "fileId: string;", + "UpdateFileRequest: { customCoordinates?: string; customMetadata?: object; description?: string; extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[]; removeAITags?: string[] | 'all'; tags?: string[]; webhookUrl?: string; } | { publish?: { isPublished: boolean; includeFileVersions?: boolean; }; };" ], - response: - "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", - perLanguage: { - typescript: { - method: 'client.files.update', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.update('fileId');\n\nconsole.log(file);", - }, - python: { - method: 'files.update', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.update(\n file_id="fileId",\n)\nprint(file)', - }, - java: { - method: 'files().update', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUpdateParams;\nimport io.imagekit.models.files.FileUpdateResponse;\nimport io.imagekit.models.files.UpdateFileRequest;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUpdateParams params = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build();\n FileUpdateResponse file = client.files().update(params);\n }\n}', - }, - kotlin: { - method: 'files().update', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUpdateParams\nimport com.imagekit.api.models.files.FileUpdateResponse\nimport com.imagekit.api.models.files.UpdateFileRequest\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUpdateParams = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build()\n val file: FileUpdateResponse = client.files().update(params)\n}', - }, - go: { - method: 'client.Files.Update', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Update(\n\t\tcontext.TODO(),\n\t\t"fileId",\n\t\timagekit.FileUpdateParams{\n\t\t\tUpdateFileRequest: imagekit.UpdateFileRequestUnionParam{\n\t\t\t\tOfUpdateFileDetails: &imagekit.UpdateFileRequestUpdateFileDetailsParam{},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file)\n}\n', - }, - ruby: { - method: 'files.update', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfile = image_kit.files.update("fileId", update_file_request: {})\n\nputs(file)', - }, - cli: { - method: 'files update', - example: - "imagekit files update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", - }, - php: { - method: 'files->update', - example: - "files->update(\n 'fileId',\n customCoordinates: 'customCoordinates',\n customMetadata: ['foo' => 'bar'],\n description: 'description',\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n removeAITags: 'all',\n tags: ['tag1', 'tag2'],\n webhookURL: 'https://example.com',\n publish: ['isPublished' => true, 'includeFileVersions' => true],\n);\n\nvar_dump($file);", - }, - csharp: { - method: 'Files.Update', - example: - 'FileUpdateParams parameters = new()\n{\n FileID = "fileId",\n UpdateFileRequest = new UpdateFileDetails()\n {\n CustomCoordinates = "10,10,100,100",\n CustomMetadata = new Dictionary()\n {\n { "brand", JsonSerializer.SerializeToElement("bar") },\n { "color", JsonSerializer.SerializeToElement("bar") },\n },\n Description = "description",\n Extensions =\n [\n new RemoveBg()\n {\n Options = new()\n {\n AddShadow = true,\n BgColor = "bg_color",\n BgImageUrl = "bg_image_url",\n Semitransparency = true,\n },\n },\n new AutoTaggingExtension()\n {\n MaxTags = 10,\n MinConfidence = 80,\n Name = Name.GoogleAutoTagging,\n },\n new AutoTaggingExtension()\n {\n MaxTags = 10,\n MinConfidence = 80,\n Name = Name.AwsAutoTagging,\n },\n new AIAutoDescription(),\n new AITasks(\n\n [\n new SelectTags()\n {\n Instruction = "What types of clothing items are visible?",\n MaxSelections = 1,\n MinSelections = 0,\n Vocabulary =\n [\n "shirt", "dress", "jacket"\n ],\n },\n ]\n ),\n new SavedExtension("ext_abc123"),\n ],\n RemoveAITags = new(\n\n [\n "car", "vehicle", "motorsports"\n ]\n ),\n Tags =\n [\n "tag1", "tag2"\n ],\n WebhookUrl = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a",\n },\n};\n\nvar file = await client.Files.Update(parameters);\n\nConsole.WriteLine(file);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/details \\\n -X PATCH \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "extensions": [\n {\n "name": "remove-bg",\n "options": {\n "add_shadow": true\n }\n },\n {\n "maxTags": 5,\n "minConfidence": 95,\n "name": "google-auto-tagging"\n },\n {\n "name": "ai-auto-description"\n },\n {\n "name": "ai-tasks",\n "tasks": [\n {\n "instruction": "What types of clothing items are visible in this image?",\n "type": "select_tags",\n "vocabulary": [\n "shirt",\n "tshirt",\n "dress",\n "trousers",\n "jacket"\n ]\n },\n {\n "instruction": "Is this a luxury or high-end fashion item?",\n "type": "yes_no",\n "on_yes": {\n "add_tags": [\n "luxury",\n "premium"\n ]\n }\n }\n ]\n },\n {\n "id": "ext_abc123",\n "name": "saved-extension"\n }\n ],\n "tags": [\n "tag1",\n "tag2"\n ]\n }\'', - }, - }, + "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", + "perLanguage": { + "typescript": { + "method": "client.files.update", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.update('fileId');\n\nconsole.log(file);" + }, + "python": { + "method": "files.update", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfile = client.files.update(\n file_id=\"fileId\",\n)\nprint(file)" + }, + "java": { + "method": "files().update", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUpdateParams;\nimport io.imagekit.models.files.FileUpdateResponse;\nimport io.imagekit.models.files.UpdateFileRequest;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUpdateParams params = FileUpdateParams.builder()\n .fileId(\"fileId\")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build();\n FileUpdateResponse file = client.files().update(params);\n }\n}" + }, + "kotlin": { + "method": "files().update", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUpdateParams\nimport com.imagekit.api.models.files.FileUpdateResponse\nimport com.imagekit.api.models.files.UpdateFileRequest\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUpdateParams = FileUpdateParams.builder()\n .fileId(\"fileId\")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build()\n val file: FileUpdateResponse = client.files().update(params)\n}" + }, + "go": { + "method": "client.Files.Update", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfile, err := client.Files.Update(\n\t\tcontext.TODO(),\n\t\t\"fileId\",\n\t\timagekit.FileUpdateParams{\n\t\t\tUpdateFileRequest: imagekit.UpdateFileRequestUnionParam{\n\t\t\t\tOfUpdateFileDetails: &imagekit.UpdateFileRequestUpdateFileDetailsParam{},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", file)\n}\n" + }, + "ruby": { + "method": "files.update", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfile = image_kit.files.update(\"fileId\", update_file_request: {})\n\nputs(file)" + }, + "cli": { + "method": "files update", + "example": "imagekit files update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId" + }, + "php": { + "method": "files->update", + "example": "files->update(\n 'fileId',\n customCoordinates: 'customCoordinates',\n customMetadata: ['foo' => 'bar'],\n description: 'description',\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n removeAITags: 'all',\n tags: ['tag1', 'tag2'],\n webhookURL: 'https://example.com',\n publish: ['isPublished' => true, 'includeFileVersions' => true],\n);\n\nvar_dump($file);" + }, + "csharp": { + "method": "Files.Update", + "example": "FileUpdateParams parameters = new()\n{\n FileID = \"fileId\",\n UpdateFileRequest = new UpdateFileDetails()\n {\n CustomCoordinates = \"10,10,100,100\",\n CustomMetadata = new Dictionary()\n {\n { \"brand\", JsonSerializer.SerializeToElement(\"bar\") },\n { \"color\", JsonSerializer.SerializeToElement(\"bar\") },\n },\n Description = \"description\",\n Extensions =\n [\n new RemoveBg()\n {\n Options = new()\n {\n AddShadow = true,\n BgColor = \"bg_color\",\n BgImageUrl = \"bg_image_url\",\n Semitransparency = true,\n },\n },\n new AutoTaggingExtension()\n {\n MaxTags = 10,\n MinConfidence = 80,\n Name = Name.GoogleAutoTagging,\n },\n new AutoTaggingExtension()\n {\n MaxTags = 10,\n MinConfidence = 80,\n Name = Name.AwsAutoTagging,\n },\n new AIAutoDescription(),\n new AITasks(\n\n [\n new SelectTags()\n {\n Instruction = \"What types of clothing items are visible?\",\n MaxSelections = 1,\n MinSelections = 0,\n Vocabulary =\n [\n \"shirt\", \"dress\", \"jacket\"\n ],\n },\n ]\n ),\n new SavedExtension(\"ext_abc123\"),\n ],\n RemoveAITags = new(\n\n [\n \"car\", \"vehicle\", \"motorsports\"\n ]\n ),\n Tags =\n [\n \"tag1\", \"tag2\"\n ],\n WebhookUrl = \"https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a\",\n },\n};\n\nvar file = await client.Files.Update(parameters);\n\nConsole.WriteLine(file);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/details \\\n -X PATCH \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"extensions\": [\n {\n \"name\": \"remove-bg\",\n \"options\": {\n \"add_shadow\": true\n }\n },\n {\n \"maxTags\": 5,\n \"minConfidence\": 95,\n \"name\": \"google-auto-tagging\"\n },\n {\n \"name\": \"ai-auto-description\"\n },\n {\n \"name\": \"ai-tasks\",\n \"tasks\": [\n {\n \"instruction\": \"What types of clothing items are visible in this image?\",\n \"type\": \"select_tags\",\n \"vocabulary\": [\n \"shirt\",\n \"tshirt\",\n \"dress\",\n \"trousers\",\n \"jacket\"\n ]\n },\n {\n \"instruction\": \"Is this a luxury or high-end fashion item?\",\n \"type\": \"yes_no\",\n \"on_yes\": {\n \"add_tags\": [\n \"luxury\",\n \"premium\"\n ]\n }\n }\n ]\n },\n {\n \"id\": \"ext_abc123\",\n \"name\": \"saved-extension\"\n }\n ],\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ]\n }'" + } + } }, { - name: 'delete', - endpoint: '/v1/files/{fileId}', - httpMethod: 'delete', - summary: 'Delete file', - description: - 'This API deletes the file and all its file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n', - stainlessPath: '(resource) files > (method) delete', - qualified: 'client.files.delete', - params: ['fileId: string;'], - markdown: - "## delete\n\n`client.files.delete(fileId: string): void`\n\n**delete** `/v1/files/{fileId}`\n\nThis API deletes the file and all its file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.files.delete('fileId')\n```", - perLanguage: { - typescript: { - method: 'client.files.delete', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.files.delete('fileId');", - }, - python: { - method: 'files.delete', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.files.delete(\n "fileId",\n)', - }, - java: { - method: 'files().delete', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.files().delete("fileId");\n }\n}', - }, - kotlin: { - method: 'files().delete', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.files().delete("fileId")\n}', - }, - go: { - method: 'client.Files.Delete', - example: - 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Files.Delete(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', - }, - ruby: { - method: 'files.delete', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.files.delete("fileId")\n\nputs(result)', - }, - cli: { - method: 'files delete', - example: - "imagekit files delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", - }, - php: { - method: 'files->delete', - example: - "files->delete('fileId');\n\nvar_dump($result);", - }, - csharp: { - method: 'Files.Delete', - example: - 'FileDeleteParams parameters = new() { FileID = "fileId" };\n\nawait client.Files.Delete(parameters);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "delete", + "endpoint": "/v1/files/{fileId}", + "httpMethod": "delete", + "summary": "Delete file", + "description": "This API deletes the file and all its file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n", + "stainlessPath": "(resource) files > (method) delete", + "qualified": "client.files.delete", + "params": [ + "fileId: string;" + ], + "markdown": "## delete\n\n`client.files.delete(fileId: string): void`\n\n**delete** `/v1/files/{fileId}`\n\nThis API deletes the file and all its file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.files.delete('fileId')\n```", + "perLanguage": { + "typescript": { + "method": "client.files.delete", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.files.delete('fileId');" + }, + "python": { + "method": "files.delete", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nclient.files.delete(\n \"fileId\",\n)" + }, + "java": { + "method": "files().delete", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.files().delete(\"fileId\");\n }\n}" + }, + "kotlin": { + "method": "files().delete", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.files().delete(\"fileId\")\n}" + }, + "go": { + "method": "client.Files.Delete", + "example": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\terr := client.Files.Delete(context.TODO(), \"fileId\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n" + }, + "ruby": { + "method": "files.delete", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresult = image_kit.files.delete(\"fileId\")\n\nputs(result)" + }, + "cli": { + "method": "files delete", + "example": "imagekit files delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId" + }, + "php": { + "method": "files->delete", + "example": "files->delete('fileId');\n\nvar_dump($result);" + }, + "csharp": { + "method": "Files.Delete", + "example": "FileDeleteParams parameters = new() { FileID = \"fileId\" };\n\nawait client.Files.Delete(parameters);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/$FILE_ID \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'copy', - endpoint: '/v1/files/copy', - httpMethod: 'post', - summary: 'Copy file', - description: - 'This will copy a file from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions (if `includeFileVersions` is set to true) will be appended to the destination file version history.\n', - stainlessPath: '(resource) files > (method) copy', - qualified: 'client.files.copy', - params: ['destinationPath: string;', 'sourceFilePath: string;', 'includeFileVersions?: boolean;'], - response: '{ }', - markdown: - "## copy\n\n`client.files.copy(destinationPath: string, sourceFilePath: string, includeFileVersions?: boolean): { }`\n\n**post** `/v1/files/copy`\n\nThis will copy a file from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions (if `includeFileVersions` is set to true) will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the folder you want to copy the above file into.\n\n\n- `sourceFilePath: string`\n The full path of the file you want to copy.\n\n\n- `includeFileVersions?: boolean`\n Option to copy all versions of a file. By default, only the current version of the file is copied. When set to true, all versions of the file will be copied. Default value - `false`.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.copy({ destinationPath: '/folder/to/copy/into/', sourceFilePath: '/path/to/file.jpg' });\n\nconsole.log(response);\n```", - perLanguage: { - typescript: { - method: 'client.files.copy', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.copy({\n destinationPath: '/folder/to/copy/into/',\n sourceFilePath: '/path/to/file.jpg',\n});\n\nconsole.log(response);", - }, - python: { - method: 'files.copy', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.copy(\n destination_path="/folder/to/copy/into/",\n source_file_path="/path/to/file.jpg",\n)\nprint(response)', - }, - java: { - method: 'files().copy', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileCopyParams;\nimport io.imagekit.models.files.FileCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileCopyParams params = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileCopyResponse response = client.files().copy(params);\n }\n}', - }, - kotlin: { - method: 'files().copy', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileCopyParams\nimport com.imagekit.api.models.files.FileCopyResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileCopyParams = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build()\n val response: FileCopyResponse = client.files().copy(params)\n}', - }, - go: { - method: 'client.Files.Copy', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Copy(context.TODO(), imagekit.FileCopyParams{\n\t\tDestinationPath: "/folder/to/copy/into/",\n\t\tSourceFilePath: "/path/to/file.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response)\n}\n', - }, - ruby: { - method: 'files.copy', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.copy(destination_path: "/folder/to/copy/into/", source_file_path: "/path/to/file.jpg")\n\nputs(response)', - }, - cli: { - method: 'files copy', - example: - "imagekit files copy \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /folder/to/copy/into/ \\\n --source-file-path /path/to/file.jpg", - }, - php: { - method: 'files->copy', - example: - "files->copy(\n destinationPath: '/folder/to/copy/into/',\n sourceFilePath: '/path/to/file.jpg',\n includeFileVersions: false,\n);\n\nvar_dump($response);", - }, - csharp: { - method: 'Files.Copy', - example: - 'FileCopyParams parameters = new()\n{\n DestinationPath = "/folder/to/copy/into/",\n SourceFilePath = "/path/to/file.jpg",\n};\n\nvar response = await client.Files.Copy(parameters);\n\nConsole.WriteLine(response);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/copy \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/folder/to/copy/into/",\n "sourceFilePath": "/path/to/file.jpg"\n }\'', - }, - }, + "name": "copy", + "endpoint": "/v1/files/copy", + "httpMethod": "post", + "summary": "Copy file", + "description": "This will copy a file from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions (if `includeFileVersions` is set to true) will be appended to the destination file version history.\n", + "stainlessPath": "(resource) files > (method) copy", + "qualified": "client.files.copy", + "params": [ + "destinationPath: string;", + "sourceFilePath: string;", + "includeFileVersions?: boolean;" + ], + "response": "{ }", + "markdown": "## copy\n\n`client.files.copy(destinationPath: string, sourceFilePath: string, includeFileVersions?: boolean): { }`\n\n**post** `/v1/files/copy`\n\nThis will copy a file from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions (if `includeFileVersions` is set to true) will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the folder you want to copy the above file into.\n\n\n- `sourceFilePath: string`\n The full path of the file you want to copy.\n\n\n- `includeFileVersions?: boolean`\n Option to copy all versions of a file. By default, only the current version of the file is copied. When set to true, all versions of the file will be copied. Default value - `false`.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.copy({ destinationPath: '/folder/to/copy/into/', sourceFilePath: '/path/to/file.jpg' });\n\nconsole.log(response);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.copy", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.copy({\n destinationPath: '/folder/to/copy/into/',\n sourceFilePath: '/path/to/file.jpg',\n});\n\nconsole.log(response);" + }, + "python": { + "method": "files.copy", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.copy(\n destination_path=\"/folder/to/copy/into/\",\n source_file_path=\"/path/to/file.jpg\",\n)\nprint(response)" + }, + "java": { + "method": "files().copy", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileCopyParams;\nimport io.imagekit.models.files.FileCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileCopyParams params = FileCopyParams.builder()\n .destinationPath(\"/folder/to/copy/into/\")\n .sourceFilePath(\"/path/to/file.jpg\")\n .build();\n FileCopyResponse response = client.files().copy(params);\n }\n}" + }, + "kotlin": { + "method": "files().copy", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileCopyParams\nimport com.imagekit.api.models.files.FileCopyResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileCopyParams = FileCopyParams.builder()\n .destinationPath(\"/folder/to/copy/into/\")\n .sourceFilePath(\"/path/to/file.jpg\")\n .build()\n val response: FileCopyResponse = client.files().copy(params)\n}" + }, + "go": { + "method": "client.Files.Copy", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Copy(context.TODO(), imagekit.FileCopyParams{\n\t\tDestinationPath: \"/folder/to/copy/into/\",\n\t\tSourceFilePath: \"/path/to/file.jpg\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response)\n}\n" + }, + "ruby": { + "method": "files.copy", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.copy(destination_path: \"/folder/to/copy/into/\", source_file_path: \"/path/to/file.jpg\")\n\nputs(response)" + }, + "cli": { + "method": "files copy", + "example": "imagekit files copy \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /folder/to/copy/into/ \\\n --source-file-path /path/to/file.jpg" + }, + "php": { + "method": "files->copy", + "example": "files->copy(\n destinationPath: '/folder/to/copy/into/',\n sourceFilePath: '/path/to/file.jpg',\n includeFileVersions: false,\n);\n\nvar_dump($response);" + }, + "csharp": { + "method": "Files.Copy", + "example": "FileCopyParams parameters = new()\n{\n DestinationPath = \"/folder/to/copy/into/\",\n SourceFilePath = \"/path/to/file.jpg\",\n};\n\nvar response = await client.Files.Copy(parameters);\n\nConsole.WriteLine(response);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/copy \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"destinationPath\": \"/folder/to/copy/into/\",\n \"sourceFilePath\": \"/path/to/file.jpg\"\n }'" + } + } }, { - name: 'move', - endpoint: '/v1/files/move', - httpMethod: 'post', - summary: 'Move file', - description: - 'This will move a file and all its versions from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file.\n', - stainlessPath: '(resource) files > (method) move', - qualified: 'client.files.move', - params: ['destinationPath: string;', 'sourceFilePath: string;'], - response: '{ }', - markdown: - "## move\n\n`client.files.move(destinationPath: string, sourceFilePath: string): { }`\n\n**post** `/v1/files/move`\n\nThis will move a file and all its versions from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the folder you want to move the above file into.\n\n\n- `sourceFilePath: string`\n The full path of the file you want to move.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.move({ destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg' });\n\nconsole.log(response);\n```", - perLanguage: { - typescript: { - method: 'client.files.move', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.move({\n destinationPath: '/folder/to/move/into/',\n sourceFilePath: '/path/to/file.jpg',\n});\n\nconsole.log(response);", - }, - python: { - method: 'files.move', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.move(\n destination_path="/folder/to/move/into/",\n source_file_path="/path/to/file.jpg",\n)\nprint(response)', - }, - java: { - method: 'files().move', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileMoveParams;\nimport io.imagekit.models.files.FileMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileMoveParams params = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileMoveResponse response = client.files().move(params);\n }\n}', - }, - kotlin: { - method: 'files().move', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileMoveParams\nimport com.imagekit.api.models.files.FileMoveResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileMoveParams = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build()\n val response: FileMoveResponse = client.files().move(params)\n}', - }, - go: { - method: 'client.Files.Move', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Move(context.TODO(), imagekit.FileMoveParams{\n\t\tDestinationPath: "/folder/to/move/into/",\n\t\tSourceFilePath: "/path/to/file.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response)\n}\n', - }, - ruby: { - method: 'files.move', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.move(destination_path: "/folder/to/move/into/", source_file_path: "/path/to/file.jpg")\n\nputs(response)', - }, - cli: { - method: 'files move', - example: - "imagekit files move \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /folder/to/move/into/ \\\n --source-file-path /path/to/file.jpg", - }, - php: { - method: 'files->move', - example: - "files->move(\n destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg'\n);\n\nvar_dump($response);", - }, - csharp: { - method: 'Files.Move', - example: - 'FileMoveParams parameters = new()\n{\n DestinationPath = "/folder/to/move/into/",\n SourceFilePath = "/path/to/file.jpg",\n};\n\nvar response = await client.Files.Move(parameters);\n\nConsole.WriteLine(response);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/move \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/folder/to/move/into/",\n "sourceFilePath": "/path/to/file.jpg"\n }\'', - }, - }, + "name": "move", + "endpoint": "/v1/files/move", + "httpMethod": "post", + "summary": "Move file", + "description": "This will move a file and all its versions from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file.\n", + "stainlessPath": "(resource) files > (method) move", + "qualified": "client.files.move", + "params": [ + "destinationPath: string;", + "sourceFilePath: string;" + ], + "response": "{ }", + "markdown": "## move\n\n`client.files.move(destinationPath: string, sourceFilePath: string): { }`\n\n**post** `/v1/files/move`\n\nThis will move a file and all its versions from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the folder you want to move the above file into.\n\n\n- `sourceFilePath: string`\n The full path of the file you want to move.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.move({ destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg' });\n\nconsole.log(response);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.move", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.move({\n destinationPath: '/folder/to/move/into/',\n sourceFilePath: '/path/to/file.jpg',\n});\n\nconsole.log(response);" + }, + "python": { + "method": "files.move", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.move(\n destination_path=\"/folder/to/move/into/\",\n source_file_path=\"/path/to/file.jpg\",\n)\nprint(response)" + }, + "java": { + "method": "files().move", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileMoveParams;\nimport io.imagekit.models.files.FileMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileMoveParams params = FileMoveParams.builder()\n .destinationPath(\"/folder/to/move/into/\")\n .sourceFilePath(\"/path/to/file.jpg\")\n .build();\n FileMoveResponse response = client.files().move(params);\n }\n}" + }, + "kotlin": { + "method": "files().move", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileMoveParams\nimport com.imagekit.api.models.files.FileMoveResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileMoveParams = FileMoveParams.builder()\n .destinationPath(\"/folder/to/move/into/\")\n .sourceFilePath(\"/path/to/file.jpg\")\n .build()\n val response: FileMoveResponse = client.files().move(params)\n}" + }, + "go": { + "method": "client.Files.Move", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Move(context.TODO(), imagekit.FileMoveParams{\n\t\tDestinationPath: \"/folder/to/move/into/\",\n\t\tSourceFilePath: \"/path/to/file.jpg\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response)\n}\n" + }, + "ruby": { + "method": "files.move", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.move(destination_path: \"/folder/to/move/into/\", source_file_path: \"/path/to/file.jpg\")\n\nputs(response)" + }, + "cli": { + "method": "files move", + "example": "imagekit files move \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /folder/to/move/into/ \\\n --source-file-path /path/to/file.jpg" + }, + "php": { + "method": "files->move", + "example": "files->move(\n destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg'\n);\n\nvar_dump($response);" + }, + "csharp": { + "method": "Files.Move", + "example": "FileMoveParams parameters = new()\n{\n DestinationPath = \"/folder/to/move/into/\",\n SourceFilePath = \"/path/to/file.jpg\",\n};\n\nvar response = await client.Files.Move(parameters);\n\nConsole.WriteLine(response);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/move \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"destinationPath\": \"/folder/to/move/into/\",\n \"sourceFilePath\": \"/path/to/file.jpg\"\n }'" + } + } }, { - name: 'rename', - endpoint: '/v1/files/rename', - httpMethod: 'put', - summary: 'Rename file', - description: - 'You can rename an already existing file in the media library using rename file API. This operation would rename all file versions of the file. \n\nNote: The old URLs will stop working. The file/file version URLs cached on CDN will continue to work unless a purge is requested.\n', - stainlessPath: '(resource) files > (method) rename', - qualified: 'client.files.rename', - params: ['filePath: string;', 'newFileName: string;', 'purgeCache?: boolean;'], - response: '{ purgeRequestId?: string; }', - markdown: - "## rename\n\n`client.files.rename(filePath: string, newFileName: string, purgeCache?: boolean): { purgeRequestId?: string; }`\n\n**put** `/v1/files/rename`\n\nYou can rename an already existing file in the media library using rename file API. This operation would rename all file versions of the file. \n\nNote: The old URLs will stop working. The file/file version URLs cached on CDN will continue to work unless a purge is requested.\n\n\n### Parameters\n\n- `filePath: string`\n The full path of the file you want to rename.\n\n\n- `newFileName: string`\n The new name of the file. A filename can contain:\n\nAlphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, and numerals in other languages).\nSpecial Characters: `.`, `_`, and `-`.\n\nAny other character, including space, will be replaced by `_`.\n\n\n- `purgeCache?: boolean`\n Option to purge cache for the old file and its versions' URLs.\n\nWhen set to true, it will internally issue a purge cache request on CDN to remove cached content of old file and its versions. This purge request is counted against your monthly purge quota.\n\nNote: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard at the end). It will remove the file and its versions' URLs and any transformations made using query parameters on this file or its versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation.\n\n\n\nDefault value - `false`\n\n\n### Returns\n\n- `{ purgeRequestId?: string; }`\n\n - `purgeRequestId?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.rename({ filePath: '/path/to/file.jpg', newFileName: 'newFileName.jpg' });\n\nconsole.log(response);\n```", - perLanguage: { - typescript: { - method: 'client.files.rename', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.rename({\n filePath: '/path/to/file.jpg',\n newFileName: 'newFileName.jpg',\n});\n\nconsole.log(response.purgeRequestId);", - }, - python: { - method: 'files.rename', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.rename(\n file_path="/path/to/file.jpg",\n new_file_name="newFileName.jpg",\n)\nprint(response.purge_request_id)', - }, - java: { - method: 'files().rename', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileRenameParams;\nimport io.imagekit.models.files.FileRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileRenameParams params = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build();\n FileRenameResponse response = client.files().rename(params);\n }\n}', - }, - kotlin: { - method: 'files().rename', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileRenameParams\nimport com.imagekit.api.models.files.FileRenameResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileRenameParams = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build()\n val response: FileRenameResponse = client.files().rename(params)\n}', - }, - go: { - method: 'client.Files.Rename', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Rename(context.TODO(), imagekit.FileRenameParams{\n\t\tFilePath: "/path/to/file.jpg",\n\t\tNewFileName: "newFileName.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.PurgeRequestID)\n}\n', - }, - ruby: { - method: 'files.rename', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.rename(file_path: "/path/to/file.jpg", new_file_name: "newFileName.jpg")\n\nputs(response)', - }, - cli: { - method: 'files rename', - example: - "imagekit files rename \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-path /path/to/file.jpg \\\n --new-file-name newFileName.jpg", - }, - php: { - method: 'files->rename', - example: - "files->rename(\n filePath: '/path/to/file.jpg',\n newFileName: 'newFileName.jpg',\n purgeCache: true,\n);\n\nvar_dump($response);", - }, - csharp: { - method: 'Files.Rename', - example: - 'FileRenameParams parameters = new()\n{\n FilePath = "/path/to/file.jpg",\n NewFileName = "newFileName.jpg",\n};\n\nvar response = await client.Files.Rename(parameters);\n\nConsole.WriteLine(response);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/rename \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "filePath": "/path/to/file.jpg",\n "newFileName": "newFileName.jpg",\n "purgeCache": true\n }\'', - }, - }, + "name": "rename", + "endpoint": "/v1/files/rename", + "httpMethod": "put", + "summary": "Rename file", + "description": "You can rename an already existing file in the media library using rename file API. This operation would rename all file versions of the file. \n\nNote: The old URLs will stop working. The file/file version URLs cached on CDN will continue to work unless a purge is requested.\n", + "stainlessPath": "(resource) files > (method) rename", + "qualified": "client.files.rename", + "params": [ + "filePath: string;", + "newFileName: string;", + "purgeCache?: boolean;" + ], + "response": "{ purgeRequestId?: string; }", + "markdown": "## rename\n\n`client.files.rename(filePath: string, newFileName: string, purgeCache?: boolean): { purgeRequestId?: string; }`\n\n**put** `/v1/files/rename`\n\nYou can rename an already existing file in the media library using rename file API. This operation would rename all file versions of the file. \n\nNote: The old URLs will stop working. The file/file version URLs cached on CDN will continue to work unless a purge is requested.\n\n\n### Parameters\n\n- `filePath: string`\n The full path of the file you want to rename.\n\n\n- `newFileName: string`\n The new name of the file. A filename can contain:\n\nAlphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, and numerals in other languages).\nSpecial Characters: `.`, `_`, and `-`.\n\nAny other character, including space, will be replaced by `_`.\n\n\n- `purgeCache?: boolean`\n Option to purge cache for the old file and its versions' URLs.\n\nWhen set to true, it will internally issue a purge cache request on CDN to remove cached content of old file and its versions. This purge request is counted against your monthly purge quota.\n\nNote: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard at the end). It will remove the file and its versions' URLs and any transformations made using query parameters on this file or its versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation.\n\n\n\nDefault value - `false`\n\n\n### Returns\n\n- `{ purgeRequestId?: string; }`\n\n - `purgeRequestId?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.rename({ filePath: '/path/to/file.jpg', newFileName: 'newFileName.jpg' });\n\nconsole.log(response);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.rename", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.rename({\n filePath: '/path/to/file.jpg',\n newFileName: 'newFileName.jpg',\n});\n\nconsole.log(response.purgeRequestId);" + }, + "python": { + "method": "files.rename", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.rename(\n file_path=\"/path/to/file.jpg\",\n new_file_name=\"newFileName.jpg\",\n)\nprint(response.purge_request_id)" + }, + "java": { + "method": "files().rename", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileRenameParams;\nimport io.imagekit.models.files.FileRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileRenameParams params = FileRenameParams.builder()\n .filePath(\"/path/to/file.jpg\")\n .newFileName(\"newFileName.jpg\")\n .build();\n FileRenameResponse response = client.files().rename(params);\n }\n}" + }, + "kotlin": { + "method": "files().rename", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileRenameParams\nimport com.imagekit.api.models.files.FileRenameResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileRenameParams = FileRenameParams.builder()\n .filePath(\"/path/to/file.jpg\")\n .newFileName(\"newFileName.jpg\")\n .build()\n val response: FileRenameResponse = client.files().rename(params)\n}" + }, + "go": { + "method": "client.Files.Rename", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Rename(context.TODO(), imagekit.FileRenameParams{\n\t\tFilePath: \"/path/to/file.jpg\",\n\t\tNewFileName: \"newFileName.jpg\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.PurgeRequestID)\n}\n" + }, + "ruby": { + "method": "files.rename", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.rename(file_path: \"/path/to/file.jpg\", new_file_name: \"newFileName.jpg\")\n\nputs(response)" + }, + "cli": { + "method": "files rename", + "example": "imagekit files rename \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-path /path/to/file.jpg \\\n --new-file-name newFileName.jpg" + }, + "php": { + "method": "files->rename", + "example": "files->rename(\n filePath: '/path/to/file.jpg',\n newFileName: 'newFileName.jpg',\n purgeCache: true,\n);\n\nvar_dump($response);" + }, + "csharp": { + "method": "Files.Rename", + "example": "FileRenameParams parameters = new()\n{\n FilePath = \"/path/to/file.jpg\",\n NewFileName = \"newFileName.jpg\",\n};\n\nvar response = await client.Files.Rename(parameters);\n\nConsole.WriteLine(response);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/rename \\\n -X PUT \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"filePath\": \"/path/to/file.jpg\",\n \"newFileName\": \"newFileName.jpg\",\n \"purgeCache\": true\n }'" + } + } }, { - name: 'delete', - endpoint: '/v1/files/batch/deleteByFileIds', - httpMethod: 'post', - summary: 'Delete multiple files', - description: - 'This API deletes multiple files and all their file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\nA maximum of 100 files can be deleted at a time.\n', - stainlessPath: '(resource) files.bulk > (method) delete', - qualified: 'client.files.bulk.delete', - params: ['fileIds: string[];'], - response: '{ successfullyDeletedFileIds?: string[]; }', - markdown: - "## delete\n\n`client.files.bulk.delete(fileIds: string[]): { successfullyDeletedFileIds?: string[]; }`\n\n**post** `/v1/files/batch/deleteByFileIds`\n\nThis API deletes multiple files and all their file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\nA maximum of 100 files can be deleted at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds which you want to delete.\n\n\n### Returns\n\n- `{ successfullyDeletedFileIds?: string[]; }`\n\n - `successfullyDeletedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst bulk = await client.files.bulk.delete({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] });\n\nconsole.log(bulk);\n```", - perLanguage: { - typescript: { - method: 'client.files.bulk.delete', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst bulk = await client.files.bulk.delete({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n});\n\nconsole.log(bulk.successfullyDeletedFileIds);", - }, - python: { - method: 'files.bulk.delete', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nbulk = client.files.bulk.delete(\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n)\nprint(bulk.successfully_deleted_file_ids)', - }, - java: { - method: 'files().bulk().delete', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkDeleteParams;\nimport io.imagekit.models.files.bulk.BulkDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkDeleteParams params = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkDeleteResponse bulk = client.files().bulk().delete(params);\n }\n}', - }, - kotlin: { - method: 'files().bulk().delete', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkDeleteParams\nimport com.imagekit.api.models.files.bulk.BulkDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkDeleteParams = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build()\n val bulk: BulkDeleteResponse = client.files().bulk().delete(params)\n}', - }, - go: { - method: 'client.Files.Bulk.Delete', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tbulk, err := client.Files.Bulk.Delete(context.TODO(), imagekit.FileBulkDeleteParams{\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", bulk.SuccessfullyDeletedFileIDs)\n}\n', - }, - ruby: { - method: 'files.bulk.delete', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nbulk = image_kit.files.bulk.delete(file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"])\n\nputs(bulk)', - }, - cli: { - method: 'bulk delete', - example: - "imagekit files:bulk delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be", - }, - php: { - method: 'files->bulk->delete', - example: - "files->bulk->delete(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be']\n);\n\nvar_dump($bulk);", - }, - csharp: { - method: 'Files.Bulk.Delete', - example: - 'BulkDeleteParams parameters = new()\n{\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n};\n\nvar bulk = await client.Files.Bulk.Delete(parameters);\n\nConsole.WriteLine(bulk);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/batch/deleteByFileIds \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ]\n }\'', - }, - }, + "name": "delete", + "endpoint": "/v1/files/batch/deleteByFileIds", + "httpMethod": "post", + "summary": "Delete multiple files", + "description": "This API deletes multiple files and all their file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\nA maximum of 100 files can be deleted at a time.\n", + "stainlessPath": "(resource) files.bulk > (method) delete", + "qualified": "client.files.bulk.delete", + "params": [ + "fileIds: string[];" + ], + "response": "{ successfullyDeletedFileIds?: string[]; }", + "markdown": "## delete\n\n`client.files.bulk.delete(fileIds: string[]): { successfullyDeletedFileIds?: string[]; }`\n\n**post** `/v1/files/batch/deleteByFileIds`\n\nThis API deletes multiple files and all their file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\nA maximum of 100 files can be deleted at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds which you want to delete.\n\n\n### Returns\n\n- `{ successfullyDeletedFileIds?: string[]; }`\n\n - `successfullyDeletedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst bulk = await client.files.bulk.delete({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] });\n\nconsole.log(bulk);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.bulk.delete", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst bulk = await client.files.bulk.delete({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n});\n\nconsole.log(bulk.successfullyDeletedFileIds);" + }, + "python": { + "method": "files.bulk.delete", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nbulk = client.files.bulk.delete(\n file_ids=[\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"],\n)\nprint(bulk.successfully_deleted_file_ids)" + }, + "java": { + "method": "files().bulk().delete", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkDeleteParams;\nimport io.imagekit.models.files.bulk.BulkDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkDeleteParams params = BulkDeleteParams.builder()\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .build();\n BulkDeleteResponse bulk = client.files().bulk().delete(params);\n }\n}" + }, + "kotlin": { + "method": "files().bulk().delete", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkDeleteParams\nimport com.imagekit.api.models.files.bulk.BulkDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkDeleteParams = BulkDeleteParams.builder()\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .build()\n val bulk: BulkDeleteResponse = client.files().bulk().delete(params)\n}" + }, + "go": { + "method": "client.Files.Bulk.Delete", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tbulk, err := client.Files.Bulk.Delete(context.TODO(), imagekit.FileBulkDeleteParams{\n\t\tFileIDs: []string{\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", bulk.SuccessfullyDeletedFileIDs)\n}\n" + }, + "ruby": { + "method": "files.bulk.delete", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nbulk = image_kit.files.bulk.delete(file_ids: [\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"])\n\nputs(bulk)" + }, + "cli": { + "method": "bulk delete", + "example": "imagekit files:bulk delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be" + }, + "php": { + "method": "files->bulk->delete", + "example": "files->bulk->delete(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be']\n);\n\nvar_dump($bulk);" + }, + "csharp": { + "method": "Files.Bulk.Delete", + "example": "BulkDeleteParams parameters = new()\n{\n FileIds =\n [\n \"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"\n ],\n};\n\nvar bulk = await client.Files.Bulk.Delete(parameters);\n\nConsole.WriteLine(bulk);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/batch/deleteByFileIds \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"fileIds\": [\n \"598821f949c0a938d57563bd\",\n \"598821f949c0a938d57563be\"\n ]\n }'" + } + } }, { - name: 'addTags', - endpoint: '/v1/files/addTags', - httpMethod: 'post', - summary: 'Add tags (bulk)', - description: - 'This API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a time.\n', - stainlessPath: '(resource) files.bulk > (method) addTags', - qualified: 'client.files.bulk.addTags', - params: ['fileIds: string[];', 'tags: string[];'], - response: '{ successfullyUpdatedFileIds?: string[]; }', - markdown: - "## addTags\n\n`client.files.bulk.addTags(fileIds: string[], tags: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/addTags`\n\nThis API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds to which you want to add tags.\n\n\n- `tags: string[]`\n An array of tags that you want to add to the files.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.addTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] });\n\nconsole.log(response);\n```", - perLanguage: { - typescript: { - method: 'client.files.bulk.addTags', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.addTags({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);", - }, - python: { - method: 'files.bulk.add_tags', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.add_tags(\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags=["t-shirt", "round-neck", "sale2019"],\n)\nprint(response.successfully_updated_file_ids)', - }, - java: { - method: 'files().bulk().addTags', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkAddTagsParams;\nimport io.imagekit.models.files.bulk.BulkAddTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkAddTagsParams params = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkAddTagsResponse response = client.files().bulk().addTags(params);\n }\n}', - }, - kotlin: { - method: 'files().bulk().addTags', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkAddTagsParams\nimport com.imagekit.api.models.files.bulk.BulkAddTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkAddTagsParams = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(listOf(\n "t-shirt",\n "round-neck",\n "sale2019",\n ))\n .build()\n val response: BulkAddTagsResponse = client.files().bulk().addTags(params)\n}', - }, - go: { - method: 'client.Files.Bulk.AddTags', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Bulk.AddTags(context.TODO(), imagekit.FileBulkAddTagsParams{\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t\tTags: []string{"t-shirt", "round-neck", "sale2019"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.SuccessfullyUpdatedFileIDs)\n}\n', - }, - ruby: { - method: 'files.bulk.add_tags', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.bulk.add_tags(\n file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags: ["t-shirt", "round-neck", "sale2019"]\n)\n\nputs(response)', - }, - cli: { - method: 'bulk addTags', - example: - "imagekit files:bulk add-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be \\\n --tag t-shirt \\\n --tag round-neck \\\n --tag sale2019", - }, - php: { - method: 'files->bulk->addTags', - example: - "files->bulk->addTags(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n);\n\nvar_dump($response);", - }, - csharp: { - method: 'Files.Bulk.AddTags', - example: - 'BulkAddTagsParams parameters = new()\n{\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n Tags =\n [\n "t-shirt", "round-neck", "sale2019"\n ],\n};\n\nvar response = await client.Files.Bulk.AddTags(parameters);\n\nConsole.WriteLine(response);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/addTags \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ],\n "tags": [\n "t-shirt",\n "round-neck",\n "sale2019"\n ]\n }\'', - }, - }, + "name": "addTags", + "endpoint": "/v1/files/addTags", + "httpMethod": "post", + "summary": "Add tags (bulk)", + "description": "This API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a time.\n", + "stainlessPath": "(resource) files.bulk > (method) addTags", + "qualified": "client.files.bulk.addTags", + "params": [ + "fileIds: string[];", + "tags: string[];" + ], + "response": "{ successfullyUpdatedFileIds?: string[]; }", + "markdown": "## addTags\n\n`client.files.bulk.addTags(fileIds: string[], tags: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/addTags`\n\nThis API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds to which you want to add tags.\n\n\n- `tags: string[]`\n An array of tags that you want to add to the files.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.addTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] });\n\nconsole.log(response);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.bulk.addTags", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.addTags({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);" + }, + "python": { + "method": "files.bulk.add_tags", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.add_tags(\n file_ids=[\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"],\n tags=[\"t-shirt\", \"round-neck\", \"sale2019\"],\n)\nprint(response.successfully_updated_file_ids)" + }, + "java": { + "method": "files().bulk().addTags", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkAddTagsParams;\nimport io.imagekit.models.files.bulk.BulkAddTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkAddTagsParams params = BulkAddTagsParams.builder()\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .tags(List.of(\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\"\n ))\n .build();\n BulkAddTagsResponse response = client.files().bulk().addTags(params);\n }\n}" + }, + "kotlin": { + "method": "files().bulk().addTags", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkAddTagsParams\nimport com.imagekit.api.models.files.bulk.BulkAddTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkAddTagsParams = BulkAddTagsParams.builder()\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .tags(listOf(\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\",\n ))\n .build()\n val response: BulkAddTagsResponse = client.files().bulk().addTags(params)\n}" + }, + "go": { + "method": "client.Files.Bulk.AddTags", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Bulk.AddTags(context.TODO(), imagekit.FileBulkAddTagsParams{\n\t\tFileIDs: []string{\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"},\n\t\tTags: []string{\"t-shirt\", \"round-neck\", \"sale2019\"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.SuccessfullyUpdatedFileIDs)\n}\n" + }, + "ruby": { + "method": "files.bulk.add_tags", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.bulk.add_tags(\n file_ids: [\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"],\n tags: [\"t-shirt\", \"round-neck\", \"sale2019\"]\n)\n\nputs(response)" + }, + "cli": { + "method": "bulk addTags", + "example": "imagekit files:bulk add-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be \\\n --tag t-shirt \\\n --tag round-neck \\\n --tag sale2019" + }, + "php": { + "method": "files->bulk->addTags", + "example": "files->bulk->addTags(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n);\n\nvar_dump($response);" + }, + "csharp": { + "method": "Files.Bulk.AddTags", + "example": "BulkAddTagsParams parameters = new()\n{\n FileIds =\n [\n \"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"\n ],\n Tags =\n [\n \"t-shirt\", \"round-neck\", \"sale2019\"\n ],\n};\n\nvar response = await client.Files.Bulk.AddTags(parameters);\n\nConsole.WriteLine(response);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/addTags \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"fileIds\": [\n \"598821f949c0a938d57563bd\",\n \"598821f949c0a938d57563be\"\n ],\n \"tags\": [\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\"\n ]\n }'" + } + } }, { - name: 'removeTags', - endpoint: '/v1/files/removeTags', - httpMethod: 'post', - summary: 'Remove tags (bulk)', - description: - 'This API removes tags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n', - stainlessPath: '(resource) files.bulk > (method) removeTags', - qualified: 'client.files.bulk.removeTags', - params: ['fileIds: string[];', 'tags: string[];'], - response: '{ successfullyUpdatedFileIds?: string[]; }', - markdown: - "## removeTags\n\n`client.files.bulk.removeTags(fileIds: string[], tags: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/removeTags`\n\nThis API removes tags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds from which you want to remove tags.\n\n\n- `tags: string[]`\n An array of tags that you want to remove from the files.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.removeTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] });\n\nconsole.log(response);\n```", - perLanguage: { - typescript: { - method: 'client.files.bulk.removeTags', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.removeTags({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);", - }, - python: { - method: 'files.bulk.remove_tags', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.remove_tags(\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags=["t-shirt", "round-neck", "sale2019"],\n)\nprint(response.successfully_updated_file_ids)', - }, - java: { - method: 'files().bulk().removeTags', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkRemoveTagsParams;\nimport io.imagekit.models.files.bulk.BulkRemoveTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveTagsParams params = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkRemoveTagsResponse response = client.files().bulk().removeTags(params);\n }\n}', - }, - kotlin: { - method: 'files().bulk().removeTags', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsParams\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkRemoveTagsParams = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(listOf(\n "t-shirt",\n "round-neck",\n "sale2019",\n ))\n .build()\n val response: BulkRemoveTagsResponse = client.files().bulk().removeTags(params)\n}', - }, - go: { - method: 'client.Files.Bulk.RemoveTags', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Bulk.RemoveTags(context.TODO(), imagekit.FileBulkRemoveTagsParams{\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t\tTags: []string{"t-shirt", "round-neck", "sale2019"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.SuccessfullyUpdatedFileIDs)\n}\n', - }, - ruby: { - method: 'files.bulk.remove_tags', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.bulk.remove_tags(\n file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags: ["t-shirt", "round-neck", "sale2019"]\n)\n\nputs(response)', - }, - cli: { - method: 'bulk removeTags', - example: - "imagekit files:bulk remove-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be \\\n --tag t-shirt \\\n --tag round-neck \\\n --tag sale2019", - }, - php: { - method: 'files->bulk->removeTags', - example: - "files->bulk->removeTags(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n);\n\nvar_dump($response);", - }, - csharp: { - method: 'Files.Bulk.RemoveTags', - example: - 'BulkRemoveTagsParams parameters = new()\n{\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n Tags =\n [\n "t-shirt", "round-neck", "sale2019"\n ],\n};\n\nvar response = await client.Files.Bulk.RemoveTags(parameters);\n\nConsole.WriteLine(response);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/removeTags \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ],\n "tags": [\n "t-shirt",\n "round-neck",\n "sale2019"\n ]\n }\'', - }, - }, + "name": "removeTags", + "endpoint": "/v1/files/removeTags", + "httpMethod": "post", + "summary": "Remove tags (bulk)", + "description": "This API removes tags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n", + "stainlessPath": "(resource) files.bulk > (method) removeTags", + "qualified": "client.files.bulk.removeTags", + "params": [ + "fileIds: string[];", + "tags: string[];" + ], + "response": "{ successfullyUpdatedFileIds?: string[]; }", + "markdown": "## removeTags\n\n`client.files.bulk.removeTags(fileIds: string[], tags: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/removeTags`\n\nThis API removes tags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds from which you want to remove tags.\n\n\n- `tags: string[]`\n An array of tags that you want to remove from the files.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.removeTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] });\n\nconsole.log(response);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.bulk.removeTags", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.removeTags({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);" + }, + "python": { + "method": "files.bulk.remove_tags", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.remove_tags(\n file_ids=[\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"],\n tags=[\"t-shirt\", \"round-neck\", \"sale2019\"],\n)\nprint(response.successfully_updated_file_ids)" + }, + "java": { + "method": "files().bulk().removeTags", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkRemoveTagsParams;\nimport io.imagekit.models.files.bulk.BulkRemoveTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveTagsParams params = BulkRemoveTagsParams.builder()\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .tags(List.of(\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\"\n ))\n .build();\n BulkRemoveTagsResponse response = client.files().bulk().removeTags(params);\n }\n}" + }, + "kotlin": { + "method": "files().bulk().removeTags", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsParams\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkRemoveTagsParams = BulkRemoveTagsParams.builder()\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .tags(listOf(\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\",\n ))\n .build()\n val response: BulkRemoveTagsResponse = client.files().bulk().removeTags(params)\n}" + }, + "go": { + "method": "client.Files.Bulk.RemoveTags", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Bulk.RemoveTags(context.TODO(), imagekit.FileBulkRemoveTagsParams{\n\t\tFileIDs: []string{\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"},\n\t\tTags: []string{\"t-shirt\", \"round-neck\", \"sale2019\"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.SuccessfullyUpdatedFileIDs)\n}\n" + }, + "ruby": { + "method": "files.bulk.remove_tags", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.bulk.remove_tags(\n file_ids: [\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"],\n tags: [\"t-shirt\", \"round-neck\", \"sale2019\"]\n)\n\nputs(response)" + }, + "cli": { + "method": "bulk removeTags", + "example": "imagekit files:bulk remove-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be \\\n --tag t-shirt \\\n --tag round-neck \\\n --tag sale2019" + }, + "php": { + "method": "files->bulk->removeTags", + "example": "files->bulk->removeTags(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n);\n\nvar_dump($response);" + }, + "csharp": { + "method": "Files.Bulk.RemoveTags", + "example": "BulkRemoveTagsParams parameters = new()\n{\n FileIds =\n [\n \"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"\n ],\n Tags =\n [\n \"t-shirt\", \"round-neck\", \"sale2019\"\n ],\n};\n\nvar response = await client.Files.Bulk.RemoveTags(parameters);\n\nConsole.WriteLine(response);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/removeTags \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"fileIds\": [\n \"598821f949c0a938d57563bd\",\n \"598821f949c0a938d57563be\"\n ],\n \"tags\": [\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\"\n ]\n }'" + } + } }, { - name: 'removeAiTags', - endpoint: '/v1/files/removeAITags', - httpMethod: 'post', - summary: 'Remove AI tags (bulk)', - description: - 'This API removes AITags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n', - stainlessPath: '(resource) files.bulk > (method) removeAiTags', - qualified: 'client.files.bulk.removeAITags', - params: ['AITags: string[];', 'fileIds: string[];'], - response: '{ successfullyUpdatedFileIds?: string[]; }', - markdown: - "## removeAiTags\n\n`client.files.bulk.removeAITags(AITags: string[], fileIds: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/removeAITags`\n\nThis API removes AITags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `AITags: string[]`\n An array of AITags that you want to remove from the files.\n\n\n- `fileIds: string[]`\n An array of fileIds from which you want to remove AITags.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.removeAITags({ AITags: ['t-shirt', 'round-neck', 'sale2019'], fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] });\n\nconsole.log(response);\n```", - perLanguage: { - typescript: { - method: 'client.files.bulk.removeAITags', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.removeAITags({\n AITags: ['t-shirt', 'round-neck', 'sale2019'],\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);", - }, - python: { - method: 'files.bulk.remove_ai_tags', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.remove_ai_tags(\n ai_tags=["t-shirt", "round-neck", "sale2019"],\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n)\nprint(response.successfully_updated_file_ids)', - }, - java: { - method: 'files().bulk().removeAiTags', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkRemoveAiTagsParams;\nimport io.imagekit.models.files.bulk.BulkRemoveAiTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveAiTagsParams params = BulkRemoveAiTagsParams.builder()\n .aiTags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkRemoveAiTagsResponse response = client.files().bulk().removeAiTags(params);\n }\n}', - }, - kotlin: { - method: 'files().bulk().removeAiTags', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkRemoveAiTagsParams = BulkRemoveAiTagsParams.builder()\n .aiTags(listOf(\n "t-shirt",\n "round-neck",\n "sale2019",\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build()\n val response: BulkRemoveAiTagsResponse = client.files().bulk().removeAiTags(params)\n}', - }, - go: { - method: 'client.Files.Bulk.RemoveAITags', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Bulk.RemoveAITags(context.TODO(), imagekit.FileBulkRemoveAITagsParams{\n\t\tAITags: []string{"t-shirt", "round-neck", "sale2019"},\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.SuccessfullyUpdatedFileIDs)\n}\n', - }, - ruby: { - method: 'files.bulk.remove_ai_tags', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.bulk.remove_ai_tags(\n ai_tags: ["t-shirt", "round-neck", "sale2019"],\n file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"]\n)\n\nputs(response)', - }, - cli: { - method: 'bulk removeAiTags', - example: - "imagekit files:bulk remove-ai-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --ai-tag t-shirt \\\n --ai-tag round-neck \\\n --ai-tag sale2019 \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be", - }, - php: { - method: 'files->bulk->removeAITags', - example: - "files->bulk->removeAITags(\n aiTags: ['t-shirt', 'round-neck', 'sale2019'],\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n);\n\nvar_dump($response);", - }, - csharp: { - method: 'Files.Bulk.RemoveAITags', - example: - 'BulkRemoveAITagsParams parameters = new()\n{\n AITags =\n [\n "t-shirt", "round-neck", "sale2019"\n ],\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n};\n\nvar response = await client.Files.Bulk.RemoveAITags(parameters);\n\nConsole.WriteLine(response);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/removeAITags \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "AITags": [\n "t-shirt",\n "round-neck",\n "sale2019"\n ],\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ]\n }\'', - }, - }, + "name": "removeAiTags", + "endpoint": "/v1/files/removeAITags", + "httpMethod": "post", + "summary": "Remove AI tags (bulk)", + "description": "This API removes AITags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n", + "stainlessPath": "(resource) files.bulk > (method) removeAiTags", + "qualified": "client.files.bulk.removeAITags", + "params": [ + "AITags: string[];", + "fileIds: string[];" + ], + "response": "{ successfullyUpdatedFileIds?: string[]; }", + "markdown": "## removeAiTags\n\n`client.files.bulk.removeAITags(AITags: string[], fileIds: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/removeAITags`\n\nThis API removes AITags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `AITags: string[]`\n An array of AITags that you want to remove from the files.\n\n\n- `fileIds: string[]`\n An array of fileIds from which you want to remove AITags.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.removeAITags({ AITags: ['t-shirt', 'round-neck', 'sale2019'], fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] });\n\nconsole.log(response);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.bulk.removeAITags", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.removeAITags({\n AITags: ['t-shirt', 'round-neck', 'sale2019'],\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);" + }, + "python": { + "method": "files.bulk.remove_ai_tags", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.remove_ai_tags(\n ai_tags=[\"t-shirt\", \"round-neck\", \"sale2019\"],\n file_ids=[\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"],\n)\nprint(response.successfully_updated_file_ids)" + }, + "java": { + "method": "files().bulk().removeAiTags", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkRemoveAiTagsParams;\nimport io.imagekit.models.files.bulk.BulkRemoveAiTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveAiTagsParams params = BulkRemoveAiTagsParams.builder()\n .aiTags(List.of(\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\"\n ))\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .build();\n BulkRemoveAiTagsResponse response = client.files().bulk().removeAiTags(params);\n }\n}" + }, + "kotlin": { + "method": "files().bulk().removeAiTags", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkRemoveAiTagsParams = BulkRemoveAiTagsParams.builder()\n .aiTags(listOf(\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\",\n ))\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .build()\n val response: BulkRemoveAiTagsResponse = client.files().bulk().removeAiTags(params)\n}" + }, + "go": { + "method": "client.Files.Bulk.RemoveAITags", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Bulk.RemoveAITags(context.TODO(), imagekit.FileBulkRemoveAITagsParams{\n\t\tAITags: []string{\"t-shirt\", \"round-neck\", \"sale2019\"},\n\t\tFileIDs: []string{\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.SuccessfullyUpdatedFileIDs)\n}\n" + }, + "ruby": { + "method": "files.bulk.remove_ai_tags", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.bulk.remove_ai_tags(\n ai_tags: [\"t-shirt\", \"round-neck\", \"sale2019\"],\n file_ids: [\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"]\n)\n\nputs(response)" + }, + "cli": { + "method": "bulk removeAiTags", + "example": "imagekit files:bulk remove-ai-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --ai-tag t-shirt \\\n --ai-tag round-neck \\\n --ai-tag sale2019 \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be" + }, + "php": { + "method": "files->bulk->removeAITags", + "example": "files->bulk->removeAITags(\n aiTags: ['t-shirt', 'round-neck', 'sale2019'],\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n);\n\nvar_dump($response);" + }, + "csharp": { + "method": "Files.Bulk.RemoveAITags", + "example": "BulkRemoveAITagsParams parameters = new()\n{\n AITags =\n [\n \"t-shirt\", \"round-neck\", \"sale2019\"\n ],\n FileIds =\n [\n \"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"\n ],\n};\n\nvar response = await client.Files.Bulk.RemoveAITags(parameters);\n\nConsole.WriteLine(response);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/removeAITags \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"AITags\": [\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\"\n ],\n \"fileIds\": [\n \"598821f949c0a938d57563bd\",\n \"598821f949c0a938d57563be\"\n ]\n }'" + } + } }, { - name: 'list', - endpoint: '/v1/files/{fileId}/versions', - httpMethod: 'get', - summary: 'List file versions', - description: 'This API returns details of all versions of a file.\n', - stainlessPath: '(resource) files.versions > (method) list', - qualified: 'client.files.versions.list', - params: ['fileId: string;'], - response: - "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }[]", - markdown: - "## list\n\n`client.files.versions.list(fileId: string): object[]`\n\n**get** `/v1/files/{fileId}/versions`\n\nThis API returns details of all versions of a file.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst files = await client.files.versions.list('fileId');\n\nconsole.log(files);\n```", - perLanguage: { - typescript: { - method: 'client.files.versions.list', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst files = await client.files.versions.list('fileId');\n\nconsole.log(files);", - }, - python: { - method: 'files.versions.list', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfiles = client.files.versions.list(\n "fileId",\n)\nprint(files)', - }, - java: { - method: 'files().versions().list', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List files = client.files().versions().list("fileId");\n }\n}', - }, - kotlin: { - method: 'files().versions().list', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val files: List = client.files().versions().list("fileId")\n}', - }, - go: { - method: 'client.Files.Versions.List', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfiles, err := client.Files.Versions.List(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", files)\n}\n', - }, - ruby: { - method: 'files.versions.list', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfiles = image_kit.files.versions.list("fileId")\n\nputs(files)', - }, - cli: { - method: 'versions list', - example: - "imagekit files:versions list \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", - }, - php: { - method: 'files->versions->list', - example: - "files->versions->list('fileId');\n\nvar_dump($files);", - }, - csharp: { - method: 'Files.Versions.List', - example: - 'VersionListParams parameters = new() { FileID = "fileId" };\n\nvar files = await client.Files.Versions.List(parameters);\n\nConsole.WriteLine(files);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "list", + "endpoint": "/v1/files/{fileId}/versions", + "httpMethod": "get", + "summary": "List file versions", + "description": "This API returns details of all versions of a file.\n", + "stainlessPath": "(resource) files.versions > (method) list", + "qualified": "client.files.versions.list", + "params": [ + "fileId: string;" + ], + "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }[]", + "markdown": "## list\n\n`client.files.versions.list(fileId: string): object[]`\n\n**get** `/v1/files/{fileId}/versions`\n\nThis API returns details of all versions of a file.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst files = await client.files.versions.list('fileId');\n\nconsole.log(files);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.versions.list", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst files = await client.files.versions.list('fileId');\n\nconsole.log(files);" + }, + "python": { + "method": "files.versions.list", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfiles = client.files.versions.list(\n \"fileId\",\n)\nprint(files)" + }, + "java": { + "method": "files().versions().list", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List files = client.files().versions().list(\"fileId\");\n }\n}" + }, + "kotlin": { + "method": "files().versions().list", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val files: List = client.files().versions().list(\"fileId\")\n}" + }, + "go": { + "method": "client.Files.Versions.List", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfiles, err := client.Files.Versions.List(context.TODO(), \"fileId\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", files)\n}\n" + }, + "ruby": { + "method": "files.versions.list", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfiles = image_kit.files.versions.list(\"fileId\")\n\nputs(files)" + }, + "cli": { + "method": "versions list", + "example": "imagekit files:versions list \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId" + }, + "php": { + "method": "files->versions->list", + "example": "files->versions->list('fileId');\n\nvar_dump($files);" + }, + "csharp": { + "method": "Files.Versions.List", + "example": "VersionListParams parameters = new() { FileID = \"fileId\" };\n\nvar files = await client.Files.Versions.List(parameters);\n\nConsole.WriteLine(files);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/versions \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'get', - endpoint: '/v1/files/{fileId}/versions/{versionId}', - httpMethod: 'get', - summary: 'Get file version details', - description: 'This API returns an object with details or attributes of a file version.', - stainlessPath: '(resource) files.versions > (method) get', - qualified: 'client.files.versions.get', - params: ['fileId: string;', 'versionId: string;'], - response: - "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", - markdown: - "## get\n\n`client.files.versions.get(fileId: string, versionId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/versions/{versionId}`\n\nThis API returns an object with details or attributes of a file version.\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.versions.get('versionId', { fileId: 'fileId' });\n\nconsole.log(file);\n```", - perLanguage: { - typescript: { - method: 'client.files.versions.get', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.versions.get('versionId', { fileId: 'fileId' });\n\nconsole.log(file.videoCodec);", - }, - python: { - method: 'files.versions.get', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.versions.get(\n version_id="versionId",\n file_id="fileId",\n)\nprint(file.video_codec)', - }, - java: { - method: 'files().versions().get', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionGetParams params = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().get(params);\n }\n}', - }, - kotlin: { - method: 'files().versions().get', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionGetParams = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build()\n val file: File = client.files().versions().get(params)\n}', - }, - go: { - method: 'client.Files.Versions.Get', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Versions.Get(\n\t\tcontext.TODO(),\n\t\t"versionId",\n\t\timagekit.FileVersionGetParams{\n\t\t\tFileID: "fileId",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file.VideoCodec)\n}\n', - }, - ruby: { - method: 'files.versions.get', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfile = image_kit.files.versions.get("versionId", file_id: "fileId")\n\nputs(file)', - }, - cli: { - method: 'versions get', - example: - "imagekit files:versions get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId", - }, - php: { - method: 'files->versions->get', - example: - "files->versions->get('versionId', fileID: 'fileId');\n\nvar_dump($file);", - }, - csharp: { - method: 'Files.Versions.Get', - example: - 'VersionGetParams parameters = new()\n{\n FileID = "fileId",\n VersionID = "versionId",\n};\n\nvar file = await client.Files.Versions.Get(parameters);\n\nConsole.WriteLine(file);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "get", + "endpoint": "/v1/files/{fileId}/versions/{versionId}", + "httpMethod": "get", + "summary": "Get file version details", + "description": "This API returns an object with details or attributes of a file version.", + "stainlessPath": "(resource) files.versions > (method) get", + "qualified": "client.files.versions.get", + "params": [ + "fileId: string;", + "versionId: string;" + ], + "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", + "markdown": "## get\n\n`client.files.versions.get(fileId: string, versionId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/versions/{versionId}`\n\nThis API returns an object with details or attributes of a file version.\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.versions.get('versionId', { fileId: 'fileId' });\n\nconsole.log(file);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.versions.get", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.versions.get('versionId', { fileId: 'fileId' });\n\nconsole.log(file.videoCodec);" + }, + "python": { + "method": "files.versions.get", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfile = client.files.versions.get(\n version_id=\"versionId\",\n file_id=\"fileId\",\n)\nprint(file.video_codec)" + }, + "java": { + "method": "files().versions().get", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionGetParams params = VersionGetParams.builder()\n .fileId(\"fileId\")\n .versionId(\"versionId\")\n .build();\n File file = client.files().versions().get(params);\n }\n}" + }, + "kotlin": { + "method": "files().versions().get", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionGetParams = VersionGetParams.builder()\n .fileId(\"fileId\")\n .versionId(\"versionId\")\n .build()\n val file: File = client.files().versions().get(params)\n}" + }, + "go": { + "method": "client.Files.Versions.Get", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfile, err := client.Files.Versions.Get(\n\t\tcontext.TODO(),\n\t\t\"versionId\",\n\t\timagekit.FileVersionGetParams{\n\t\t\tFileID: \"fileId\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", file.VideoCodec)\n}\n" + }, + "ruby": { + "method": "files.versions.get", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfile = image_kit.files.versions.get(\"versionId\", file_id: \"fileId\")\n\nputs(file)" + }, + "cli": { + "method": "versions get", + "example": "imagekit files:versions get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId" + }, + "php": { + "method": "files->versions->get", + "example": "files->versions->get('versionId', fileID: 'fileId');\n\nvar_dump($file);" + }, + "csharp": { + "method": "Files.Versions.Get", + "example": "VersionGetParams parameters = new()\n{\n FileID = \"fileId\",\n VersionID = \"versionId\",\n};\n\nvar file = await client.Files.Versions.Get(parameters);\n\nConsole.WriteLine(file);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'delete', - endpoint: '/v1/files/{fileId}/versions/{versionId}', - httpMethod: 'delete', - summary: 'Delete file version', - description: - 'This API deletes a non-current file version permanently. The API returns an empty response.\n\nNote: If you want to delete all versions of a file, use the delete file API.\n', - stainlessPath: '(resource) files.versions > (method) delete', - qualified: 'client.files.versions.delete', - params: ['fileId: string;', 'versionId: string;'], - response: '{ }', - markdown: - "## delete\n\n`client.files.versions.delete(fileId: string, versionId: string): { }`\n\n**delete** `/v1/files/{fileId}/versions/{versionId}`\n\nThis API deletes a non-current file version permanently. The API returns an empty response.\n\nNote: If you want to delete all versions of a file, use the delete file API.\n\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst version = await client.files.versions.delete('versionId', { fileId: 'fileId' });\n\nconsole.log(version);\n```", - perLanguage: { - typescript: { - method: 'client.files.versions.delete', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst version = await client.files.versions.delete('versionId', { fileId: 'fileId' });\n\nconsole.log(version);", - }, - python: { - method: 'files.versions.delete', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nversion = client.files.versions.delete(\n version_id="versionId",\n file_id="fileId",\n)\nprint(version)', - }, - java: { - method: 'files().versions().delete', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.versions.VersionDeleteParams;\nimport io.imagekit.models.files.versions.VersionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionDeleteParams params = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n VersionDeleteResponse version = client.files().versions().delete(params);\n }\n}', - }, - kotlin: { - method: 'files().versions().delete', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.versions.VersionDeleteParams\nimport com.imagekit.api.models.files.versions.VersionDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionDeleteParams = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build()\n val version: VersionDeleteResponse = client.files().versions().delete(params)\n}', - }, - go: { - method: 'client.Files.Versions.Delete', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tversion, err := client.Files.Versions.Delete(\n\t\tcontext.TODO(),\n\t\t"versionId",\n\t\timagekit.FileVersionDeleteParams{\n\t\t\tFileID: "fileId",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", version)\n}\n', - }, - ruby: { - method: 'files.versions.delete', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nversion = image_kit.files.versions.delete("versionId", file_id: "fileId")\n\nputs(version)', - }, - cli: { - method: 'versions delete', - example: - "imagekit files:versions delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId", - }, - php: { - method: 'files->versions->delete', - example: - "files->versions->delete('versionId', fileID: 'fileId');\n\nvar_dump($version);", - }, - csharp: { - method: 'Files.Versions.Delete', - example: - 'VersionDeleteParams parameters = new()\n{\n FileID = "fileId",\n VersionID = "versionId",\n};\n\nvar version = await client.Files.Versions.Delete(parameters);\n\nConsole.WriteLine(version);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "delete", + "endpoint": "/v1/files/{fileId}/versions/{versionId}", + "httpMethod": "delete", + "summary": "Delete file version", + "description": "This API deletes a non-current file version permanently. The API returns an empty response.\n\nNote: If you want to delete all versions of a file, use the delete file API.\n", + "stainlessPath": "(resource) files.versions > (method) delete", + "qualified": "client.files.versions.delete", + "params": [ + "fileId: string;", + "versionId: string;" + ], + "response": "{ }", + "markdown": "## delete\n\n`client.files.versions.delete(fileId: string, versionId: string): { }`\n\n**delete** `/v1/files/{fileId}/versions/{versionId}`\n\nThis API deletes a non-current file version permanently. The API returns an empty response.\n\nNote: If you want to delete all versions of a file, use the delete file API.\n\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst version = await client.files.versions.delete('versionId', { fileId: 'fileId' });\n\nconsole.log(version);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.versions.delete", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst version = await client.files.versions.delete('versionId', { fileId: 'fileId' });\n\nconsole.log(version);" + }, + "python": { + "method": "files.versions.delete", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nversion = client.files.versions.delete(\n version_id=\"versionId\",\n file_id=\"fileId\",\n)\nprint(version)" + }, + "java": { + "method": "files().versions().delete", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.versions.VersionDeleteParams;\nimport io.imagekit.models.files.versions.VersionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionDeleteParams params = VersionDeleteParams.builder()\n .fileId(\"fileId\")\n .versionId(\"versionId\")\n .build();\n VersionDeleteResponse version = client.files().versions().delete(params);\n }\n}" + }, + "kotlin": { + "method": "files().versions().delete", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.versions.VersionDeleteParams\nimport com.imagekit.api.models.files.versions.VersionDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionDeleteParams = VersionDeleteParams.builder()\n .fileId(\"fileId\")\n .versionId(\"versionId\")\n .build()\n val version: VersionDeleteResponse = client.files().versions().delete(params)\n}" + }, + "go": { + "method": "client.Files.Versions.Delete", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tversion, err := client.Files.Versions.Delete(\n\t\tcontext.TODO(),\n\t\t\"versionId\",\n\t\timagekit.FileVersionDeleteParams{\n\t\t\tFileID: \"fileId\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", version)\n}\n" + }, + "ruby": { + "method": "files.versions.delete", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nversion = image_kit.files.versions.delete(\"versionId\", file_id: \"fileId\")\n\nputs(version)" + }, + "cli": { + "method": "versions delete", + "example": "imagekit files:versions delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId" + }, + "php": { + "method": "files->versions->delete", + "example": "files->versions->delete('versionId', fileID: 'fileId');\n\nvar_dump($version);" + }, + "csharp": { + "method": "Files.Versions.Delete", + "example": "VersionDeleteParams parameters = new()\n{\n FileID = \"fileId\",\n VersionID = \"versionId\",\n};\n\nvar version = await client.Files.Versions.Delete(parameters);\n\nConsole.WriteLine(version);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'restore', - endpoint: '/v1/files/{fileId}/versions/{versionId}/restore', - httpMethod: 'put', - summary: 'Restore file version', - description: 'This API restores a file version as the current file version.\n', - stainlessPath: '(resource) files.versions > (method) restore', - qualified: 'client.files.versions.restore', - params: ['fileId: string;', 'versionId: string;'], - response: - "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", - markdown: - "## restore\n\n`client.files.versions.restore(fileId: string, versionId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**put** `/v1/files/{fileId}/versions/{versionId}/restore`\n\nThis API restores a file version as the current file version.\n\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.versions.restore('versionId', { fileId: 'fileId' });\n\nconsole.log(file);\n```", - perLanguage: { - typescript: { - method: 'client.files.versions.restore', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.versions.restore('versionId', { fileId: 'fileId' });\n\nconsole.log(file.videoCodec);", - }, - python: { - method: 'files.versions.restore', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.versions.restore(\n version_id="versionId",\n file_id="fileId",\n)\nprint(file.video_codec)', - }, - java: { - method: 'files().versions().restore', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionRestoreParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionRestoreParams params = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().restore(params);\n }\n}', - }, - kotlin: { - method: 'files().versions().restore', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionRestoreParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionRestoreParams = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build()\n val file: File = client.files().versions().restore(params)\n}', - }, - go: { - method: 'client.Files.Versions.Restore', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Versions.Restore(\n\t\tcontext.TODO(),\n\t\t"versionId",\n\t\timagekit.FileVersionRestoreParams{\n\t\t\tFileID: "fileId",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file.VideoCodec)\n}\n', - }, - ruby: { - method: 'files.versions.restore', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfile = image_kit.files.versions.restore("versionId", file_id: "fileId")\n\nputs(file)', - }, - cli: { - method: 'versions restore', - example: - "imagekit files:versions restore \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId", - }, - php: { - method: 'files->versions->restore', - example: - "files->versions->restore('versionId', fileID: 'fileId');\n\nvar_dump($file);", - }, - csharp: { - method: 'Files.Versions.Restore', - example: - 'VersionRestoreParams parameters = new()\n{\n FileID = "fileId",\n VersionID = "versionId",\n};\n\nvar file = await client.Files.Versions.Restore(parameters);\n\nConsole.WriteLine(file);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID/restore \\\n -X PUT \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "restore", + "endpoint": "/v1/files/{fileId}/versions/{versionId}/restore", + "httpMethod": "put", + "summary": "Restore file version", + "description": "This API restores a file version as the current file version.\n", + "stainlessPath": "(resource) files.versions > (method) restore", + "qualified": "client.files.versions.restore", + "params": [ + "fileId: string;", + "versionId: string;" + ], + "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", + "markdown": "## restore\n\n`client.files.versions.restore(fileId: string, versionId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**put** `/v1/files/{fileId}/versions/{versionId}/restore`\n\nThis API restores a file version as the current file version.\n\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.versions.restore('versionId', { fileId: 'fileId' });\n\nconsole.log(file);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.versions.restore", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.versions.restore('versionId', { fileId: 'fileId' });\n\nconsole.log(file.videoCodec);" + }, + "python": { + "method": "files.versions.restore", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfile = client.files.versions.restore(\n version_id=\"versionId\",\n file_id=\"fileId\",\n)\nprint(file.video_codec)" + }, + "java": { + "method": "files().versions().restore", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionRestoreParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionRestoreParams params = VersionRestoreParams.builder()\n .fileId(\"fileId\")\n .versionId(\"versionId\")\n .build();\n File file = client.files().versions().restore(params);\n }\n}" + }, + "kotlin": { + "method": "files().versions().restore", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionRestoreParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionRestoreParams = VersionRestoreParams.builder()\n .fileId(\"fileId\")\n .versionId(\"versionId\")\n .build()\n val file: File = client.files().versions().restore(params)\n}" + }, + "go": { + "method": "client.Files.Versions.Restore", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfile, err := client.Files.Versions.Restore(\n\t\tcontext.TODO(),\n\t\t\"versionId\",\n\t\timagekit.FileVersionRestoreParams{\n\t\t\tFileID: \"fileId\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", file.VideoCodec)\n}\n" + }, + "ruby": { + "method": "files.versions.restore", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfile = image_kit.files.versions.restore(\"versionId\", file_id: \"fileId\")\n\nputs(file)" + }, + "cli": { + "method": "versions restore", + "example": "imagekit files:versions restore \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId" + }, + "php": { + "method": "files->versions->restore", + "example": "files->versions->restore('versionId', fileID: 'fileId');\n\nvar_dump($file);" + }, + "csharp": { + "method": "Files.Versions.Restore", + "example": "VersionRestoreParams parameters = new()\n{\n FileID = \"fileId\",\n VersionID = \"versionId\",\n};\n\nvar file = await client.Files.Versions.Restore(parameters);\n\nConsole.WriteLine(file);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID/restore \\\n -X PUT \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'get', - endpoint: '/v1/files/{fileId}/metadata', - httpMethod: 'get', - summary: 'Get uploaded file metadata', - description: - 'You can programmatically get image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API.\n\nYou can also get the metadata in upload API response by passing `metadata` in `responseFields` parameter.\n', - stainlessPath: '(resource) files.metadata > (method) get', - qualified: 'client.files.metadata.get', - params: ['fileId: string;'], - response: - '{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: object; gps?: object; image?: object; interoperability?: object; makernote?: object; thumbnail?: object; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }', - markdown: - "## get\n\n`client.files.metadata.get(fileId: string): { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/metadata`\n\nYou can programmatically get image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API.\n\nYou can also get the metadata in upload API response by passing `metadata` in `responseFields` parameter.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n JSON object containing metadata.\n\n - `audioCodec?: string`\n - `bitRate?: number`\n - `density?: number`\n - `duration?: number`\n - `exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }`\n - `format?: string`\n - `hasColorProfile?: boolean`\n - `hasTransparency?: boolean`\n - `height?: number`\n - `pHash?: string`\n - `quality?: number`\n - `size?: number`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst metadata = await client.files.metadata.get('fileId');\n\nconsole.log(metadata);\n```", - perLanguage: { - typescript: { - method: 'client.files.metadata.get', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst metadata = await client.files.metadata.get('fileId');\n\nconsole.log(metadata.videoCodec);", - }, - python: { - method: 'files.metadata.get', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nmetadata = client.files.metadata.get(\n "fileId",\n)\nprint(metadata.video_codec)', - }, - java: { - method: 'files().metadata().get', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.Metadata;\nimport io.imagekit.models.files.metadata.MetadataGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n Metadata metadata = client.files().metadata().get("fileId");\n }\n}', - }, - kotlin: { - method: 'files().metadata().get', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.Metadata\nimport com.imagekit.api.models.files.metadata.MetadataGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val metadata: Metadata = client.files().metadata().get("fileId")\n}', - }, - go: { - method: 'client.Files.Metadata.Get', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tmetadata, err := client.Files.Metadata.Get(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", metadata.VideoCodec)\n}\n', - }, - ruby: { - method: 'files.metadata.get', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nmetadata = image_kit.files.metadata.get("fileId")\n\nputs(metadata)', - }, - cli: { - method: 'metadata get', - example: - "imagekit files:metadata get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", - }, - php: { - method: 'files->metadata->get', - example: - "files->metadata->get('fileId');\n\nvar_dump($metadata);", - }, - csharp: { - method: 'Files.Metadata.Get', - example: - 'MetadataGetParams parameters = new() { FileID = "fileId" };\n\nvar metadata = await client.Files.Metadata.Get(parameters);\n\nConsole.WriteLine(metadata);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/$FILE_ID/metadata \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "get", + "endpoint": "/v1/files/{fileId}/metadata", + "httpMethod": "get", + "summary": "Get uploaded file metadata", + "description": "You can programmatically get image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API.\n\nYou can also get the metadata in upload API response by passing `metadata` in `responseFields` parameter.\n", + "stainlessPath": "(resource) files.metadata > (method) get", + "qualified": "client.files.metadata.get", + "params": [ + "fileId: string;" + ], + "response": "{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: object; gps?: object; image?: object; interoperability?: object; makernote?: object; thumbnail?: object; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }", + "markdown": "## get\n\n`client.files.metadata.get(fileId: string): { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/metadata`\n\nYou can programmatically get image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API.\n\nYou can also get the metadata in upload API response by passing `metadata` in `responseFields` parameter.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n JSON object containing metadata.\n\n - `audioCodec?: string`\n - `bitRate?: number`\n - `density?: number`\n - `duration?: number`\n - `exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }`\n - `format?: string`\n - `hasColorProfile?: boolean`\n - `hasTransparency?: boolean`\n - `height?: number`\n - `pHash?: string`\n - `quality?: number`\n - `size?: number`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst metadata = await client.files.metadata.get('fileId');\n\nconsole.log(metadata);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.metadata.get", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst metadata = await client.files.metadata.get('fileId');\n\nconsole.log(metadata.videoCodec);" + }, + "python": { + "method": "files.metadata.get", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nmetadata = client.files.metadata.get(\n \"fileId\",\n)\nprint(metadata.video_codec)" + }, + "java": { + "method": "files().metadata().get", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.Metadata;\nimport io.imagekit.models.files.metadata.MetadataGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n Metadata metadata = client.files().metadata().get(\"fileId\");\n }\n}" + }, + "kotlin": { + "method": "files().metadata().get", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.Metadata\nimport com.imagekit.api.models.files.metadata.MetadataGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val metadata: Metadata = client.files().metadata().get(\"fileId\")\n}" + }, + "go": { + "method": "client.Files.Metadata.Get", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tmetadata, err := client.Files.Metadata.Get(context.TODO(), \"fileId\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", metadata.VideoCodec)\n}\n" + }, + "ruby": { + "method": "files.metadata.get", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nmetadata = image_kit.files.metadata.get(\"fileId\")\n\nputs(metadata)" + }, + "cli": { + "method": "metadata get", + "example": "imagekit files:metadata get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId" + }, + "php": { + "method": "files->metadata->get", + "example": "files->metadata->get('fileId');\n\nvar_dump($metadata);" + }, + "csharp": { + "method": "Files.Metadata.Get", + "example": "MetadataGetParams parameters = new() { FileID = \"fileId\" };\n\nvar metadata = await client.Files.Metadata.Get(parameters);\n\nConsole.WriteLine(metadata);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/metadata \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'getFromURL', - endpoint: '/v1/metadata', - httpMethod: 'get', - summary: 'Get metadata from remote URL', - description: - 'Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API.\n', - stainlessPath: '(resource) files.metadata > (method) getFromURL', - qualified: 'client.files.metadata.getFromURL', - params: ['url: string;'], - response: - '{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: object; gps?: object; image?: object; interoperability?: object; makernote?: object; thumbnail?: object; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }', - markdown: - "## getFromURL\n\n`client.files.metadata.getFromURL(url: string): { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n\n**get** `/v1/metadata`\n\nGet image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API.\n\n\n### Parameters\n\n- `url: string`\n Should be a valid file URL. It should be accessible using your ImageKit.io account.\n\n\n### Returns\n\n- `{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n JSON object containing metadata.\n\n - `audioCodec?: string`\n - `bitRate?: number`\n - `density?: number`\n - `duration?: number`\n - `exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }`\n - `format?: string`\n - `hasColorProfile?: boolean`\n - `hasTransparency?: boolean`\n - `height?: number`\n - `pHash?: string`\n - `quality?: number`\n - `size?: number`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst metadata = await client.files.metadata.getFromURL({ url: 'https://example.com' });\n\nconsole.log(metadata);\n```", - perLanguage: { - typescript: { - method: 'client.files.metadata.getFromURL', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst metadata = await client.files.metadata.getFromURL({ url: 'https://example.com' });\n\nconsole.log(metadata.videoCodec);", - }, - python: { - method: 'files.metadata.get_from_url', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nmetadata = client.files.metadata.get_from_url(\n url="https://example.com",\n)\nprint(metadata.video_codec)', - }, - java: { - method: 'files().metadata().getFromUrl', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.Metadata;\nimport io.imagekit.models.files.metadata.MetadataGetFromUrlParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n MetadataGetFromUrlParams params = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build();\n Metadata metadata = client.files().metadata().getFromUrl(params);\n }\n}', - }, - kotlin: { - method: 'files().metadata().getFromUrl', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.Metadata\nimport com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: MetadataGetFromUrlParams = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build()\n val metadata: Metadata = client.files().metadata().getFromUrl(params)\n}', - }, - go: { - method: 'client.Files.Metadata.GetFromURL', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tmetadata, err := client.Files.Metadata.GetFromURL(context.TODO(), imagekit.FileMetadataGetFromURLParams{\n\t\tURL: "https://example.com",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", metadata.VideoCodec)\n}\n', - }, - ruby: { - method: 'files.metadata.get_from_url', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nmetadata = image_kit.files.metadata.get_from_url(url: "https://example.com")\n\nputs(metadata)', - }, - cli: { - method: 'metadata getFromURL', - example: - "imagekit files:metadata get-from-url \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --url https://example.com", - }, - php: { - method: 'files->metadata->getFromURL', - example: - "files->metadata->getFromURL(url: 'https://example.com');\n\nvar_dump($metadata);", - }, - csharp: { - method: 'Files.Metadata.GetFromUrl', - example: - 'MetadataGetFromUrlParams parameters = new() { Url = "https://example.com" };\n\nvar metadata = await client.Files.Metadata.GetFromUrl(parameters);\n\nConsole.WriteLine(metadata);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/metadata \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "getFromURL", + "endpoint": "/v1/metadata", + "httpMethod": "get", + "summary": "Get metadata from remote URL", + "description": "Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API.\n", + "stainlessPath": "(resource) files.metadata > (method) getFromURL", + "qualified": "client.files.metadata.getFromURL", + "params": [ + "url: string;" + ], + "response": "{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: object; gps?: object; image?: object; interoperability?: object; makernote?: object; thumbnail?: object; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }", + "markdown": "## getFromURL\n\n`client.files.metadata.getFromURL(url: string): { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n\n**get** `/v1/metadata`\n\nGet image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API.\n\n\n### Parameters\n\n- `url: string`\n Should be a valid file URL. It should be accessible using your ImageKit.io account.\n\n\n### Returns\n\n- `{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n JSON object containing metadata.\n\n - `audioCodec?: string`\n - `bitRate?: number`\n - `density?: number`\n - `duration?: number`\n - `exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }`\n - `format?: string`\n - `hasColorProfile?: boolean`\n - `hasTransparency?: boolean`\n - `height?: number`\n - `pHash?: string`\n - `quality?: number`\n - `size?: number`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst metadata = await client.files.metadata.getFromURL({ url: 'https://example.com' });\n\nconsole.log(metadata);\n```", + "perLanguage": { + "typescript": { + "method": "client.files.metadata.getFromURL", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst metadata = await client.files.metadata.getFromURL({ url: 'https://example.com' });\n\nconsole.log(metadata.videoCodec);" + }, + "python": { + "method": "files.metadata.get_from_url", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nmetadata = client.files.metadata.get_from_url(\n url=\"https://example.com\",\n)\nprint(metadata.video_codec)" + }, + "java": { + "method": "files().metadata().getFromUrl", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.Metadata;\nimport io.imagekit.models.files.metadata.MetadataGetFromUrlParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n MetadataGetFromUrlParams params = MetadataGetFromUrlParams.builder()\n .url(\"https://example.com\")\n .build();\n Metadata metadata = client.files().metadata().getFromUrl(params);\n }\n}" + }, + "kotlin": { + "method": "files().metadata().getFromUrl", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.Metadata\nimport com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: MetadataGetFromUrlParams = MetadataGetFromUrlParams.builder()\n .url(\"https://example.com\")\n .build()\n val metadata: Metadata = client.files().metadata().getFromUrl(params)\n}" + }, + "go": { + "method": "client.Files.Metadata.GetFromURL", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tmetadata, err := client.Files.Metadata.GetFromURL(context.TODO(), imagekit.FileMetadataGetFromURLParams{\n\t\tURL: \"https://example.com\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", metadata.VideoCodec)\n}\n" + }, + "ruby": { + "method": "files.metadata.get_from_url", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nmetadata = image_kit.files.metadata.get_from_url(url: \"https://example.com\")\n\nputs(metadata)" + }, + "cli": { + "method": "metadata getFromURL", + "example": "imagekit files:metadata get-from-url \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --url https://example.com" + }, + "php": { + "method": "files->metadata->getFromURL", + "example": "files->metadata->getFromURL(url: 'https://example.com');\n\nvar_dump($metadata);" + }, + "csharp": { + "method": "Files.Metadata.GetFromUrl", + "example": "MetadataGetFromUrlParams parameters = new() { Url = \"https://example.com\" };\n\nvar metadata = await client.Files.Metadata.GetFromUrl(parameters);\n\nConsole.WriteLine(metadata);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/metadata \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'list', - endpoint: '/v1/saved-extensions', - httpMethod: 'get', - summary: 'List all saved extensions', - description: - 'This API returns an array of all saved extensions for your account. Saved extensions allow you to save complex extension configurations and reuse them by referencing them by ID in upload or update file APIs.\n', - stainlessPath: '(resource) savedExtensions > (method) list', - qualified: 'client.savedExtensions.list', - response: - '{ id?: string; config?: object | object | object | object; createdAt?: string; description?: string; name?: string; updatedAt?: string; }[]', - markdown: - "## list\n\n`client.savedExtensions.list(): object[]`\n\n**get** `/v1/saved-extensions`\n\nThis API returns an array of all saved extensions for your account. Saved extensions allow you to save complex extension configurations and reuse them by referencing them by ID in upload or update file APIs.\n\n\n### Returns\n\n- `{ id?: string; config?: object | object | object | object; createdAt?: string; description?: string; name?: string; updatedAt?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtensions = await client.savedExtensions.list();\n\nconsole.log(savedExtensions);\n```", - perLanguage: { - typescript: { - method: 'client.savedExtensions.list', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtensions = await client.savedExtensions.list();\n\nconsole.log(savedExtensions);", - }, - python: { - method: 'saved_extensions.list', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extensions = client.saved_extensions.list()\nprint(saved_extensions)', - }, - java: { - method: 'savedExtensions().list', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List savedExtensions = client.savedExtensions().list();\n }\n}', - }, - kotlin: { - method: 'savedExtensions().list', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtensions: List = client.savedExtensions().list()\n}', - }, - go: { - method: 'client.SavedExtensions.List', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtensions, err := client.SavedExtensions.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtensions)\n}\n', - }, - ruby: { - method: 'saved_extensions.list', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nsaved_extensions = image_kit.saved_extensions.list\n\nputs(saved_extensions)', - }, - cli: { - method: 'savedExtensions list', - example: - "imagekit saved-extensions list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - php: { - method: 'savedExtensions->list', - example: - "savedExtensions->list();\n\nvar_dump($savedExtensions);", - }, - csharp: { - method: 'SavedExtensions.List', - example: - 'SavedExtensionListParams parameters = new();\n\nvar savedExtensions = await client.SavedExtensions.List(parameters);\n\nConsole.WriteLine(savedExtensions);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/saved-extensions \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "list", + "endpoint": "/v1/saved-extensions", + "httpMethod": "get", + "summary": "List all saved extensions", + "description": "This API returns an array of all saved extensions for your account. Saved extensions allow you to save complex extension configurations and reuse them by referencing them by ID in upload or update file APIs.\n", + "stainlessPath": "(resource) savedExtensions > (method) list", + "qualified": "client.savedExtensions.list", + "response": "{ id?: string; config?: object | object | object | object; createdAt?: string; description?: string; name?: string; updatedAt?: string; }[]", + "markdown": "## list\n\n`client.savedExtensions.list(): object[]`\n\n**get** `/v1/saved-extensions`\n\nThis API returns an array of all saved extensions for your account. Saved extensions allow you to save complex extension configurations and reuse them by referencing them by ID in upload or update file APIs.\n\n\n### Returns\n\n- `{ id?: string; config?: object | object | object | object; createdAt?: string; description?: string; name?: string; updatedAt?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtensions = await client.savedExtensions.list();\n\nconsole.log(savedExtensions);\n```", + "perLanguage": { + "typescript": { + "method": "client.savedExtensions.list", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtensions = await client.savedExtensions.list();\n\nconsole.log(savedExtensions);" + }, + "python": { + "method": "saved_extensions.list", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nsaved_extensions = client.saved_extensions.list()\nprint(saved_extensions)" + }, + "java": { + "method": "savedExtensions().list", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List savedExtensions = client.savedExtensions().list();\n }\n}" + }, + "kotlin": { + "method": "savedExtensions().list", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtensions: List = client.savedExtensions().list()\n}" + }, + "go": { + "method": "client.SavedExtensions.List", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tsavedExtensions, err := client.SavedExtensions.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", savedExtensions)\n}\n" + }, + "ruby": { + "method": "saved_extensions.list", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nsaved_extensions = image_kit.saved_extensions.list\n\nputs(saved_extensions)" + }, + "cli": { + "method": "savedExtensions list", + "example": "imagekit saved-extensions list \\\n --private-key 'My Private Key' \\\n --password 'My Password'" + }, + "php": { + "method": "savedExtensions->list", + "example": "savedExtensions->list();\n\nvar_dump($savedExtensions);" + }, + "csharp": { + "method": "SavedExtensions.List", + "example": "SavedExtensionListParams parameters = new();\n\nvar savedExtensions = await client.SavedExtensions.List(parameters);\n\nConsole.WriteLine(savedExtensions);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/saved-extensions \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'create', - endpoint: '/v1/saved-extensions', - httpMethod: 'post', - summary: 'Create saved extension', - description: - 'This API creates a new saved extension. Saved extensions allow you to save complex extension configurations (like AI tasks) and reuse them by referencing the ID in upload or update file APIs.\n\n**Saved extension limit** \\\nYou can create a maximum of 100 saved extensions per account.\n', - stainlessPath: '(resource) savedExtensions > (method) create', - qualified: 'client.savedExtensions.create', - params: [ + "name": "create", + "endpoint": "/v1/saved-extensions", + "httpMethod": "post", + "summary": "Create saved extension", + "description": "This API creates a new saved extension. Saved extensions allow you to save complex extension configurations (like AI tasks) and reuse them by referencing the ID in upload or update file APIs.\n\n**Saved extension limit** \\\nYou can create a maximum of 100 saved extensions per account.\n", + "stainlessPath": "(resource) savedExtensions > (method) create", + "qualified": "client.savedExtensions.create", + "params": [ "config: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; };", - 'description: string;', - 'name: string;', + "description: string;", + "name: string;" ], - response: - "{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }", - markdown: - "## create\n\n`client.savedExtensions.create(config: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }, description: string, name: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**post** `/v1/saved-extensions`\n\nThis API creates a new saved extension. Saved extensions allow you to save complex extension configurations (like AI tasks) and reuse them by referencing the ID in upload or update file APIs.\n\n**Saved extension limit** \\\nYou can create a maximum of 100 saved extensions per account.\n\n\n### Parameters\n\n- `config: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n Configuration object for an extension (base extensions only, not saved extension references).\n\n- `description: string`\n Description of what the saved extension does.\n\n- `name: string`\n Name of the saved extension.\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.create({\n config: { name: 'remove-bg' },\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n});\n\nconsole.log(savedExtension);\n```", - perLanguage: { - typescript: { - method: 'client.savedExtensions.create', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.create({\n config: { name: 'remove-bg' },\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n});\n\nconsole.log(savedExtension.id);", - }, - python: { - method: 'saved_extensions.create', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.create(\n config={\n "name": "remove-bg"\n },\n description="Analyzes vehicle images for type, condition, and quality assessment",\n name="Car Quality Analysis",\n)\nprint(saved_extension.id)', - }, - java: { - method: 'savedExtensions().create', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.ExtensionConfig;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtensionCreateParams params = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build();\n SavedExtension savedExtension = client.savedExtensions().create(params);\n }\n}', - }, - kotlin: { - method: 'savedExtensions().create', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.ExtensionConfig\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionCreateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: SavedExtensionCreateParams = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build()\n val savedExtension: SavedExtension = client.savedExtensions().create(params)\n}', - }, - go: { - method: 'client.SavedExtensions.New', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n\t"github.com/imagekit-developer/imagekit-go/shared"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.New(context.TODO(), imagekit.SavedExtensionNewParams{\n\t\tConfig: shared.ExtensionConfigUnionParam{\n\t\t\tOfRemoveBg: &shared.ExtensionConfigRemoveBgParam{},\n\t\t},\n\t\tDescription: "Analyzes vehicle images for type, condition, and quality assessment",\n\t\tName: "Car Quality Analysis",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtension.ID)\n}\n', - }, - ruby: { - method: 'saved_extensions.create', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nsaved_extension = image_kit.saved_extensions.create(\n config: {name: :"remove-bg"},\n description: "Analyzes vehicle images for type, condition, and quality assessment",\n name: "Car Quality Analysis"\n)\n\nputs(saved_extension)', - }, - cli: { - method: 'savedExtensions create', - example: - "imagekit saved-extensions create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --config '{name: remove-bg}' \\\n --description 'Analyzes vehicle images for type, condition, and quality assessment' \\\n --name 'Car Quality Analysis'", - }, - php: { - method: 'savedExtensions->create', - example: - "savedExtensions->create(\n config: [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n);\n\nvar_dump($savedExtension);", - }, - csharp: { - method: 'SavedExtensions.Create', - example: - 'SavedExtensionCreateParams parameters = new()\n{\n Config = new RemoveBg()\n {\n Options = new()\n {\n AddShadow = true,\n BgColor = "bg_color",\n BgImageUrl = "bg_image_url",\n Semitransparency = true,\n },\n },\n Description = "Analyzes vehicle images for type, condition, and quality assessment",\n Name = "Car Quality Analysis",\n};\n\nvar savedExtension = await client.SavedExtensions.Create(parameters);\n\nConsole.WriteLine(savedExtension);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/saved-extensions \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "config": {\n "name": "remove-bg"\n },\n "description": "Analyzes vehicle images for type, condition, and quality assessment",\n "name": "Car Quality Analysis"\n }\'', - }, - }, + "response": "{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }", + "markdown": "## create\n\n`client.savedExtensions.create(config: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }, description: string, name: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**post** `/v1/saved-extensions`\n\nThis API creates a new saved extension. Saved extensions allow you to save complex extension configurations (like AI tasks) and reuse them by referencing the ID in upload or update file APIs.\n\n**Saved extension limit** \\\nYou can create a maximum of 100 saved extensions per account.\n\n\n### Parameters\n\n- `config: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n Configuration object for an extension (base extensions only, not saved extension references).\n\n- `description: string`\n Description of what the saved extension does.\n\n- `name: string`\n Name of the saved extension.\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.create({\n config: { name: 'remove-bg' },\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n});\n\nconsole.log(savedExtension);\n```", + "perLanguage": { + "typescript": { + "method": "client.savedExtensions.create", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.create({\n config: { name: 'remove-bg' },\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n});\n\nconsole.log(savedExtension.id);" + }, + "python": { + "method": "saved_extensions.create", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.create(\n config={\n \"name\": \"remove-bg\"\n },\n description=\"Analyzes vehicle images for type, condition, and quality assessment\",\n name=\"Car Quality Analysis\",\n)\nprint(saved_extension.id)" + }, + "java": { + "method": "savedExtensions().create", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.ExtensionConfig;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtensionCreateParams params = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description(\"Analyzes vehicle images for type, condition, and quality assessment\")\n .name(\"Car Quality Analysis\")\n .build();\n SavedExtension savedExtension = client.savedExtensions().create(params);\n }\n}" + }, + "kotlin": { + "method": "savedExtensions().create", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.ExtensionConfig\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionCreateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: SavedExtensionCreateParams = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description(\"Analyzes vehicle images for type, condition, and quality assessment\")\n .name(\"Car Quality Analysis\")\n .build()\n val savedExtension: SavedExtension = client.savedExtensions().create(params)\n}" + }, + "go": { + "method": "client.SavedExtensions.New", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n\t\"github.com/imagekit-developer/imagekit-go/shared\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.New(context.TODO(), imagekit.SavedExtensionNewParams{\n\t\tConfig: shared.ExtensionConfigUnionParam{\n\t\t\tOfRemoveBg: &shared.ExtensionConfigRemoveBgParam{},\n\t\t},\n\t\tDescription: \"Analyzes vehicle images for type, condition, and quality assessment\",\n\t\tName: \"Car Quality Analysis\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", savedExtension.ID)\n}\n" + }, + "ruby": { + "method": "saved_extensions.create", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nsaved_extension = image_kit.saved_extensions.create(\n config: {name: :\"remove-bg\"},\n description: \"Analyzes vehicle images for type, condition, and quality assessment\",\n name: \"Car Quality Analysis\"\n)\n\nputs(saved_extension)" + }, + "cli": { + "method": "savedExtensions create", + "example": "imagekit saved-extensions create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --config '{name: remove-bg}' \\\n --description 'Analyzes vehicle images for type, condition, and quality assessment' \\\n --name 'Car Quality Analysis'" + }, + "php": { + "method": "savedExtensions->create", + "example": "savedExtensions->create(\n config: [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n);\n\nvar_dump($savedExtension);" + }, + "csharp": { + "method": "SavedExtensions.Create", + "example": "SavedExtensionCreateParams parameters = new()\n{\n Config = new RemoveBg()\n {\n Options = new()\n {\n AddShadow = true,\n BgColor = \"bg_color\",\n BgImageUrl = \"bg_image_url\",\n Semitransparency = true,\n },\n },\n Description = \"Analyzes vehicle images for type, condition, and quality assessment\",\n Name = \"Car Quality Analysis\",\n};\n\nvar savedExtension = await client.SavedExtensions.Create(parameters);\n\nConsole.WriteLine(savedExtension);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/saved-extensions \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"config\": {\n \"name\": \"remove-bg\"\n },\n \"description\": \"Analyzes vehicle images for type, condition, and quality assessment\",\n \"name\": \"Car Quality Analysis\"\n }'" + } + } }, { - name: 'get', - endpoint: '/v1/saved-extensions/{id}', - httpMethod: 'get', - summary: 'Get saved extension details', - description: 'This API returns details of a specific saved extension by ID.\n', - stainlessPath: '(resource) savedExtensions > (method) get', - qualified: 'client.savedExtensions.get', - params: ['id: string;'], - response: - "{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }", - markdown: - "## get\n\n`client.savedExtensions.get(id: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**get** `/v1/saved-extensions/{id}`\n\nThis API returns details of a specific saved extension by ID.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.get('id');\n\nconsole.log(savedExtension);\n```", - perLanguage: { - typescript: { - method: 'client.savedExtensions.get', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.get('id');\n\nconsole.log(savedExtension.id);", - }, - python: { - method: 'saved_extensions.get', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.get(\n "id",\n)\nprint(saved_extension.id)', - }, - java: { - method: 'savedExtensions().get', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().get("id");\n }\n}', - }, - kotlin: { - method: 'savedExtensions().get', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtension: SavedExtension = client.savedExtensions().get("id")\n}', - }, - go: { - method: 'client.SavedExtensions.Get', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.Get(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtension.ID)\n}\n', - }, - ruby: { - method: 'saved_extensions.get', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nsaved_extension = image_kit.saved_extensions.get("id")\n\nputs(saved_extension)', - }, - cli: { - method: 'savedExtensions get', - example: - "imagekit saved-extensions get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - php: { - method: 'savedExtensions->get', - example: - "savedExtensions->get('id');\n\nvar_dump($savedExtension);", - }, - csharp: { - method: 'SavedExtensions.Get', - example: - 'SavedExtensionGetParams parameters = new() { ID = "id" };\n\nvar savedExtension = await client.SavedExtensions.Get(parameters);\n\nConsole.WriteLine(savedExtension);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "get", + "endpoint": "/v1/saved-extensions/{id}", + "httpMethod": "get", + "summary": "Get saved extension details", + "description": "This API returns details of a specific saved extension by ID.\n", + "stainlessPath": "(resource) savedExtensions > (method) get", + "qualified": "client.savedExtensions.get", + "params": [ + "id: string;" + ], + "response": "{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }", + "markdown": "## get\n\n`client.savedExtensions.get(id: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**get** `/v1/saved-extensions/{id}`\n\nThis API returns details of a specific saved extension by ID.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.get('id');\n\nconsole.log(savedExtension);\n```", + "perLanguage": { + "typescript": { + "method": "client.savedExtensions.get", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.get('id');\n\nconsole.log(savedExtension.id);" + }, + "python": { + "method": "saved_extensions.get", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.get(\n \"id\",\n)\nprint(saved_extension.id)" + }, + "java": { + "method": "savedExtensions().get", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().get(\"id\");\n }\n}" + }, + "kotlin": { + "method": "savedExtensions().get", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtension: SavedExtension = client.savedExtensions().get(\"id\")\n}" + }, + "go": { + "method": "client.SavedExtensions.Get", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.Get(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", savedExtension.ID)\n}\n" + }, + "ruby": { + "method": "saved_extensions.get", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nsaved_extension = image_kit.saved_extensions.get(\"id\")\n\nputs(saved_extension)" + }, + "cli": { + "method": "savedExtensions get", + "example": "imagekit saved-extensions get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" + }, + "php": { + "method": "savedExtensions->get", + "example": "savedExtensions->get('id');\n\nvar_dump($savedExtension);" + }, + "csharp": { + "method": "SavedExtensions.Get", + "example": "SavedExtensionGetParams parameters = new() { ID = \"id\" };\n\nvar savedExtension = await client.SavedExtensions.Get(parameters);\n\nConsole.WriteLine(savedExtension);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'update', - endpoint: '/v1/saved-extensions/{id}', - httpMethod: 'patch', - summary: 'Update saved extension', - description: - 'This API updates an existing saved extension. You can update the name, description, or config.\n', - stainlessPath: '(resource) savedExtensions > (method) update', - qualified: 'client.savedExtensions.update', - params: [ - 'id: string;', + "name": "update", + "endpoint": "/v1/saved-extensions/{id}", + "httpMethod": "patch", + "summary": "Update saved extension", + "description": "This API updates an existing saved extension. You can update the name, description, or config.\n", + "stainlessPath": "(resource) savedExtensions > (method) update", + "qualified": "client.savedExtensions.update", + "params": [ + "id: string;", "config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; };", - 'description?: string;', - 'name?: string;', + "description?: string;", + "name?: string;" ], - response: - "{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }", - markdown: - "## update\n\n`client.savedExtensions.update(id: string, config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }, description?: string, name?: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**patch** `/v1/saved-extensions/{id}`\n\nThis API updates an existing saved extension. You can update the name, description, or config.\n\n\n### Parameters\n\n- `id: string`\n\n- `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n Configuration object for an extension (base extensions only, not saved extension references).\n\n- `description?: string`\n Updated description of the saved extension.\n\n- `name?: string`\n Updated name of the saved extension.\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.update('id');\n\nconsole.log(savedExtension);\n```", - perLanguage: { - typescript: { - method: 'client.savedExtensions.update', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.update('id');\n\nconsole.log(savedExtension.id);", - }, - python: { - method: 'saved_extensions.update', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.update(\n id="id",\n)\nprint(saved_extension.id)', - }, - java: { - method: 'savedExtensions().update', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().update("id");\n }\n}', - }, - kotlin: { - method: 'savedExtensions().update', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtension: SavedExtension = client.savedExtensions().update("id")\n}', - }, - go: { - method: 'client.SavedExtensions.Update', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.SavedExtensionUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtension.ID)\n}\n', - }, - ruby: { - method: 'saved_extensions.update', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nsaved_extension = image_kit.saved_extensions.update("id")\n\nputs(saved_extension)', - }, - cli: { - method: 'savedExtensions update', - example: - "imagekit saved-extensions update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - php: { - method: 'savedExtensions->update', - example: - "savedExtensions->update(\n 'id',\n config: [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n description: 'x',\n name: 'x',\n);\n\nvar_dump($savedExtension);", - }, - csharp: { - method: 'SavedExtensions.Update', - example: - 'SavedExtensionUpdateParams parameters = new() { ID = "id" };\n\nvar savedExtension = await client.SavedExtensions.Update(parameters);\n\nConsole.WriteLine(savedExtension);', - }, - http: { - example: - "curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -X PATCH \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{}'", - }, - }, + "response": "{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }", + "markdown": "## update\n\n`client.savedExtensions.update(id: string, config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }, description?: string, name?: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**patch** `/v1/saved-extensions/{id}`\n\nThis API updates an existing saved extension. You can update the name, description, or config.\n\n\n### Parameters\n\n- `id: string`\n\n- `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n Configuration object for an extension (base extensions only, not saved extension references).\n\n- `description?: string`\n Updated description of the saved extension.\n\n- `name?: string`\n Updated name of the saved extension.\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.update('id');\n\nconsole.log(savedExtension);\n```", + "perLanguage": { + "typescript": { + "method": "client.savedExtensions.update", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.update('id');\n\nconsole.log(savedExtension.id);" + }, + "python": { + "method": "saved_extensions.update", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.update(\n id=\"id\",\n)\nprint(saved_extension.id)" + }, + "java": { + "method": "savedExtensions().update", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().update(\"id\");\n }\n}" + }, + "kotlin": { + "method": "savedExtensions().update", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtension: SavedExtension = client.savedExtensions().update(\"id\")\n}" + }, + "go": { + "method": "client.SavedExtensions.Update", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.Update(\n\t\tcontext.TODO(),\n\t\t\"id\",\n\t\timagekit.SavedExtensionUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", savedExtension.ID)\n}\n" + }, + "ruby": { + "method": "saved_extensions.update", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nsaved_extension = image_kit.saved_extensions.update(\"id\")\n\nputs(saved_extension)" + }, + "cli": { + "method": "savedExtensions update", + "example": "imagekit saved-extensions update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" + }, + "php": { + "method": "savedExtensions->update", + "example": "savedExtensions->update(\n 'id',\n config: [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n description: 'x',\n name: 'x',\n);\n\nvar_dump($savedExtension);" + }, + "csharp": { + "method": "SavedExtensions.Update", + "example": "SavedExtensionUpdateParams parameters = new() { ID = \"id\" };\n\nvar savedExtension = await client.SavedExtensions.Update(parameters);\n\nConsole.WriteLine(savedExtension);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -X PATCH \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{}'" + } + } }, { - name: 'delete', - endpoint: '/v1/saved-extensions/{id}', - httpMethod: 'delete', - summary: 'Delete saved extension', - description: 'This API deletes a saved extension permanently.\n', - stainlessPath: '(resource) savedExtensions > (method) delete', - qualified: 'client.savedExtensions.delete', - params: ['id: string;'], - markdown: - "## delete\n\n`client.savedExtensions.delete(id: string): void`\n\n**delete** `/v1/saved-extensions/{id}`\n\nThis API deletes a saved extension permanently.\n\n\n### Parameters\n\n- `id: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.savedExtensions.delete('id')\n```", - perLanguage: { - typescript: { - method: 'client.savedExtensions.delete', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.savedExtensions.delete('id');", - }, - python: { - method: 'saved_extensions.delete', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.saved_extensions.delete(\n "id",\n)', - }, - java: { - method: 'savedExtensions().delete', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.savedextensions.SavedExtensionDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.savedExtensions().delete("id");\n }\n}', - }, - kotlin: { - method: 'savedExtensions().delete', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.savedExtensions().delete("id")\n}', - }, - go: { - method: 'client.SavedExtensions.Delete', - example: - 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.SavedExtensions.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', - }, - ruby: { - method: 'saved_extensions.delete', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.saved_extensions.delete("id")\n\nputs(result)', - }, - cli: { - method: 'savedExtensions delete', - example: - "imagekit saved-extensions delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - php: { - method: 'savedExtensions->delete', - example: - "savedExtensions->delete('id');\n\nvar_dump($result);", - }, - csharp: { - method: 'SavedExtensions.Delete', - example: - 'SavedExtensionDeleteParams parameters = new() { ID = "id" };\n\nawait client.SavedExtensions.Delete(parameters);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "delete", + "endpoint": "/v1/saved-extensions/{id}", + "httpMethod": "delete", + "summary": "Delete saved extension", + "description": "This API deletes a saved extension permanently.\n", + "stainlessPath": "(resource) savedExtensions > (method) delete", + "qualified": "client.savedExtensions.delete", + "params": [ + "id: string;" + ], + "markdown": "## delete\n\n`client.savedExtensions.delete(id: string): void`\n\n**delete** `/v1/saved-extensions/{id}`\n\nThis API deletes a saved extension permanently.\n\n\n### Parameters\n\n- `id: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.savedExtensions.delete('id')\n```", + "perLanguage": { + "typescript": { + "method": "client.savedExtensions.delete", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.savedExtensions.delete('id');" + }, + "python": { + "method": "saved_extensions.delete", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nclient.saved_extensions.delete(\n \"id\",\n)" + }, + "java": { + "method": "savedExtensions().delete", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.savedextensions.SavedExtensionDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.savedExtensions().delete(\"id\");\n }\n}" + }, + "kotlin": { + "method": "savedExtensions().delete", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.savedExtensions().delete(\"id\")\n}" + }, + "go": { + "method": "client.SavedExtensions.Delete", + "example": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\terr := client.SavedExtensions.Delete(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n" + }, + "ruby": { + "method": "saved_extensions.delete", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresult = image_kit.saved_extensions.delete(\"id\")\n\nputs(result)" + }, + "cli": { + "method": "savedExtensions delete", + "example": "imagekit saved-extensions delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" + }, + "php": { + "method": "savedExtensions->delete", + "example": "savedExtensions->delete('id');\n\nvar_dump($result);" + }, + "csharp": { + "method": "SavedExtensions.Delete", + "example": "SavedExtensionDeleteParams parameters = new() { ID = \"id\" };\n\nawait client.SavedExtensions.Delete(parameters);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'list', - endpoint: '/v1/files', - httpMethod: 'get', - summary: 'List and search assets', - description: - 'This API can list all the uploaded files and folders in your ImageKit.io media library. In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and provide this generated string as the value of the `searchQuery`.\n', - stainlessPath: '(resource) assets > (method) list', - qualified: 'client.assets.list', - params: [ + "name": "list", + "endpoint": "/v1/files", + "httpMethod": "get", + "summary": "List and search assets", + "description": "This API can list all the uploaded files and folders in your ImageKit.io media library. In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and provide this generated string as the value of the `searchQuery`.\n", + "stainlessPath": "(resource) assets > (method) list", + "qualified": "client.assets.list", + "params": [ "fileType?: 'all' | 'image' | 'non-image';", - 'limit?: number;', - 'path?: string;', - 'searchQuery?: string;', - 'skip?: number;', - 'sort?: string;', - "type?: 'file' | 'file-version' | 'folder' | 'all';", + "limit?: number;", + "path?: string;", + "searchQuery?: string;", + "skip?: number;", + "sort?: string;", + "type?: 'file' | 'file-version' | 'folder' | 'all';" ], - response: - "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; } | { createdAt?: string; customMetadata?: object; folderId?: string; folderPath?: string; name?: string; type?: 'folder'; updatedAt?: string; }[]", - markdown: - "## list\n\n`client.assets.list(fileType?: 'all' | 'image' | 'non-image', limit?: number, path?: string, searchQuery?: string, skip?: number, sort?: string, type?: 'file' | 'file-version' | 'folder' | 'all'): object | object[]`\n\n**get** `/v1/files`\n\nThis API can list all the uploaded files and folders in your ImageKit.io media library. In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and provide this generated string as the value of the `searchQuery`.\n\n\n### Parameters\n\n- `fileType?: 'all' | 'image' | 'non-image'`\n Filter results by file type.\n\n- `all` — include all file types \n- `image` — include only image files \n- `non-image` — include only non-image files (e.g., JS, CSS, video)\n\n- `limit?: number`\n The maximum number of results to return in response.\n\n\n- `path?: string`\n Folder path if you want to limit the search within a specific folder. For example, `/sales-banner/` will only search in folder sales-banner.\n\nNote : If your use case involves searching within a folder as well as its subfolders, you can use `path` parameter in `searchQuery` with appropriate operator.\nCheckout [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) for more information.\n\n\n- `searchQuery?: string`\n Query string in a Lucene-like query language e.g. `createdAt > \"7d\"`.\n\nNote : When the searchQuery parameter is present, the following query parameters will have no effect on the result:\n\n1. `tags`\n2. `type`\n3. `name`\n\n[Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) from examples.\n\n\n- `skip?: number`\n The number of results to skip before returning results.\n\n\n- `sort?: string`\n Sort the results by one of the supported fields in ascending or descending order.\n\n- `type?: 'file' | 'file-version' | 'folder' | 'all'`\n Filter results by asset type.\n\n- `file` — returns only files \n- `file-version` — returns specific file versions \n- `folder` — returns only folders \n- `all` — returns both files and folders (excludes `file-version`)\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; } | { createdAt?: string; customMetadata?: object; folderId?: string; folderPath?: string; name?: string; type?: 'folder'; updatedAt?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst assets = await client.assets.list();\n\nconsole.log(assets);\n```", - perLanguage: { - typescript: { - method: 'client.assets.list', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst assets = await client.assets.list();\n\nconsole.log(assets);", - }, - python: { - method: 'assets.list', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nassets = client.assets.list()\nprint(assets)', - }, - java: { - method: 'assets().list', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.assets.AssetListParams;\nimport io.imagekit.models.assets.AssetListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List assets = client.assets().list();\n }\n}', - }, - kotlin: { - method: 'assets().list', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.assets.AssetListParams\nimport com.imagekit.api.models.assets.AssetListResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val assets: List = client.assets().list()\n}', - }, - go: { - method: 'client.Assets.List', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tassets, err := client.Assets.List(context.TODO(), imagekit.AssetListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", assets)\n}\n', - }, - ruby: { - method: 'assets.list', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nassets = image_kit.assets.list\n\nputs(assets)', - }, - cli: { - method: 'assets list', - example: "imagekit assets list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - php: { - method: 'assets->list', - example: - "assets->list(\n fileType: 'all',\n limit: 1,\n path: 'path',\n searchQuery: 'searchQuery',\n skip: 0,\n sort: 'ASC_NAME',\n type: 'file',\n);\n\nvar_dump($assets);", - }, - csharp: { - method: 'Assets.List', - example: - 'AssetListParams parameters = new();\n\nvar assets = await client.Assets.List(parameters);\n\nConsole.WriteLine(assets);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; } | { createdAt?: string; customMetadata?: object; folderId?: string; folderPath?: string; name?: string; type?: 'folder'; updatedAt?: string; }[]", + "markdown": "## list\n\n`client.assets.list(fileType?: 'all' | 'image' | 'non-image', limit?: number, path?: string, searchQuery?: string, skip?: number, sort?: string, type?: 'file' | 'file-version' | 'folder' | 'all'): object | object[]`\n\n**get** `/v1/files`\n\nThis API can list all the uploaded files and folders in your ImageKit.io media library. In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and provide this generated string as the value of the `searchQuery`.\n\n\n### Parameters\n\n- `fileType?: 'all' | 'image' | 'non-image'`\n Filter results by file type.\n\n- `all` — include all file types \n- `image` — include only image files \n- `non-image` — include only non-image files (e.g., JS, CSS, video)\n\n- `limit?: number`\n The maximum number of results to return in response.\n\n\n- `path?: string`\n Folder path if you want to limit the search within a specific folder. For example, `/sales-banner/` will only search in folder sales-banner.\n\nNote : If your use case involves searching within a folder as well as its subfolders, you can use `path` parameter in `searchQuery` with appropriate operator.\nCheckout [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) for more information.\n\n\n- `searchQuery?: string`\n Query string in a Lucene-like query language e.g. `createdAt > \"7d\"`.\n\nNote : When the searchQuery parameter is present, the following query parameters will have no effect on the result:\n\n1. `tags`\n2. `type`\n3. `name`\n\n[Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) from examples.\n\n\n- `skip?: number`\n The number of results to skip before returning results.\n\n\n- `sort?: string`\n Sort the results by one of the supported fields in ascending or descending order.\n\n- `type?: 'file' | 'file-version' | 'folder' | 'all'`\n Filter results by asset type.\n\n- `file` — returns only files \n- `file-version` — returns specific file versions \n- `folder` — returns only folders \n- `all` — returns both files and folders (excludes `file-version`)\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; } | { createdAt?: string; customMetadata?: object; folderId?: string; folderPath?: string; name?: string; type?: 'folder'; updatedAt?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst assets = await client.assets.list();\n\nconsole.log(assets);\n```", + "perLanguage": { + "typescript": { + "method": "client.assets.list", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst assets = await client.assets.list();\n\nconsole.log(assets);" + }, + "python": { + "method": "assets.list", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nassets = client.assets.list()\nprint(assets)" + }, + "java": { + "method": "assets().list", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.assets.AssetListParams;\nimport io.imagekit.models.assets.AssetListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List assets = client.assets().list();\n }\n}" + }, + "kotlin": { + "method": "assets().list", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.assets.AssetListParams\nimport com.imagekit.api.models.assets.AssetListResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val assets: List = client.assets().list()\n}" + }, + "go": { + "method": "client.Assets.List", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tassets, err := client.Assets.List(context.TODO(), imagekit.AssetListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", assets)\n}\n" + }, + "ruby": { + "method": "assets.list", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nassets = image_kit.assets.list\n\nputs(assets)" + }, + "cli": { + "method": "assets list", + "example": "imagekit assets list \\\n --private-key 'My Private Key' \\\n --password 'My Password'" + }, + "php": { + "method": "assets->list", + "example": "assets->list(\n fileType: 'all',\n limit: 1,\n path: 'path',\n searchQuery: 'searchQuery',\n skip: 0,\n sort: 'ASC_NAME',\n type: 'file',\n);\n\nvar_dump($assets);" + }, + "csharp": { + "method": "Assets.List", + "example": "AssetListParams parameters = new();\n\nvar assets = await client.Assets.List(parameters);\n\nConsole.WriteLine(assets);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'create', - endpoint: '/v1/files/purge', - httpMethod: 'post', - summary: 'Purge cache', - description: - "This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: Purge cache is an asynchronous process and it may take some time to reflect the changes.\n", - stainlessPath: '(resource) cache.invalidation > (method) create', - qualified: 'client.cache.invalidation.create', - params: ['url: string;'], - response: '{ requestId?: string; }', - markdown: - "## create\n\n`client.cache.invalidation.create(url: string): { requestId?: string; }`\n\n**post** `/v1/files/purge`\n\nThis API will purge CDN cache and ImageKit.io's internal cache for a file. Note: Purge cache is an asynchronous process and it may take some time to reflect the changes.\n\n\n### Parameters\n\n- `url: string`\n The full URL of the file to be purged.\n\n\n### Returns\n\n- `{ requestId?: string; }`\n\n - `requestId?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst invalidation = await client.cache.invalidation.create({ url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg' });\n\nconsole.log(invalidation);\n```", - perLanguage: { - typescript: { - method: 'client.cache.invalidation.create', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst invalidation = await client.cache.invalidation.create({\n url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg',\n});\n\nconsole.log(invalidation.requestId);", - }, - python: { - method: 'cache.invalidation.create', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ninvalidation = client.cache.invalidation.create(\n url="https://ik.imagekit.io/your_imagekit_id/default-image.jpg",\n)\nprint(invalidation.request_id)', - }, - java: { - method: 'cache().invalidation().create', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.cache.invalidation.InvalidationCreateParams;\nimport io.imagekit.models.cache.invalidation.InvalidationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationCreateParams params = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build();\n InvalidationCreateResponse invalidation = client.cache().invalidation().create(params);\n }\n}', - }, - kotlin: { - method: 'cache().invalidation().create', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateParams\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: InvalidationCreateParams = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build()\n val invalidation: InvalidationCreateResponse = client.cache().invalidation().create(params)\n}', - }, - go: { - method: 'client.Cache.Invalidation.New', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tinvalidation, err := client.Cache.Invalidation.New(context.TODO(), imagekit.CacheInvalidationNewParams{\n\t\tURL: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", invalidation.RequestID)\n}\n', - }, - ruby: { - method: 'cache.invalidation.create', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ninvalidation = image_kit.cache.invalidation.create(url: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n\nputs(invalidation)', - }, - cli: { - method: 'invalidation create', - example: - "imagekit cache:invalidation create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --url https://ik.imagekit.io/your_imagekit_id/default-image.jpg", - }, - php: { - method: 'cache->invalidation->create', - example: - "cache->invalidation->create(\n url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg'\n);\n\nvar_dump($invalidation);", - }, - csharp: { - method: 'Cache.Invalidation.Create', - example: - 'InvalidationCreateParams parameters = new()\n{\n Url = "https://ik.imagekit.io/your_imagekit_id/default-image.jpg"\n};\n\nvar invalidation = await client.Cache.Invalidation.Create(parameters);\n\nConsole.WriteLine(invalidation);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/purge \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "url": "https://ik.imagekit.io/your_imagekit_id/default-image.jpg"\n }\'', - }, - }, + "name": "create", + "endpoint": "/v1/files/purge", + "httpMethod": "post", + "summary": "Purge cache", + "description": "This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: Purge cache is an asynchronous process and it may take some time to reflect the changes.\n", + "stainlessPath": "(resource) cache.invalidation > (method) create", + "qualified": "client.cache.invalidation.create", + "params": [ + "url: string;" + ], + "response": "{ requestId?: string; }", + "markdown": "## create\n\n`client.cache.invalidation.create(url: string): { requestId?: string; }`\n\n**post** `/v1/files/purge`\n\nThis API will purge CDN cache and ImageKit.io's internal cache for a file. Note: Purge cache is an asynchronous process and it may take some time to reflect the changes.\n\n\n### Parameters\n\n- `url: string`\n The full URL of the file to be purged.\n\n\n### Returns\n\n- `{ requestId?: string; }`\n\n - `requestId?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst invalidation = await client.cache.invalidation.create({ url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg' });\n\nconsole.log(invalidation);\n```", + "perLanguage": { + "typescript": { + "method": "client.cache.invalidation.create", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst invalidation = await client.cache.invalidation.create({\n url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg',\n});\n\nconsole.log(invalidation.requestId);" + }, + "python": { + "method": "cache.invalidation.create", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\ninvalidation = client.cache.invalidation.create(\n url=\"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\",\n)\nprint(invalidation.request_id)" + }, + "java": { + "method": "cache().invalidation().create", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.cache.invalidation.InvalidationCreateParams;\nimport io.imagekit.models.cache.invalidation.InvalidationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationCreateParams params = InvalidationCreateParams.builder()\n .url(\"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\")\n .build();\n InvalidationCreateResponse invalidation = client.cache().invalidation().create(params);\n }\n}" + }, + "kotlin": { + "method": "cache().invalidation().create", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateParams\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: InvalidationCreateParams = InvalidationCreateParams.builder()\n .url(\"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\")\n .build()\n val invalidation: InvalidationCreateResponse = client.cache().invalidation().create(params)\n}" + }, + "go": { + "method": "client.Cache.Invalidation.New", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tinvalidation, err := client.Cache.Invalidation.New(context.TODO(), imagekit.CacheInvalidationNewParams{\n\t\tURL: \"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", invalidation.RequestID)\n}\n" + }, + "ruby": { + "method": "cache.invalidation.create", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\ninvalidation = image_kit.cache.invalidation.create(url: \"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\")\n\nputs(invalidation)" + }, + "cli": { + "method": "invalidation create", + "example": "imagekit cache:invalidation create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --url https://ik.imagekit.io/your_imagekit_id/default-image.jpg" + }, + "php": { + "method": "cache->invalidation->create", + "example": "cache->invalidation->create(\n url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg'\n);\n\nvar_dump($invalidation);" + }, + "csharp": { + "method": "Cache.Invalidation.Create", + "example": "InvalidationCreateParams parameters = new()\n{\n Url = \"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\"\n};\n\nvar invalidation = await client.Cache.Invalidation.Create(parameters);\n\nConsole.WriteLine(invalidation);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/purge \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"url\": \"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\"\n }'" + } + } }, { - name: 'get', - endpoint: '/v1/files/purge/{requestId}', - httpMethod: 'get', - summary: 'Get purge status', - description: 'This API returns the status of a purge cache request.\n', - stainlessPath: '(resource) cache.invalidation > (method) get', - qualified: 'client.cache.invalidation.get', - params: ['requestId: string;'], - response: "{ status?: 'Pending' | 'Completed'; }", - markdown: - "## get\n\n`client.cache.invalidation.get(requestId: string): { status?: 'Pending' | 'Completed'; }`\n\n**get** `/v1/files/purge/{requestId}`\n\nThis API returns the status of a purge cache request.\n\n\n### Parameters\n\n- `requestId: string`\n\n### Returns\n\n- `{ status?: 'Pending' | 'Completed'; }`\n\n - `status?: 'Pending' | 'Completed'`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst invalidation = await client.cache.invalidation.get('requestId');\n\nconsole.log(invalidation);\n```", - perLanguage: { - typescript: { - method: 'client.cache.invalidation.get', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst invalidation = await client.cache.invalidation.get('requestId');\n\nconsole.log(invalidation.status);", - }, - python: { - method: 'cache.invalidation.get', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ninvalidation = client.cache.invalidation.get(\n "requestId",\n)\nprint(invalidation.status)', - }, - java: { - method: 'cache().invalidation().get', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.cache.invalidation.InvalidationGetParams;\nimport io.imagekit.models.cache.invalidation.InvalidationGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationGetResponse invalidation = client.cache().invalidation().get("requestId");\n }\n}', - }, - kotlin: { - method: 'cache().invalidation().get', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetParams\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val invalidation: InvalidationGetResponse = client.cache().invalidation().get("requestId")\n}', - }, - go: { - method: 'client.Cache.Invalidation.Get', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tinvalidation, err := client.Cache.Invalidation.Get(context.TODO(), "requestId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", invalidation.Status)\n}\n', - }, - ruby: { - method: 'cache.invalidation.get', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ninvalidation = image_kit.cache.invalidation.get("requestId")\n\nputs(invalidation)', - }, - cli: { - method: 'invalidation get', - example: - "imagekit cache:invalidation get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --request-id requestId", - }, - php: { - method: 'cache->invalidation->get', - example: - "cache->invalidation->get('requestId');\n\nvar_dump($invalidation);", - }, - csharp: { - method: 'Cache.Invalidation.Get', - example: - 'InvalidationGetParams parameters = new() { RequestID = "requestId" };\n\nvar invalidation = await client.Cache.Invalidation.Get(parameters);\n\nConsole.WriteLine(invalidation);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/files/purge/$REQUEST_ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "get", + "endpoint": "/v1/files/purge/{requestId}", + "httpMethod": "get", + "summary": "Get purge status", + "description": "This API returns the status of a purge cache request.\n", + "stainlessPath": "(resource) cache.invalidation > (method) get", + "qualified": "client.cache.invalidation.get", + "params": [ + "requestId: string;" + ], + "response": "{ status?: 'Pending' | 'Completed'; }", + "markdown": "## get\n\n`client.cache.invalidation.get(requestId: string): { status?: 'Pending' | 'Completed'; }`\n\n**get** `/v1/files/purge/{requestId}`\n\nThis API returns the status of a purge cache request.\n\n\n### Parameters\n\n- `requestId: string`\n\n### Returns\n\n- `{ status?: 'Pending' | 'Completed'; }`\n\n - `status?: 'Pending' | 'Completed'`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst invalidation = await client.cache.invalidation.get('requestId');\n\nconsole.log(invalidation);\n```", + "perLanguage": { + "typescript": { + "method": "client.cache.invalidation.get", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst invalidation = await client.cache.invalidation.get('requestId');\n\nconsole.log(invalidation.status);" + }, + "python": { + "method": "cache.invalidation.get", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\ninvalidation = client.cache.invalidation.get(\n \"requestId\",\n)\nprint(invalidation.status)" + }, + "java": { + "method": "cache().invalidation().get", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.cache.invalidation.InvalidationGetParams;\nimport io.imagekit.models.cache.invalidation.InvalidationGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationGetResponse invalidation = client.cache().invalidation().get(\"requestId\");\n }\n}" + }, + "kotlin": { + "method": "cache().invalidation().get", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetParams\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val invalidation: InvalidationGetResponse = client.cache().invalidation().get(\"requestId\")\n}" + }, + "go": { + "method": "client.Cache.Invalidation.Get", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tinvalidation, err := client.Cache.Invalidation.Get(context.TODO(), \"requestId\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", invalidation.Status)\n}\n" + }, + "ruby": { + "method": "cache.invalidation.get", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\ninvalidation = image_kit.cache.invalidation.get(\"requestId\")\n\nputs(invalidation)" + }, + "cli": { + "method": "invalidation get", + "example": "imagekit cache:invalidation get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --request-id requestId" + }, + "php": { + "method": "cache->invalidation->get", + "example": "cache->invalidation->get('requestId');\n\nvar_dump($invalidation);" + }, + "csharp": { + "method": "Cache.Invalidation.Get", + "example": "InvalidationGetParams parameters = new() { RequestID = \"requestId\" };\n\nvar invalidation = await client.Cache.Invalidation.Get(parameters);\n\nConsole.WriteLine(invalidation);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/files/purge/$REQUEST_ID \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'create', - endpoint: '/v1/folder', - httpMethod: 'post', - summary: 'Create folder', - description: - 'This will create a new folder. You can specify the folder name and location of the parent folder where this new folder should be created.\n', - stainlessPath: '(resource) folders > (method) create', - qualified: 'client.folders.create', - params: ['folderName: string;', 'parentFolderPath: string;'], - response: '{ }', - markdown: - "## create\n\n`client.folders.create(folderName: string, parentFolderPath: string): { }`\n\n**post** `/v1/folder`\n\nThis will create a new folder. You can specify the folder name and location of the parent folder where this new folder should be created.\n\n\n### Parameters\n\n- `folderName: string`\n The folder will be created with this name. \n\nAll characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) will be replaced by an underscore i.e. `_`.\n\n\n- `parentFolderPath: string`\n The folder where the new folder should be created, for root use `/` else the path e.g. `containing/folder/`.\n\nNote: If any folder(s) is not present in the parentFolderPath parameter, it will be automatically created. For example, if you pass `/product/images/summer`, then `product`, `images`, and `summer` folders will be created if they don't already exist.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst folder = await client.folders.create({ folderName: 'summer', parentFolderPath: '/product/images/' });\n\nconsole.log(folder);\n```", - perLanguage: { - typescript: { - method: 'client.folders.create', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst folder = await client.folders.create({\n folderName: 'summer',\n parentFolderPath: '/product/images/',\n});\n\nconsole.log(folder);", - }, - python: { - method: 'folders.create', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfolder = client.folders.create(\n folder_name="summer",\n parent_folder_path="/product/images/",\n)\nprint(folder)', - }, - java: { - method: 'folders().create', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderCreateParams;\nimport io.imagekit.models.folders.FolderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCreateParams params = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build();\n FolderCreateResponse folder = client.folders().create(params);\n }\n}', - }, - kotlin: { - method: 'folders().create', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderCreateParams\nimport com.imagekit.api.models.folders.FolderCreateResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderCreateParams = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build()\n val folder: FolderCreateResponse = client.folders().create(params)\n}', - }, - go: { - method: 'client.Folders.New', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfolder, err := client.Folders.New(context.TODO(), imagekit.FolderNewParams{\n\t\tFolderName: "summer",\n\t\tParentFolderPath: "/product/images/",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", folder)\n}\n', - }, - ruby: { - method: 'folders.create', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfolder = image_kit.folders.create(folder_name: "summer", parent_folder_path: "/product/images/")\n\nputs(folder)', - }, - cli: { - method: 'folders create', - example: - "imagekit folders create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-name summer \\\n --parent-folder-path /product/images/", - }, - php: { - method: 'folders->create', - example: - "folders->create(\n folderName: 'summer', parentFolderPath: '/product/images/'\n);\n\nvar_dump($folder);", - }, - csharp: { - method: 'Folders.Create', - example: - 'FolderCreateParams parameters = new()\n{\n FolderName = "summer",\n ParentFolderPath = "/product/images/",\n};\n\nvar folder = await client.Folders.Create(parameters);\n\nConsole.WriteLine(folder);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/folder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "folderName": "summer",\n "parentFolderPath": "/product/images/"\n }\'', - }, - }, + "name": "create", + "endpoint": "/v1/folder", + "httpMethod": "post", + "summary": "Create folder", + "description": "This will create a new folder. You can specify the folder name and location of the parent folder where this new folder should be created.\n", + "stainlessPath": "(resource) folders > (method) create", + "qualified": "client.folders.create", + "params": [ + "folderName: string;", + "parentFolderPath: string;" + ], + "response": "{ }", + "markdown": "## create\n\n`client.folders.create(folderName: string, parentFolderPath: string): { }`\n\n**post** `/v1/folder`\n\nThis will create a new folder. You can specify the folder name and location of the parent folder where this new folder should be created.\n\n\n### Parameters\n\n- `folderName: string`\n The folder will be created with this name. \n\nAll characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) will be replaced by an underscore i.e. `_`.\n\n\n- `parentFolderPath: string`\n The folder where the new folder should be created, for root use `/` else the path e.g. `containing/folder/`.\n\nNote: If any folder(s) is not present in the parentFolderPath parameter, it will be automatically created. For example, if you pass `/product/images/summer`, then `product`, `images`, and `summer` folders will be created if they don't already exist.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst folder = await client.folders.create({ folderName: 'summer', parentFolderPath: '/product/images/' });\n\nconsole.log(folder);\n```", + "perLanguage": { + "typescript": { + "method": "client.folders.create", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst folder = await client.folders.create({\n folderName: 'summer',\n parentFolderPath: '/product/images/',\n});\n\nconsole.log(folder);" + }, + "python": { + "method": "folders.create", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfolder = client.folders.create(\n folder_name=\"summer\",\n parent_folder_path=\"/product/images/\",\n)\nprint(folder)" + }, + "java": { + "method": "folders().create", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderCreateParams;\nimport io.imagekit.models.folders.FolderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCreateParams params = FolderCreateParams.builder()\n .folderName(\"summer\")\n .parentFolderPath(\"/product/images/\")\n .build();\n FolderCreateResponse folder = client.folders().create(params);\n }\n}" + }, + "kotlin": { + "method": "folders().create", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderCreateParams\nimport com.imagekit.api.models.folders.FolderCreateResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderCreateParams = FolderCreateParams.builder()\n .folderName(\"summer\")\n .parentFolderPath(\"/product/images/\")\n .build()\n val folder: FolderCreateResponse = client.folders().create(params)\n}" + }, + "go": { + "method": "client.Folders.New", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfolder, err := client.Folders.New(context.TODO(), imagekit.FolderNewParams{\n\t\tFolderName: \"summer\",\n\t\tParentFolderPath: \"/product/images/\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", folder)\n}\n" + }, + "ruby": { + "method": "folders.create", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfolder = image_kit.folders.create(folder_name: \"summer\", parent_folder_path: \"/product/images/\")\n\nputs(folder)" + }, + "cli": { + "method": "folders create", + "example": "imagekit folders create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-name summer \\\n --parent-folder-path /product/images/" + }, + "php": { + "method": "folders->create", + "example": "folders->create(\n folderName: 'summer', parentFolderPath: '/product/images/'\n);\n\nvar_dump($folder);" + }, + "csharp": { + "method": "Folders.Create", + "example": "FolderCreateParams parameters = new()\n{\n FolderName = \"summer\",\n ParentFolderPath = \"/product/images/\",\n};\n\nvar folder = await client.Folders.Create(parameters);\n\nConsole.WriteLine(folder);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/folder \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"folderName\": \"summer\",\n \"parentFolderPath\": \"/product/images/\"\n }'" + } + } }, { - name: 'delete', - endpoint: '/v1/folder', - httpMethod: 'delete', - summary: 'Delete folder', - description: - 'This will delete a folder and all its contents permanently. The API returns an empty response.\n', - stainlessPath: '(resource) folders > (method) delete', - qualified: 'client.folders.delete', - params: ['folderPath: string;'], - response: '{ }', - markdown: - "## delete\n\n`client.folders.delete(folderPath: string): { }`\n\n**delete** `/v1/folder`\n\nThis will delete a folder and all its contents permanently. The API returns an empty response.\n\n\n### Parameters\n\n- `folderPath: string`\n Full path to the folder you want to delete. For example `/folder/to/delete/`.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst folder = await client.folders.delete({ folderPath: '/folder/to/delete/' });\n\nconsole.log(folder);\n```", - perLanguage: { - typescript: { - method: 'client.folders.delete', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst folder = await client.folders.delete({ folderPath: '/folder/to/delete/' });\n\nconsole.log(folder);", - }, - python: { - method: 'folders.delete', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfolder = client.folders.delete(\n folder_path="/folder/to/delete/",\n)\nprint(folder)', - }, - java: { - method: 'folders().delete', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderDeleteParams;\nimport io.imagekit.models.folders.FolderDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderDeleteParams params = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build();\n FolderDeleteResponse folder = client.folders().delete(params);\n }\n}', - }, - kotlin: { - method: 'folders().delete', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderDeleteParams\nimport com.imagekit.api.models.folders.FolderDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderDeleteParams = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build()\n val folder: FolderDeleteResponse = client.folders().delete(params)\n}', - }, - go: { - method: 'client.Folders.Delete', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfolder, err := client.Folders.Delete(context.TODO(), imagekit.FolderDeleteParams{\n\t\tFolderPath: "/folder/to/delete/",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", folder)\n}\n', - }, - ruby: { - method: 'folders.delete', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfolder = image_kit.folders.delete(folder_path: "/folder/to/delete/")\n\nputs(folder)', - }, - cli: { - method: 'folders delete', - example: - "imagekit folders delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-path /folder/to/delete/", - }, - php: { - method: 'folders->delete', - example: - "folders->delete(folderPath: '/folder/to/delete/');\n\nvar_dump($folder);", - }, - csharp: { - method: 'Folders.Delete', - example: - 'FolderDeleteParams parameters = new() { FolderPath = "/folder/to/delete/" };\n\nvar folder = await client.Folders.Delete(parameters);\n\nConsole.WriteLine(folder);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/folder \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "delete", + "endpoint": "/v1/folder", + "httpMethod": "delete", + "summary": "Delete folder", + "description": "This will delete a folder and all its contents permanently. The API returns an empty response.\n", + "stainlessPath": "(resource) folders > (method) delete", + "qualified": "client.folders.delete", + "params": [ + "folderPath: string;" + ], + "response": "{ }", + "markdown": "## delete\n\n`client.folders.delete(folderPath: string): { }`\n\n**delete** `/v1/folder`\n\nThis will delete a folder and all its contents permanently. The API returns an empty response.\n\n\n### Parameters\n\n- `folderPath: string`\n Full path to the folder you want to delete. For example `/folder/to/delete/`.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst folder = await client.folders.delete({ folderPath: '/folder/to/delete/' });\n\nconsole.log(folder);\n```", + "perLanguage": { + "typescript": { + "method": "client.folders.delete", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst folder = await client.folders.delete({ folderPath: '/folder/to/delete/' });\n\nconsole.log(folder);" + }, + "python": { + "method": "folders.delete", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfolder = client.folders.delete(\n folder_path=\"/folder/to/delete/\",\n)\nprint(folder)" + }, + "java": { + "method": "folders().delete", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderDeleteParams;\nimport io.imagekit.models.folders.FolderDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderDeleteParams params = FolderDeleteParams.builder()\n .folderPath(\"/folder/to/delete/\")\n .build();\n FolderDeleteResponse folder = client.folders().delete(params);\n }\n}" + }, + "kotlin": { + "method": "folders().delete", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderDeleteParams\nimport com.imagekit.api.models.folders.FolderDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderDeleteParams = FolderDeleteParams.builder()\n .folderPath(\"/folder/to/delete/\")\n .build()\n val folder: FolderDeleteResponse = client.folders().delete(params)\n}" + }, + "go": { + "method": "client.Folders.Delete", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfolder, err := client.Folders.Delete(context.TODO(), imagekit.FolderDeleteParams{\n\t\tFolderPath: \"/folder/to/delete/\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", folder)\n}\n" + }, + "ruby": { + "method": "folders.delete", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfolder = image_kit.folders.delete(folder_path: \"/folder/to/delete/\")\n\nputs(folder)" + }, + "cli": { + "method": "folders delete", + "example": "imagekit folders delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-path /folder/to/delete/" + }, + "php": { + "method": "folders->delete", + "example": "folders->delete(folderPath: '/folder/to/delete/');\n\nvar_dump($folder);" + }, + "csharp": { + "method": "Folders.Delete", + "example": "FolderDeleteParams parameters = new() { FolderPath = \"/folder/to/delete/\" };\n\nvar folder = await client.Folders.Delete(parameters);\n\nConsole.WriteLine(folder);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/folder \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'copy', - endpoint: '/v1/bulkJobs/copyFolder', - httpMethod: 'post', - summary: 'Copy folder', - description: - 'This will copy one folder into another. The selected folder, its nested folders, files, and their versions (in `includeVersions` is set to true) are copied in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n', - stainlessPath: '(resource) folders > (method) copy', - qualified: 'client.folders.copy', - params: ['destinationPath: string;', 'sourceFolderPath: string;', 'includeVersions?: boolean;'], - response: '{ jobId: string; }', - markdown: - "## copy\n\n`client.folders.copy(destinationPath: string, sourceFolderPath: string, includeVersions?: boolean): { jobId: string; }`\n\n**post** `/v1/bulkJobs/copyFolder`\n\nThis will copy one folder into another. The selected folder, its nested folders, files, and their versions (in `includeVersions` is set to true) are copied in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the destination folder where you want to copy the source folder into.\n\n\n- `sourceFolderPath: string`\n The full path to the source folder you want to copy.\n\n\n- `includeVersions?: boolean`\n Option to copy all versions of files that are nested inside the selected folder. By default, only the current version of each file will be copied. When set to true, all versions of each file will be copied. Default value - `false`.\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.copy({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' });\n\nconsole.log(response);\n```", - perLanguage: { - typescript: { - method: 'client.folders.copy', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.copy({\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n});\n\nconsole.log(response.jobId);", - }, - python: { - method: 'folders.copy', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.folders.copy(\n destination_path="/path/of/destination/folder",\n source_folder_path="/path/of/source/folder",\n)\nprint(response.job_id)', - }, - java: { - method: 'folders().copy', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderCopyParams;\nimport io.imagekit.models.folders.FolderCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCopyParams params = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderCopyResponse response = client.folders().copy(params);\n }\n}', - }, - kotlin: { - method: 'folders().copy', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderCopyParams\nimport com.imagekit.api.models.folders.FolderCopyResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderCopyParams = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build()\n val response: FolderCopyResponse = client.folders().copy(params)\n}', - }, - go: { - method: 'client.Folders.Copy', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Folders.Copy(context.TODO(), imagekit.FolderCopyParams{\n\t\tDestinationPath: "/path/of/destination/folder",\n\t\tSourceFolderPath: "/path/of/source/folder",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.JobID)\n}\n', - }, - ruby: { - method: 'folders.copy', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.folders.copy(\n destination_path: "/path/of/destination/folder",\n source_folder_path: "/path/of/source/folder"\n)\n\nputs(response)', - }, - cli: { - method: 'folders copy', - example: - "imagekit folders copy \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /path/of/destination/folder \\\n --source-folder-path /path/of/source/folder", - }, - php: { - method: 'folders->copy', - example: - "folders->copy(\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n includeVersions: true,\n);\n\nvar_dump($response);", - }, - csharp: { - method: 'Folders.Copy', - example: - 'FolderCopyParams parameters = new()\n{\n DestinationPath = "/path/of/destination/folder",\n SourceFolderPath = "/path/of/source/folder",\n};\n\nvar response = await client.Folders.Copy(parameters);\n\nConsole.WriteLine(response);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/bulkJobs/copyFolder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/path/of/destination/folder",\n "sourceFolderPath": "/path/of/source/folder",\n "includeVersions": true\n }\'', - }, - }, + "name": "copy", + "endpoint": "/v1/bulkJobs/copyFolder", + "httpMethod": "post", + "summary": "Copy folder", + "description": "This will copy one folder into another. The selected folder, its nested folders, files, and their versions (in `includeVersions` is set to true) are copied in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n", + "stainlessPath": "(resource) folders > (method) copy", + "qualified": "client.folders.copy", + "params": [ + "destinationPath: string;", + "sourceFolderPath: string;", + "includeVersions?: boolean;" + ], + "response": "{ jobId: string; }", + "markdown": "## copy\n\n`client.folders.copy(destinationPath: string, sourceFolderPath: string, includeVersions?: boolean): { jobId: string; }`\n\n**post** `/v1/bulkJobs/copyFolder`\n\nThis will copy one folder into another. The selected folder, its nested folders, files, and their versions (in `includeVersions` is set to true) are copied in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the destination folder where you want to copy the source folder into.\n\n\n- `sourceFolderPath: string`\n The full path to the source folder you want to copy.\n\n\n- `includeVersions?: boolean`\n Option to copy all versions of files that are nested inside the selected folder. By default, only the current version of each file will be copied. When set to true, all versions of each file will be copied. Default value - `false`.\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.copy({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' });\n\nconsole.log(response);\n```", + "perLanguage": { + "typescript": { + "method": "client.folders.copy", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.copy({\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n});\n\nconsole.log(response.jobId);" + }, + "python": { + "method": "folders.copy", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.folders.copy(\n destination_path=\"/path/of/destination/folder\",\n source_folder_path=\"/path/of/source/folder\",\n)\nprint(response.job_id)" + }, + "java": { + "method": "folders().copy", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderCopyParams;\nimport io.imagekit.models.folders.FolderCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCopyParams params = FolderCopyParams.builder()\n .destinationPath(\"/path/of/destination/folder\")\n .sourceFolderPath(\"/path/of/source/folder\")\n .build();\n FolderCopyResponse response = client.folders().copy(params);\n }\n}" + }, + "kotlin": { + "method": "folders().copy", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderCopyParams\nimport com.imagekit.api.models.folders.FolderCopyResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderCopyParams = FolderCopyParams.builder()\n .destinationPath(\"/path/of/destination/folder\")\n .sourceFolderPath(\"/path/of/source/folder\")\n .build()\n val response: FolderCopyResponse = client.folders().copy(params)\n}" + }, + "go": { + "method": "client.Folders.Copy", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Folders.Copy(context.TODO(), imagekit.FolderCopyParams{\n\t\tDestinationPath: \"/path/of/destination/folder\",\n\t\tSourceFolderPath: \"/path/of/source/folder\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.JobID)\n}\n" + }, + "ruby": { + "method": "folders.copy", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.folders.copy(\n destination_path: \"/path/of/destination/folder\",\n source_folder_path: \"/path/of/source/folder\"\n)\n\nputs(response)" + }, + "cli": { + "method": "folders copy", + "example": "imagekit folders copy \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /path/of/destination/folder \\\n --source-folder-path /path/of/source/folder" + }, + "php": { + "method": "folders->copy", + "example": "folders->copy(\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n includeVersions: true,\n);\n\nvar_dump($response);" + }, + "csharp": { + "method": "Folders.Copy", + "example": "FolderCopyParams parameters = new()\n{\n DestinationPath = \"/path/of/destination/folder\",\n SourceFolderPath = \"/path/of/source/folder\",\n};\n\nvar response = await client.Folders.Copy(parameters);\n\nConsole.WriteLine(response);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/bulkJobs/copyFolder \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"destinationPath\": \"/path/of/destination/folder\",\n \"sourceFolderPath\": \"/path/of/source/folder\",\n \"includeVersions\": true\n }'" + } + } }, { - name: 'move', - endpoint: '/v1/bulkJobs/moveFolder', - httpMethod: 'post', - summary: 'Move folder', - description: - 'This will move one folder into another. The selected folder, its nested folders, files, and their versions are moved in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n', - stainlessPath: '(resource) folders > (method) move', - qualified: 'client.folders.move', - params: ['destinationPath: string;', 'sourceFolderPath: string;'], - response: '{ jobId: string; }', - markdown: - "## move\n\n`client.folders.move(destinationPath: string, sourceFolderPath: string): { jobId: string; }`\n\n**post** `/v1/bulkJobs/moveFolder`\n\nThis will move one folder into another. The selected folder, its nested folders, files, and their versions are moved in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the destination folder where you want to move the source folder into.\n\n\n- `sourceFolderPath: string`\n The full path to the source folder you want to move.\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.move({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' });\n\nconsole.log(response);\n```", - perLanguage: { - typescript: { - method: 'client.folders.move', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.move({\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n});\n\nconsole.log(response.jobId);", - }, - python: { - method: 'folders.move', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.folders.move(\n destination_path="/path/of/destination/folder",\n source_folder_path="/path/of/source/folder",\n)\nprint(response.job_id)', - }, - java: { - method: 'folders().move', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderMoveParams;\nimport io.imagekit.models.folders.FolderMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderMoveParams params = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderMoveResponse response = client.folders().move(params);\n }\n}', - }, - kotlin: { - method: 'folders().move', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderMoveParams\nimport com.imagekit.api.models.folders.FolderMoveResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderMoveParams = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build()\n val response: FolderMoveResponse = client.folders().move(params)\n}', - }, - go: { - method: 'client.Folders.Move', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Folders.Move(context.TODO(), imagekit.FolderMoveParams{\n\t\tDestinationPath: "/path/of/destination/folder",\n\t\tSourceFolderPath: "/path/of/source/folder",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.JobID)\n}\n', - }, - ruby: { - method: 'folders.move', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.folders.move(\n destination_path: "/path/of/destination/folder",\n source_folder_path: "/path/of/source/folder"\n)\n\nputs(response)', - }, - cli: { - method: 'folders move', - example: - "imagekit folders move \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /path/of/destination/folder \\\n --source-folder-path /path/of/source/folder", - }, - php: { - method: 'folders->move', - example: - "folders->move(\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n);\n\nvar_dump($response);", - }, - csharp: { - method: 'Folders.Move', - example: - 'FolderMoveParams parameters = new()\n{\n DestinationPath = "/path/of/destination/folder",\n SourceFolderPath = "/path/of/source/folder",\n};\n\nvar response = await client.Folders.Move(parameters);\n\nConsole.WriteLine(response);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/bulkJobs/moveFolder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/path/of/destination/folder",\n "sourceFolderPath": "/path/of/source/folder"\n }\'', - }, - }, + "name": "move", + "endpoint": "/v1/bulkJobs/moveFolder", + "httpMethod": "post", + "summary": "Move folder", + "description": "This will move one folder into another. The selected folder, its nested folders, files, and their versions are moved in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n", + "stainlessPath": "(resource) folders > (method) move", + "qualified": "client.folders.move", + "params": [ + "destinationPath: string;", + "sourceFolderPath: string;" + ], + "response": "{ jobId: string; }", + "markdown": "## move\n\n`client.folders.move(destinationPath: string, sourceFolderPath: string): { jobId: string; }`\n\n**post** `/v1/bulkJobs/moveFolder`\n\nThis will move one folder into another. The selected folder, its nested folders, files, and their versions are moved in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the destination folder where you want to move the source folder into.\n\n\n- `sourceFolderPath: string`\n The full path to the source folder you want to move.\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.move({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' });\n\nconsole.log(response);\n```", + "perLanguage": { + "typescript": { + "method": "client.folders.move", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.move({\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n});\n\nconsole.log(response.jobId);" + }, + "python": { + "method": "folders.move", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.folders.move(\n destination_path=\"/path/of/destination/folder\",\n source_folder_path=\"/path/of/source/folder\",\n)\nprint(response.job_id)" + }, + "java": { + "method": "folders().move", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderMoveParams;\nimport io.imagekit.models.folders.FolderMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderMoveParams params = FolderMoveParams.builder()\n .destinationPath(\"/path/of/destination/folder\")\n .sourceFolderPath(\"/path/of/source/folder\")\n .build();\n FolderMoveResponse response = client.folders().move(params);\n }\n}" + }, + "kotlin": { + "method": "folders().move", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderMoveParams\nimport com.imagekit.api.models.folders.FolderMoveResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderMoveParams = FolderMoveParams.builder()\n .destinationPath(\"/path/of/destination/folder\")\n .sourceFolderPath(\"/path/of/source/folder\")\n .build()\n val response: FolderMoveResponse = client.folders().move(params)\n}" + }, + "go": { + "method": "client.Folders.Move", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Folders.Move(context.TODO(), imagekit.FolderMoveParams{\n\t\tDestinationPath: \"/path/of/destination/folder\",\n\t\tSourceFolderPath: \"/path/of/source/folder\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.JobID)\n}\n" + }, + "ruby": { + "method": "folders.move", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.folders.move(\n destination_path: \"/path/of/destination/folder\",\n source_folder_path: \"/path/of/source/folder\"\n)\n\nputs(response)" + }, + "cli": { + "method": "folders move", + "example": "imagekit folders move \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /path/of/destination/folder \\\n --source-folder-path /path/of/source/folder" + }, + "php": { + "method": "folders->move", + "example": "folders->move(\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n);\n\nvar_dump($response);" + }, + "csharp": { + "method": "Folders.Move", + "example": "FolderMoveParams parameters = new()\n{\n DestinationPath = \"/path/of/destination/folder\",\n SourceFolderPath = \"/path/of/source/folder\",\n};\n\nvar response = await client.Folders.Move(parameters);\n\nConsole.WriteLine(response);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/bulkJobs/moveFolder \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"destinationPath\": \"/path/of/destination/folder\",\n \"sourceFolderPath\": \"/path/of/source/folder\"\n }'" + } + } }, { - name: 'rename', - endpoint: '/v1/bulkJobs/renameFolder', - httpMethod: 'post', - summary: 'Rename folder', - description: - 'This API allows you to rename an existing folder. The folder and all its nested assets and sub-folders will remain unchanged, but their paths will be updated to reflect the new folder name.\n', - stainlessPath: '(resource) folders > (method) rename', - qualified: 'client.folders.rename', - params: ['folderPath: string;', 'newFolderName: string;', 'purgeCache?: boolean;'], - response: '{ jobId: string; }', - markdown: - "## rename\n\n`client.folders.rename(folderPath: string, newFolderName: string, purgeCache?: boolean): { jobId: string; }`\n\n**post** `/v1/bulkJobs/renameFolder`\n\nThis API allows you to rename an existing folder. The folder and all its nested assets and sub-folders will remain unchanged, but their paths will be updated to reflect the new folder name.\n\n\n### Parameters\n\n- `folderPath: string`\n The full path to the folder you want to rename.\n\n\n- `newFolderName: string`\n The new name for the folder.\n\nAll characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) and `-` will be replaced by an underscore i.e. `_`.\n\n\n- `purgeCache?: boolean`\n Option to purge cache for the old nested files and their versions' URLs.\n\nWhen set to true, it will internally issue a purge cache request on CDN to remove the cached content of the old nested files and their versions. There will only be one purge request for all the nested files, which will be counted against your monthly purge quota.\n\nNote: A purge cache request will be issued against `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This will remove all nested files, their versions' URLs, and any transformations made using query parameters on these files or their versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation.\n\nDefault value - `false`\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.rename({ folderPath: '/path/of/folder', newFolderName: 'new-folder-name' });\n\nconsole.log(response);\n```", - perLanguage: { - typescript: { - method: 'client.folders.rename', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.rename({\n folderPath: '/path/of/folder',\n newFolderName: 'new-folder-name',\n});\n\nconsole.log(response.jobId);", - }, - python: { - method: 'folders.rename', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.folders.rename(\n folder_path="/path/of/folder",\n new_folder_name="new-folder-name",\n)\nprint(response.job_id)', - }, - java: { - method: 'folders().rename', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderRenameParams;\nimport io.imagekit.models.folders.FolderRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderRenameParams params = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build();\n FolderRenameResponse response = client.folders().rename(params);\n }\n}', - }, - kotlin: { - method: 'folders().rename', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderRenameParams\nimport com.imagekit.api.models.folders.FolderRenameResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderRenameParams = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build()\n val response: FolderRenameResponse = client.folders().rename(params)\n}', - }, - go: { - method: 'client.Folders.Rename', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Folders.Rename(context.TODO(), imagekit.FolderRenameParams{\n\t\tFolderPath: "/path/of/folder",\n\t\tNewFolderName: "new-folder-name",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.JobID)\n}\n', - }, - ruby: { - method: 'folders.rename', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.folders.rename(folder_path: "/path/of/folder", new_folder_name: "new-folder-name")\n\nputs(response)', - }, - cli: { - method: 'folders rename', - example: - "imagekit folders rename \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-path /path/of/folder \\\n --new-folder-name new-folder-name", - }, - php: { - method: 'folders->rename', - example: - "folders->rename(\n folderPath: '/path/of/folder',\n newFolderName: 'new-folder-name',\n purgeCache: true,\n);\n\nvar_dump($response);", - }, - csharp: { - method: 'Folders.Rename', - example: - 'FolderRenameParams parameters = new()\n{\n FolderPath = "/path/of/folder",\n NewFolderName = "new-folder-name",\n};\n\nvar response = await client.Folders.Rename(parameters);\n\nConsole.WriteLine(response);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/bulkJobs/renameFolder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "folderPath": "/path/of/folder",\n "newFolderName": "new-folder-name",\n "purgeCache": true\n }\'', - }, - }, + "name": "rename", + "endpoint": "/v1/bulkJobs/renameFolder", + "httpMethod": "post", + "summary": "Rename folder", + "description": "This API allows you to rename an existing folder. The folder and all its nested assets and sub-folders will remain unchanged, but their paths will be updated to reflect the new folder name.\n", + "stainlessPath": "(resource) folders > (method) rename", + "qualified": "client.folders.rename", + "params": [ + "folderPath: string;", + "newFolderName: string;", + "purgeCache?: boolean;" + ], + "response": "{ jobId: string; }", + "markdown": "## rename\n\n`client.folders.rename(folderPath: string, newFolderName: string, purgeCache?: boolean): { jobId: string; }`\n\n**post** `/v1/bulkJobs/renameFolder`\n\nThis API allows you to rename an existing folder. The folder and all its nested assets and sub-folders will remain unchanged, but their paths will be updated to reflect the new folder name.\n\n\n### Parameters\n\n- `folderPath: string`\n The full path to the folder you want to rename.\n\n\n- `newFolderName: string`\n The new name for the folder.\n\nAll characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) and `-` will be replaced by an underscore i.e. `_`.\n\n\n- `purgeCache?: boolean`\n Option to purge cache for the old nested files and their versions' URLs.\n\nWhen set to true, it will internally issue a purge cache request on CDN to remove the cached content of the old nested files and their versions. There will only be one purge request for all the nested files, which will be counted against your monthly purge quota.\n\nNote: A purge cache request will be issued against `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This will remove all nested files, their versions' URLs, and any transformations made using query parameters on these files or their versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation.\n\nDefault value - `false`\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.rename({ folderPath: '/path/of/folder', newFolderName: 'new-folder-name' });\n\nconsole.log(response);\n```", + "perLanguage": { + "typescript": { + "method": "client.folders.rename", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.rename({\n folderPath: '/path/of/folder',\n newFolderName: 'new-folder-name',\n});\n\nconsole.log(response.jobId);" + }, + "python": { + "method": "folders.rename", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.folders.rename(\n folder_path=\"/path/of/folder\",\n new_folder_name=\"new-folder-name\",\n)\nprint(response.job_id)" + }, + "java": { + "method": "folders().rename", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderRenameParams;\nimport io.imagekit.models.folders.FolderRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderRenameParams params = FolderRenameParams.builder()\n .folderPath(\"/path/of/folder\")\n .newFolderName(\"new-folder-name\")\n .build();\n FolderRenameResponse response = client.folders().rename(params);\n }\n}" + }, + "kotlin": { + "method": "folders().rename", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderRenameParams\nimport com.imagekit.api.models.folders.FolderRenameResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderRenameParams = FolderRenameParams.builder()\n .folderPath(\"/path/of/folder\")\n .newFolderName(\"new-folder-name\")\n .build()\n val response: FolderRenameResponse = client.folders().rename(params)\n}" + }, + "go": { + "method": "client.Folders.Rename", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Folders.Rename(context.TODO(), imagekit.FolderRenameParams{\n\t\tFolderPath: \"/path/of/folder\",\n\t\tNewFolderName: \"new-folder-name\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.JobID)\n}\n" + }, + "ruby": { + "method": "folders.rename", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.folders.rename(folder_path: \"/path/of/folder\", new_folder_name: \"new-folder-name\")\n\nputs(response)" + }, + "cli": { + "method": "folders rename", + "example": "imagekit folders rename \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-path /path/of/folder \\\n --new-folder-name new-folder-name" + }, + "php": { + "method": "folders->rename", + "example": "folders->rename(\n folderPath: '/path/of/folder',\n newFolderName: 'new-folder-name',\n purgeCache: true,\n);\n\nvar_dump($response);" + }, + "csharp": { + "method": "Folders.Rename", + "example": "FolderRenameParams parameters = new()\n{\n FolderPath = \"/path/of/folder\",\n NewFolderName = \"new-folder-name\",\n};\n\nvar response = await client.Folders.Rename(parameters);\n\nConsole.WriteLine(response);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/bulkJobs/renameFolder \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"folderPath\": \"/path/of/folder\",\n \"newFolderName\": \"new-folder-name\",\n \"purgeCache\": true\n }'" + } + } }, { - name: 'get', - endpoint: '/v1/bulkJobs/{jobId}', - httpMethod: 'get', - summary: 'Bulk job status', - description: 'This API returns the status of a bulk job like copy and move folder operations.\n', - stainlessPath: '(resource) folders.job > (method) get', - qualified: 'client.folders.job.get', - params: ['jobId: string;'], - response: - "{ jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }", - markdown: - "## get\n\n`client.folders.job.get(jobId: string): { jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }`\n\n**get** `/v1/bulkJobs/{jobId}`\n\nThis API returns the status of a bulk job like copy and move folder operations.\n\n\n### Parameters\n\n- `jobId: string`\n\n### Returns\n\n- `{ jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }`\n\n - `jobId?: string`\n - `purgeRequestId?: string`\n - `status?: 'Pending' | 'Completed'`\n - `type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst job = await client.folders.job.get('jobId');\n\nconsole.log(job);\n```", - perLanguage: { - typescript: { - method: 'client.folders.job.get', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst job = await client.folders.job.get('jobId');\n\nconsole.log(job.jobId);", - }, - python: { - method: 'folders.job.get', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\njob = client.folders.job.get(\n "jobId",\n)\nprint(job.job_id)', - }, - java: { - method: 'folders().job().get', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.job.JobGetParams;\nimport io.imagekit.models.folders.job.JobGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n JobGetResponse job = client.folders().job().get("jobId");\n }\n}', - }, - kotlin: { - method: 'folders().job().get', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.job.JobGetParams\nimport com.imagekit.api.models.folders.job.JobGetResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val job: JobGetResponse = client.folders().job().get("jobId")\n}', - }, - go: { - method: 'client.Folders.Job.Get', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tjob, err := client.Folders.Job.Get(context.TODO(), "jobId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", job.JobID)\n}\n', - }, - ruby: { - method: 'folders.job.get', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\njob = image_kit.folders.job.get("jobId")\n\nputs(job)', - }, - cli: { - method: 'job get', - example: - "imagekit folders:job get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --job-id jobId", - }, - php: { - method: 'folders->job->get', - example: - "folders->job->get('jobId');\n\nvar_dump($job);", - }, - csharp: { - method: 'Folders.Job.Get', - example: - 'JobGetParams parameters = new() { JobID = "jobId" };\n\nvar job = await client.Folders.Job.Get(parameters);\n\nConsole.WriteLine(job);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/bulkJobs/$JOB_ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "get", + "endpoint": "/v1/bulkJobs/{jobId}", + "httpMethod": "get", + "summary": "Bulk job status", + "description": "This API returns the status of a bulk job like copy and move folder operations.\n", + "stainlessPath": "(resource) folders.job > (method) get", + "qualified": "client.folders.job.get", + "params": [ + "jobId: string;" + ], + "response": "{ jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }", + "markdown": "## get\n\n`client.folders.job.get(jobId: string): { jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }`\n\n**get** `/v1/bulkJobs/{jobId}`\n\nThis API returns the status of a bulk job like copy and move folder operations.\n\n\n### Parameters\n\n- `jobId: string`\n\n### Returns\n\n- `{ jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }`\n\n - `jobId?: string`\n - `purgeRequestId?: string`\n - `status?: 'Pending' | 'Completed'`\n - `type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst job = await client.folders.job.get('jobId');\n\nconsole.log(job);\n```", + "perLanguage": { + "typescript": { + "method": "client.folders.job.get", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst job = await client.folders.job.get('jobId');\n\nconsole.log(job.jobId);" + }, + "python": { + "method": "folders.job.get", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\njob = client.folders.job.get(\n \"jobId\",\n)\nprint(job.job_id)" + }, + "java": { + "method": "folders().job().get", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.job.JobGetParams;\nimport io.imagekit.models.folders.job.JobGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n JobGetResponse job = client.folders().job().get(\"jobId\");\n }\n}" + }, + "kotlin": { + "method": "folders().job().get", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.job.JobGetParams\nimport com.imagekit.api.models.folders.job.JobGetResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val job: JobGetResponse = client.folders().job().get(\"jobId\")\n}" + }, + "go": { + "method": "client.Folders.Job.Get", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tjob, err := client.Folders.Job.Get(context.TODO(), \"jobId\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", job.JobID)\n}\n" + }, + "ruby": { + "method": "folders.job.get", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\njob = image_kit.folders.job.get(\"jobId\")\n\nputs(job)" + }, + "cli": { + "method": "job get", + "example": "imagekit folders:job get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --job-id jobId" + }, + "php": { + "method": "folders->job->get", + "example": "folders->job->get('jobId');\n\nvar_dump($job);" + }, + "csharp": { + "method": "Folders.Job.Get", + "example": "JobGetParams parameters = new() { JobID = \"jobId\" };\n\nvar job = await client.Folders.Job.Get(parameters);\n\nConsole.WriteLine(job);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/bulkJobs/$JOB_ID \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'get', - endpoint: '/v1/accounts/usage', - httpMethod: 'get', - summary: 'Get account usage information', - description: - 'Get the account usage information between two dates. Note that the API response includes data from the start date while excluding data from the end date. In other words, the data covers the period starting from the specified start date up to, but not including, the end date.\n', - stainlessPath: '(resource) accounts.usage > (method) get', - qualified: 'client.accounts.usage.get', - params: ['endDate: string;', 'startDate: string;'], - response: - '{ bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }', - markdown: - "## get\n\n`client.accounts.usage.get(endDate: string, startDate: string): { bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }`\n\n**get** `/v1/accounts/usage`\n\nGet the account usage information between two dates. Note that the API response includes data from the start date while excluding data from the end date. In other words, the data covers the period starting from the specified start date up to, but not including, the end date.\n\n\n### Parameters\n\n- `endDate: string`\n Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. The difference between `startDate` and `endDate` should be less than 90 days.\n\n- `startDate: string`\n Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. The difference between `startDate` and `endDate` should be less than 90 days.\n\n### Returns\n\n- `{ bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }`\n\n - `bandwidthBytes?: number`\n - `extensionUnitsCount?: number`\n - `mediaLibraryStorageBytes?: number`\n - `originalCacheStorageBytes?: number`\n - `videoProcessingUnitsCount?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst usage = await client.accounts.usage.get({ endDate: '2019-12-27', startDate: '2019-12-27' });\n\nconsole.log(usage);\n```", - perLanguage: { - typescript: { - method: 'client.accounts.usage.get', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst usage = await client.accounts.usage.get({ endDate: '2019-12-27', startDate: '2019-12-27' });\n\nconsole.log(usage.bandwidthBytes);", - }, - python: { - method: 'accounts.usage.get', - example: - 'import os\nfrom datetime import date\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nusage = client.accounts.usage.get(\n end_date=date.fromisoformat("2019-12-27"),\n start_date=date.fromisoformat("2019-12-27"),\n)\nprint(usage.bandwidth_bytes)', - }, - java: { - method: 'accounts().usage().get', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.usage.UsageGetParams;\nimport io.imagekit.models.accounts.usage.UsageGetResponse;\nimport java.time.LocalDate;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UsageGetParams params = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build();\n UsageGetResponse usage = client.accounts().usage().get(params);\n }\n}', - }, - kotlin: { - method: 'accounts().usage().get', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.usage.UsageGetParams\nimport com.imagekit.api.models.accounts.usage.UsageGetResponse\nimport java.time.LocalDate\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UsageGetParams = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build()\n val usage: UsageGetResponse = client.accounts().usage().get(params)\n}', - }, - go: { - method: 'client.Accounts.Usage.Get', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tusage, err := client.Accounts.Usage.Get(context.TODO(), imagekit.AccountUsageGetParams{\n\t\tEndDate: time.Now(),\n\t\tStartDate: time.Now(),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", usage.BandwidthBytes)\n}\n', - }, - ruby: { - method: 'accounts.usage.get', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nusage = image_kit.accounts.usage.get(end_date: "2019-12-27", start_date: "2019-12-27")\n\nputs(usage)', - }, - cli: { - method: 'usage get', - example: - "imagekit accounts:usage get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --end-date \"'2019-12-27'\" \\\n --start-date \"'2019-12-27'\"", - }, - php: { - method: 'accounts->usage->get', - example: - "accounts->usage->get(\n endDate: '2019-12-27', startDate: '2019-12-27'\n);\n\nvar_dump($usage);", - }, - csharp: { - method: 'Accounts.Usage.Get', - example: - 'UsageGetParams parameters = new()\n{\n EndDate = "2019-12-27",\n StartDate = "2019-12-27",\n};\n\nvar usage = await client.Accounts.Usage.Get(parameters);\n\nConsole.WriteLine(usage);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/accounts/usage \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "get", + "endpoint": "/v1/accounts/usage", + "httpMethod": "get", + "summary": "Get account usage information", + "description": "Get the account usage information between two dates. Note that the API response includes data from the start date while excluding data from the end date. In other words, the data covers the period starting from the specified start date up to, but not including, the end date.\n", + "stainlessPath": "(resource) accounts.usage > (method) get", + "qualified": "client.accounts.usage.get", + "params": [ + "endDate: string;", + "startDate: string;" + ], + "response": "{ bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }", + "markdown": "## get\n\n`client.accounts.usage.get(endDate: string, startDate: string): { bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }`\n\n**get** `/v1/accounts/usage`\n\nGet the account usage information between two dates. Note that the API response includes data from the start date while excluding data from the end date. In other words, the data covers the period starting from the specified start date up to, but not including, the end date.\n\n\n### Parameters\n\n- `endDate: string`\n Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. The difference between `startDate` and `endDate` should be less than 90 days.\n\n- `startDate: string`\n Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. The difference between `startDate` and `endDate` should be less than 90 days.\n\n### Returns\n\n- `{ bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }`\n\n - `bandwidthBytes?: number`\n - `extensionUnitsCount?: number`\n - `mediaLibraryStorageBytes?: number`\n - `originalCacheStorageBytes?: number`\n - `videoProcessingUnitsCount?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst usage = await client.accounts.usage.get({ endDate: '2019-12-27', startDate: '2019-12-27' });\n\nconsole.log(usage);\n```", + "perLanguage": { + "typescript": { + "method": "client.accounts.usage.get", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst usage = await client.accounts.usage.get({ endDate: '2019-12-27', startDate: '2019-12-27' });\n\nconsole.log(usage.bandwidthBytes);" + }, + "python": { + "method": "accounts.usage.get", + "example": "import os\nfrom datetime import date\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nusage = client.accounts.usage.get(\n end_date=date.fromisoformat(\"2019-12-27\"),\n start_date=date.fromisoformat(\"2019-12-27\"),\n)\nprint(usage.bandwidth_bytes)" + }, + "java": { + "method": "accounts().usage().get", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.usage.UsageGetParams;\nimport io.imagekit.models.accounts.usage.UsageGetResponse;\nimport java.time.LocalDate;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UsageGetParams params = UsageGetParams.builder()\n .endDate(LocalDate.parse(\"2019-12-27\"))\n .startDate(LocalDate.parse(\"2019-12-27\"))\n .build();\n UsageGetResponse usage = client.accounts().usage().get(params);\n }\n}" + }, + "kotlin": { + "method": "accounts().usage().get", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.usage.UsageGetParams\nimport com.imagekit.api.models.accounts.usage.UsageGetResponse\nimport java.time.LocalDate\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UsageGetParams = UsageGetParams.builder()\n .endDate(LocalDate.parse(\"2019-12-27\"))\n .startDate(LocalDate.parse(\"2019-12-27\"))\n .build()\n val usage: UsageGetResponse = client.accounts().usage().get(params)\n}" + }, + "go": { + "method": "client.Accounts.Usage.Get", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tusage, err := client.Accounts.Usage.Get(context.TODO(), imagekit.AccountUsageGetParams{\n\t\tEndDate: time.Now(),\n\t\tStartDate: time.Now(),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", usage.BandwidthBytes)\n}\n" + }, + "ruby": { + "method": "accounts.usage.get", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nusage = image_kit.accounts.usage.get(end_date: \"2019-12-27\", start_date: \"2019-12-27\")\n\nputs(usage)" + }, + "cli": { + "method": "usage get", + "example": "imagekit accounts:usage get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --end-date \"'2019-12-27'\" \\\n --start-date \"'2019-12-27'\"" + }, + "php": { + "method": "accounts->usage->get", + "example": "accounts->usage->get(\n endDate: '2019-12-27', startDate: '2019-12-27'\n);\n\nvar_dump($usage);" + }, + "csharp": { + "method": "Accounts.Usage.Get", + "example": "UsageGetParams parameters = new()\n{\n EndDate = \"2019-12-27\",\n StartDate = \"2019-12-27\",\n};\n\nvar usage = await client.Accounts.Usage.Get(parameters);\n\nConsole.WriteLine(usage);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/accounts/usage \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'list', - endpoint: '/v1/accounts/origins', - httpMethod: 'get', - summary: 'List origins', - description: - '**Note:** This API is currently in beta. \nReturns an array of all configured origins for the current account.\n', - stainlessPath: '(resource) accounts.origins > (method) list', - qualified: 'client.accounts.origins.list', - response: 'object | object | object | object | object | object | object | object[]', - markdown: - "## list\n\n`client.accounts.origins.list(): object | object | object | object | object | object | object | object[]`\n\n**get** `/v1/accounts/origins`\n\n**Note:** This API is currently in beta. \nReturns an array of all configured origins for the current account.\n\n\n### Returns\n\n- `{ id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst originResponses = await client.accounts.origins.list();\n\nconsole.log(originResponses);\n```", - perLanguage: { - typescript: { - method: 'client.accounts.origins.list', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponses = await client.accounts.origins.list();\n\nconsole.log(originResponses);", - }, - python: { - method: 'accounts.origins.list', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_responses = client.accounts.origins.list()\nprint(origin_responses)', - }, - java: { - method: 'accounts().origins().list', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginListParams;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List originResponses = client.accounts().origins().list();\n }\n}', - }, - kotlin: { - method: 'accounts().origins().list', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginListParams\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val originResponses: List = client.accounts().origins().list()\n}', - }, - go: { - method: 'client.Accounts.Origins.List', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponses, err := client.Accounts.Origins.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponses)\n}\n', - }, - ruby: { - method: 'accounts.origins.list', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\norigin_responses = image_kit.accounts.origins.list\n\nputs(origin_responses)', - }, - cli: { - method: 'origins list', - example: - "imagekit accounts:origins list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - php: { - method: 'accounts->origins->list', - example: - "accounts->origins->list();\n\nvar_dump($originResponses);", - }, - csharp: { - method: 'Accounts.Origins.List', - example: - 'OriginListParams parameters = new();\n\nvar originResponses = await client.Accounts.Origins.List(parameters);\n\nConsole.WriteLine(originResponses);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/accounts/origins \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "list", + "endpoint": "/v1/accounts/origins", + "httpMethod": "get", + "summary": "List origins", + "description": "**Note:** This API is currently in beta. \nReturns an array of all configured origins for the current account.\n", + "stainlessPath": "(resource) accounts.origins > (method) list", + "qualified": "client.accounts.origins.list", + "response": "object | object | object | object | object | object | object | object[]", + "markdown": "## list\n\n`client.accounts.origins.list(): object | object | object | object | object | object | object | object[]`\n\n**get** `/v1/accounts/origins`\n\n**Note:** This API is currently in beta. \nReturns an array of all configured origins for the current account.\n\n\n### Returns\n\n- `{ id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst originResponses = await client.accounts.origins.list();\n\nconsole.log(originResponses);\n```", + "perLanguage": { + "typescript": { + "method": "client.accounts.origins.list", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponses = await client.accounts.origins.list();\n\nconsole.log(originResponses);" + }, + "python": { + "method": "accounts.origins.list", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\norigin_responses = client.accounts.origins.list()\nprint(origin_responses)" + }, + "java": { + "method": "accounts().origins().list", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginListParams;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List originResponses = client.accounts().origins().list();\n }\n}" + }, + "kotlin": { + "method": "accounts().origins().list", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginListParams\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val originResponses: List = client.accounts().origins().list()\n}" + }, + "go": { + "method": "client.Accounts.Origins.List", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\toriginResponses, err := client.Accounts.Origins.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", originResponses)\n}\n" + }, + "ruby": { + "method": "accounts.origins.list", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\norigin_responses = image_kit.accounts.origins.list\n\nputs(origin_responses)" + }, + "cli": { + "method": "origins list", + "example": "imagekit accounts:origins list \\\n --private-key 'My Private Key' \\\n --password 'My Password'" + }, + "php": { + "method": "accounts->origins->list", + "example": "accounts->origins->list();\n\nvar_dump($originResponses);" + }, + "csharp": { + "method": "Accounts.Origins.List", + "example": "OriginListParams parameters = new();\n\nvar originResponses = await client.Accounts.Origins.List(parameters);\n\nConsole.WriteLine(originResponses);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/accounts/origins \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'create', - endpoint: '/v1/accounts/origins', - httpMethod: 'post', - summary: 'Create origin', - description: - '**Note:** This API is currently in beta. \nCreates a new origin and returns the origin object.\n', - stainlessPath: '(resource) accounts.origins > (method) create', - qualified: 'client.accounts.origins.create', - params: [ - "OriginRequest: { accessKey: string; bucket: string; name: string; secretKey: string; type: 'S3'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accessKey: string; bucket: string; endpoint: string; name: string; secretKey: string; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; s3ForcePathStyle?: boolean; } | { accessKey: string; bucket: string; name: string; secretKey: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; forwardHostHeaderToOrigin?: boolean; includeCanonicalHeader?: boolean; } | { name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; } | { bucket: string; clientEmail: string; name: string; privateKey: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accountName: string; container: string; name: string; sasToken: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; clientId: string; clientSecret: string; name: string; password: string; type: 'AKENEO_PIM'; username: string; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; };", + "name": "create", + "endpoint": "/v1/accounts/origins", + "httpMethod": "post", + "summary": "Create origin", + "description": "**Note:** This API is currently in beta. \nCreates a new origin and returns the origin object.\n", + "stainlessPath": "(resource) accounts.origins > (method) create", + "qualified": "client.accounts.origins.create", + "params": [ + "OriginRequest: { accessKey: string; bucket: string; name: string; secretKey: string; type: 'S3'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accessKey: string; bucket: string; endpoint: string; name: string; secretKey: string; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; s3ForcePathStyle?: boolean; } | { accessKey: string; bucket: string; name: string; secretKey: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; forwardHostHeaderToOrigin?: boolean; includeCanonicalHeader?: boolean; } | { name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; } | { bucket: string; clientEmail: string; name: string; privateKey: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accountName: string; container: string; name: string; sasToken: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; clientId: string; clientSecret: string; name: string; password: string; type: 'AKENEO_PIM'; username: string; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; };" ], - response: 'object | object | object | object | object | object | object | object', - perLanguage: { - typescript: { - method: 'client.accounts.origins.create', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.create({\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'product-images',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'S3',\n});\n\nconsole.log(originResponse);", - }, - python: { - method: 'accounts.origins.create', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.create(\n access_key="AKIAIOSFODNN7EXAMPLE",\n bucket="product-images",\n name="US S3 Storage",\n secret_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n type="S3",\n)\nprint(origin_response)', - }, - java: { - method: 'accounts().origins().create', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginCreateParams;\nimport io.imagekit.models.accounts.origins.OriginRequest;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}', - }, - kotlin: { - method: 'accounts().origins().create', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginCreateParams\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginRequest.S3 = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build()\n val originResponse: OriginResponse = client.accounts().origins().create(params)\n}', - }, - go: { - method: 'client.Accounts.Origins.New', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.New(context.TODO(), imagekit.AccountOriginNewParams{\n\t\tOriginRequest: imagekit.OriginRequestUnionParam{\n\t\t\tOfS3: &imagekit.OriginRequestS3Param{\n\t\t\t\tAccessKey: "AKIATEST123",\n\t\t\t\tBucket: "test-bucket",\n\t\t\t\tName: "My S3 Origin",\n\t\t\t\tSecretKey: "secrettest123",\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponse)\n}\n', - }, - ruby: { - method: 'accounts.origins.create', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\norigin_response = image_kit.accounts.origins.create(\n origin_request: {accessKey: "AKIATEST123", bucket: "test-bucket", name: "My S3 Origin", secretKey: "secrettest123", type: :S3}\n)\n\nputs(origin_response)', - }, - cli: { - method: 'origins create', - example: - "imagekit accounts:origins create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --access-key AKIAIOSFODNN7EXAMPLE \\\n --bucket product-images \\\n --name 'US S3 Storage' \\\n --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \\\n --type S3 \\\n --endpoint https://s3.eu-central-1.wasabisys.com \\\n --base-url https://images.example.com/assets \\\n --client-email service-account@project.iam.gserviceaccount.com \\\n --private-key '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...' \\\n --account-name account123 \\\n --container images \\\n --sas-token '?sv=2023-01-03&sr=c&sig=abc123' \\\n --client-id akeneo-client-id \\\n --client-secret akeneo-client-secret \\\n --password strongpassword123 \\\n --username integration-user", - }, - php: { - method: 'accounts->origins->create', - example: - "accounts->origins->create(\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'gcs-media',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'AKENEO_PIM',\n baseURLForCanonicalHeader: 'https://cdn.example.com',\n includeCanonicalHeader: false,\n prefix: 'uploads',\n endpoint: 'https://s3.eu-central-1.wasabisys.com',\n s3ForcePathStyle: true,\n baseURL: 'https://akeneo.company.com',\n forwardHostHeaderToOrigin: false,\n clientEmail: 'service-account@project.iam.gserviceaccount.com',\n privateKey: '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...',\n accountName: 'account123',\n container: 'images',\n sasToken: '?sv=2023-01-03&sr=c&sig=abc123',\n clientID: 'akeneo-client-id',\n clientSecret: 'akeneo-client-secret',\n password: 'strongpassword123',\n username: 'integration-user',\n);\n\nvar_dump($originResponse);", - }, - csharp: { - method: 'Accounts.Origins.Create', - example: - 'OriginCreateParams parameters = new()\n{\n OriginRequest = new S3()\n {\n AccessKey = "AKIATEST123",\n Bucket = "test-bucket",\n Name = "My S3 Origin",\n SecretKey = "secrettest123",\n BaseUrlForCanonicalHeader = "https://cdn.example.com",\n IncludeCanonicalHeader = false,\n Prefix = "images",\n },\n};\n\nvar originResponse = await client.Accounts.Origins.Create(parameters);\n\nConsole.WriteLine(originResponse);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/accounts/origins \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "accessKey": "AKIAIOSFODNN7EXAMPLE",\n "bucket": "product-images",\n "name": "US S3 Storage",\n "secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n "type": "S3",\n "baseUrlForCanonicalHeader": "https://cdn.example.com",\n "prefix": "raw-assets"\n }\'', - }, - }, + "response": "object | object | object | object | object | object | object | object", + "perLanguage": { + "typescript": { + "method": "client.accounts.origins.create", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.create({\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'product-images',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'S3',\n});\n\nconsole.log(originResponse);" + }, + "python": { + "method": "accounts.origins.create", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.create(\n access_key=\"AKIAIOSFODNN7EXAMPLE\",\n bucket=\"product-images\",\n name=\"US S3 Storage\",\n secret_key=\"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n type=\"S3\",\n)\nprint(origin_response)" + }, + "java": { + "method": "accounts().origins().create", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginCreateParams;\nimport io.imagekit.models.accounts.origins.OriginRequest;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey(\"AKIATEST123\")\n .bucket(\"test-bucket\")\n .name(\"My S3 Origin\")\n .secretKey(\"secrettest123\")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}" + }, + "kotlin": { + "method": "accounts().origins().create", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginCreateParams\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginRequest.S3 = OriginRequest.S3.builder()\n .accessKey(\"AKIATEST123\")\n .bucket(\"test-bucket\")\n .name(\"My S3 Origin\")\n .secretKey(\"secrettest123\")\n .build()\n val originResponse: OriginResponse = client.accounts().origins().create(params)\n}" + }, + "go": { + "method": "client.Accounts.Origins.New", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.New(context.TODO(), imagekit.AccountOriginNewParams{\n\t\tOriginRequest: imagekit.OriginRequestUnionParam{\n\t\t\tOfS3: &imagekit.OriginRequestS3Param{\n\t\t\t\tAccessKey: \"AKIATEST123\",\n\t\t\t\tBucket: \"test-bucket\",\n\t\t\t\tName: \"My S3 Origin\",\n\t\t\t\tSecretKey: \"secrettest123\",\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", originResponse)\n}\n" + }, + "ruby": { + "method": "accounts.origins.create", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\norigin_response = image_kit.accounts.origins.create(\n origin_request: {accessKey: \"AKIATEST123\", bucket: \"test-bucket\", name: \"My S3 Origin\", secretKey: \"secrettest123\", type: :S3}\n)\n\nputs(origin_response)" + }, + "cli": { + "method": "origins create", + "example": "imagekit accounts:origins create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --access-key AKIAIOSFODNN7EXAMPLE \\\n --bucket product-images \\\n --name 'US S3 Storage' \\\n --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \\\n --type S3 \\\n --endpoint https://s3.eu-central-1.wasabisys.com \\\n --base-url https://images.example.com/assets \\\n --client-email service-account@project.iam.gserviceaccount.com \\\n --private-key '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...' \\\n --account-name account123 \\\n --container images \\\n --sas-token '?sv=2023-01-03&sr=c&sig=abc123' \\\n --client-id akeneo-client-id \\\n --client-secret akeneo-client-secret \\\n --password strongpassword123 \\\n --username integration-user" + }, + "php": { + "method": "accounts->origins->create", + "example": "accounts->origins->create(\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'gcs-media',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'AKENEO_PIM',\n baseURLForCanonicalHeader: 'https://cdn.example.com',\n includeCanonicalHeader: false,\n prefix: 'uploads',\n endpoint: 'https://s3.eu-central-1.wasabisys.com',\n s3ForcePathStyle: true,\n baseURL: 'https://akeneo.company.com',\n forwardHostHeaderToOrigin: false,\n clientEmail: 'service-account@project.iam.gserviceaccount.com',\n privateKey: '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...',\n accountName: 'account123',\n container: 'images',\n sasToken: '?sv=2023-01-03&sr=c&sig=abc123',\n clientID: 'akeneo-client-id',\n clientSecret: 'akeneo-client-secret',\n password: 'strongpassword123',\n username: 'integration-user',\n);\n\nvar_dump($originResponse);" + }, + "csharp": { + "method": "Accounts.Origins.Create", + "example": "OriginCreateParams parameters = new()\n{\n OriginRequest = new S3()\n {\n AccessKey = \"AKIATEST123\",\n Bucket = \"test-bucket\",\n Name = \"My S3 Origin\",\n SecretKey = \"secrettest123\",\n BaseUrlForCanonicalHeader = \"https://cdn.example.com\",\n IncludeCanonicalHeader = false,\n Prefix = \"images\",\n },\n};\n\nvar originResponse = await client.Accounts.Origins.Create(parameters);\n\nConsole.WriteLine(originResponse);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/accounts/origins \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"accessKey\": \"AKIAIOSFODNN7EXAMPLE\",\n \"bucket\": \"product-images\",\n \"name\": \"US S3 Storage\",\n \"secretKey\": \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n \"type\": \"S3\",\n \"baseUrlForCanonicalHeader\": \"https://cdn.example.com\",\n \"prefix\": \"raw-assets\"\n }'" + } + } }, { - name: 'get', - endpoint: '/v1/accounts/origins/{id}', - httpMethod: 'get', - summary: 'Get origin', - description: '**Note:** This API is currently in beta. \nRetrieves the origin identified by `id`.\n', - stainlessPath: '(resource) accounts.origins > (method) get', - qualified: 'client.accounts.origins.get', - params: ['id: string;'], - response: 'object | object | object | object | object | object | object | object', - markdown: - "## get\n\n`client.accounts.origins.get(id: string): { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }`\n\n**get** `/v1/accounts/origins/{id}`\n\n**Note:** This API is currently in beta. \nRetrieves the origin identified by `id`.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the origin. This is generated by ImageKit when you create a new origin.\n\n### Returns\n\n- `{ id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }`\n Origin object as returned by the API (sensitive fields removed).\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst originResponse = await client.accounts.origins.get('id');\n\nconsole.log(originResponse);\n```", - perLanguage: { - typescript: { - method: 'client.accounts.origins.get', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.get('id');\n\nconsole.log(originResponse);", - }, - python: { - method: 'accounts.origins.get', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.get(\n "id",\n)\nprint(origin_response)', - }, - java: { - method: 'accounts().origins().get', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginGetParams;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginResponse originResponse = client.accounts().origins().get("id");\n }\n}', - }, - kotlin: { - method: 'accounts().origins().get', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginGetParams\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val originResponse: OriginResponse = client.accounts().origins().get("id")\n}', - }, - go: { - method: 'client.Accounts.Origins.Get', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.Get(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponse)\n}\n', - }, - ruby: { - method: 'accounts.origins.get', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\norigin_response = image_kit.accounts.origins.get("id")\n\nputs(origin_response)', - }, - cli: { - method: 'origins get', - example: - "imagekit accounts:origins get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - php: { - method: 'accounts->origins->get', - example: - "accounts->origins->get('id');\n\nvar_dump($originResponse);", - }, - csharp: { - method: 'Accounts.Origins.Get', - example: - 'OriginGetParams parameters = new() { ID = "id" };\n\nvar originResponse = await client.Accounts.Origins.Get(parameters);\n\nConsole.WriteLine(originResponse);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "get", + "endpoint": "/v1/accounts/origins/{id}", + "httpMethod": "get", + "summary": "Get origin", + "description": "**Note:** This API is currently in beta. \nRetrieves the origin identified by `id`.\n", + "stainlessPath": "(resource) accounts.origins > (method) get", + "qualified": "client.accounts.origins.get", + "params": [ + "id: string;" + ], + "response": "object | object | object | object | object | object | object | object", + "markdown": "## get\n\n`client.accounts.origins.get(id: string): { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }`\n\n**get** `/v1/accounts/origins/{id}`\n\n**Note:** This API is currently in beta. \nRetrieves the origin identified by `id`.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the origin. This is generated by ImageKit when you create a new origin.\n\n### Returns\n\n- `{ id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }`\n Origin object as returned by the API (sensitive fields removed).\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst originResponse = await client.accounts.origins.get('id');\n\nconsole.log(originResponse);\n```", + "perLanguage": { + "typescript": { + "method": "client.accounts.origins.get", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.get('id');\n\nconsole.log(originResponse);" + }, + "python": { + "method": "accounts.origins.get", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.get(\n \"id\",\n)\nprint(origin_response)" + }, + "java": { + "method": "accounts().origins().get", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginGetParams;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginResponse originResponse = client.accounts().origins().get(\"id\");\n }\n}" + }, + "kotlin": { + "method": "accounts().origins().get", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginGetParams\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val originResponse: OriginResponse = client.accounts().origins().get(\"id\")\n}" + }, + "go": { + "method": "client.Accounts.Origins.Get", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.Get(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", originResponse)\n}\n" + }, + "ruby": { + "method": "accounts.origins.get", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\norigin_response = image_kit.accounts.origins.get(\"id\")\n\nputs(origin_response)" + }, + "cli": { + "method": "origins get", + "example": "imagekit accounts:origins get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" + }, + "php": { + "method": "accounts->origins->get", + "example": "accounts->origins->get('id');\n\nvar_dump($originResponse);" + }, + "csharp": { + "method": "Accounts.Origins.Get", + "example": "OriginGetParams parameters = new() { ID = \"id\" };\n\nvar originResponse = await client.Accounts.Origins.Get(parameters);\n\nConsole.WriteLine(originResponse);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'update', - endpoint: '/v1/accounts/origins/{id}', - httpMethod: 'put', - summary: 'Update origin', - description: - '**Note:** This API is currently in beta. \nUpdates the origin identified by `id` and returns the updated origin object.\n', - stainlessPath: '(resource) accounts.origins > (method) update', - qualified: 'client.accounts.origins.update', - params: [ - 'id: string;', - "OriginRequest: { accessKey: string; bucket: string; name: string; secretKey: string; type: 'S3'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accessKey: string; bucket: string; endpoint: string; name: string; secretKey: string; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; s3ForcePathStyle?: boolean; } | { accessKey: string; bucket: string; name: string; secretKey: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; forwardHostHeaderToOrigin?: boolean; includeCanonicalHeader?: boolean; } | { name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; } | { bucket: string; clientEmail: string; name: string; privateKey: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accountName: string; container: string; name: string; sasToken: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; clientId: string; clientSecret: string; name: string; password: string; type: 'AKENEO_PIM'; username: string; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; };", + "name": "update", + "endpoint": "/v1/accounts/origins/{id}", + "httpMethod": "put", + "summary": "Update origin", + "description": "**Note:** This API is currently in beta. \nUpdates the origin identified by `id` and returns the updated origin object.\n", + "stainlessPath": "(resource) accounts.origins > (method) update", + "qualified": "client.accounts.origins.update", + "params": [ + "id: string;", + "OriginRequest: { accessKey: string; bucket: string; name: string; secretKey: string; type: 'S3'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accessKey: string; bucket: string; endpoint: string; name: string; secretKey: string; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; s3ForcePathStyle?: boolean; } | { accessKey: string; bucket: string; name: string; secretKey: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; forwardHostHeaderToOrigin?: boolean; includeCanonicalHeader?: boolean; } | { name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; } | { bucket: string; clientEmail: string; name: string; privateKey: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accountName: string; container: string; name: string; sasToken: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; clientId: string; clientSecret: string; name: string; password: string; type: 'AKENEO_PIM'; username: string; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; };" ], - response: 'object | object | object | object | object | object | object | object', - perLanguage: { - typescript: { - method: 'client.accounts.origins.update', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.update('id', {\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'product-images',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'S3',\n});\n\nconsole.log(originResponse);", - }, - python: { - method: 'accounts.origins.update', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.update(\n id="id",\n access_key="AKIAIOSFODNN7EXAMPLE",\n bucket="product-images",\n name="US S3 Storage",\n secret_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n type="S3",\n)\nprint(origin_response)', - }, - java: { - method: 'accounts().origins().update', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginRequest;\nimport io.imagekit.models.accounts.origins.OriginResponse;\nimport io.imagekit.models.accounts.origins.OriginUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginUpdateParams params = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build();\n OriginResponse originResponse = client.accounts().origins().update(params);\n }\n}', - }, - kotlin: { - method: 'accounts().origins().update', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\nimport com.imagekit.api.models.accounts.origins.OriginUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginUpdateParams = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build()\n val originResponse: OriginResponse = client.accounts().origins().update(params)\n}', - }, - go: { - method: 'client.Accounts.Origins.Update', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.AccountOriginUpdateParams{\n\t\t\tOriginRequest: imagekit.OriginRequestUnionParam{\n\t\t\t\tOfS3: &imagekit.OriginRequestS3Param{\n\t\t\t\t\tAccessKey: "AKIATEST123",\n\t\t\t\t\tBucket: "test-bucket",\n\t\t\t\t\tName: "My S3 Origin",\n\t\t\t\t\tSecretKey: "secrettest123",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponse)\n}\n', - }, - ruby: { - method: 'accounts.origins.update', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\norigin_response = image_kit.accounts.origins.update(\n "id",\n origin_request: {accessKey: "AKIATEST123", bucket: "test-bucket", name: "My S3 Origin", secretKey: "secrettest123", type: :S3}\n)\n\nputs(origin_response)', - }, - cli: { - method: 'origins update', - example: - "imagekit accounts:origins update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id \\\n --access-key AKIAIOSFODNN7EXAMPLE \\\n --bucket product-images \\\n --name 'US S3 Storage' \\\n --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \\\n --type S3 \\\n --endpoint https://s3.eu-central-1.wasabisys.com \\\n --base-url https://images.example.com/assets \\\n --client-email service-account@project.iam.gserviceaccount.com \\\n --private-key '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...' \\\n --account-name account123 \\\n --container images \\\n --sas-token '?sv=2023-01-03&sr=c&sig=abc123' \\\n --client-id akeneo-client-id \\\n --client-secret akeneo-client-secret \\\n --password strongpassword123 \\\n --username integration-user", - }, - php: { - method: 'accounts->origins->update', - example: - "accounts->origins->update(\n 'id',\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'gcs-media',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'AKENEO_PIM',\n baseURLForCanonicalHeader: 'https://cdn.example.com',\n includeCanonicalHeader: false,\n prefix: 'uploads',\n endpoint: 'https://s3.eu-central-1.wasabisys.com',\n s3ForcePathStyle: true,\n baseURL: 'https://akeneo.company.com',\n forwardHostHeaderToOrigin: false,\n clientEmail: 'service-account@project.iam.gserviceaccount.com',\n privateKey: '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...',\n accountName: 'account123',\n container: 'images',\n sasToken: '?sv=2023-01-03&sr=c&sig=abc123',\n clientID: 'akeneo-client-id',\n clientSecret: 'akeneo-client-secret',\n password: 'strongpassword123',\n username: 'integration-user',\n);\n\nvar_dump($originResponse);", - }, - csharp: { - method: 'Accounts.Origins.Update', - example: - 'OriginUpdateParams parameters = new()\n{\n ID = "id",\n OriginRequest = new S3()\n {\n AccessKey = "AKIATEST123",\n Bucket = "test-bucket",\n Name = "My S3 Origin",\n SecretKey = "secrettest123",\n BaseUrlForCanonicalHeader = "https://cdn.example.com",\n IncludeCanonicalHeader = false,\n Prefix = "images",\n },\n};\n\nvar originResponse = await client.Accounts.Origins.Update(parameters);\n\nConsole.WriteLine(originResponse);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "accessKey": "AKIAIOSFODNN7EXAMPLE",\n "bucket": "product-images",\n "name": "US S3 Storage",\n "secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n "type": "S3",\n "baseUrlForCanonicalHeader": "https://cdn.example.com",\n "prefix": "raw-assets"\n }\'', - }, - }, + "response": "object | object | object | object | object | object | object | object", + "perLanguage": { + "typescript": { + "method": "client.accounts.origins.update", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.update('id', {\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'product-images',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'S3',\n});\n\nconsole.log(originResponse);" + }, + "python": { + "method": "accounts.origins.update", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.update(\n id=\"id\",\n access_key=\"AKIAIOSFODNN7EXAMPLE\",\n bucket=\"product-images\",\n name=\"US S3 Storage\",\n secret_key=\"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n type=\"S3\",\n)\nprint(origin_response)" + }, + "java": { + "method": "accounts().origins().update", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginRequest;\nimport io.imagekit.models.accounts.origins.OriginResponse;\nimport io.imagekit.models.accounts.origins.OriginUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginUpdateParams params = OriginUpdateParams.builder()\n .id(\"id\")\n .originRequest(OriginRequest.S3.builder()\n .accessKey(\"AKIATEST123\")\n .bucket(\"test-bucket\")\n .name(\"My S3 Origin\")\n .secretKey(\"secrettest123\")\n .build())\n .build();\n OriginResponse originResponse = client.accounts().origins().update(params);\n }\n}" + }, + "kotlin": { + "method": "accounts().origins().update", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\nimport com.imagekit.api.models.accounts.origins.OriginUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginUpdateParams = OriginUpdateParams.builder()\n .id(\"id\")\n .originRequest(OriginRequest.S3.builder()\n .accessKey(\"AKIATEST123\")\n .bucket(\"test-bucket\")\n .name(\"My S3 Origin\")\n .secretKey(\"secrettest123\")\n .build())\n .build()\n val originResponse: OriginResponse = client.accounts().origins().update(params)\n}" + }, + "go": { + "method": "client.Accounts.Origins.Update", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.Update(\n\t\tcontext.TODO(),\n\t\t\"id\",\n\t\timagekit.AccountOriginUpdateParams{\n\t\t\tOriginRequest: imagekit.OriginRequestUnionParam{\n\t\t\t\tOfS3: &imagekit.OriginRequestS3Param{\n\t\t\t\t\tAccessKey: \"AKIATEST123\",\n\t\t\t\t\tBucket: \"test-bucket\",\n\t\t\t\t\tName: \"My S3 Origin\",\n\t\t\t\t\tSecretKey: \"secrettest123\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", originResponse)\n}\n" + }, + "ruby": { + "method": "accounts.origins.update", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\norigin_response = image_kit.accounts.origins.update(\n \"id\",\n origin_request: {accessKey: \"AKIATEST123\", bucket: \"test-bucket\", name: \"My S3 Origin\", secretKey: \"secrettest123\", type: :S3}\n)\n\nputs(origin_response)" + }, + "cli": { + "method": "origins update", + "example": "imagekit accounts:origins update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id \\\n --access-key AKIAIOSFODNN7EXAMPLE \\\n --bucket product-images \\\n --name 'US S3 Storage' \\\n --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \\\n --type S3 \\\n --endpoint https://s3.eu-central-1.wasabisys.com \\\n --base-url https://images.example.com/assets \\\n --client-email service-account@project.iam.gserviceaccount.com \\\n --private-key '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...' \\\n --account-name account123 \\\n --container images \\\n --sas-token '?sv=2023-01-03&sr=c&sig=abc123' \\\n --client-id akeneo-client-id \\\n --client-secret akeneo-client-secret \\\n --password strongpassword123 \\\n --username integration-user" + }, + "php": { + "method": "accounts->origins->update", + "example": "accounts->origins->update(\n 'id',\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'gcs-media',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'AKENEO_PIM',\n baseURLForCanonicalHeader: 'https://cdn.example.com',\n includeCanonicalHeader: false,\n prefix: 'uploads',\n endpoint: 'https://s3.eu-central-1.wasabisys.com',\n s3ForcePathStyle: true,\n baseURL: 'https://akeneo.company.com',\n forwardHostHeaderToOrigin: false,\n clientEmail: 'service-account@project.iam.gserviceaccount.com',\n privateKey: '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...',\n accountName: 'account123',\n container: 'images',\n sasToken: '?sv=2023-01-03&sr=c&sig=abc123',\n clientID: 'akeneo-client-id',\n clientSecret: 'akeneo-client-secret',\n password: 'strongpassword123',\n username: 'integration-user',\n);\n\nvar_dump($originResponse);" + }, + "csharp": { + "method": "Accounts.Origins.Update", + "example": "OriginUpdateParams parameters = new()\n{\n ID = \"id\",\n OriginRequest = new S3()\n {\n AccessKey = \"AKIATEST123\",\n Bucket = \"test-bucket\",\n Name = \"My S3 Origin\",\n SecretKey = \"secrettest123\",\n BaseUrlForCanonicalHeader = \"https://cdn.example.com\",\n IncludeCanonicalHeader = false,\n Prefix = \"images\",\n },\n};\n\nvar originResponse = await client.Accounts.Origins.Update(parameters);\n\nConsole.WriteLine(originResponse);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X PUT \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"accessKey\": \"AKIAIOSFODNN7EXAMPLE\",\n \"bucket\": \"product-images\",\n \"name\": \"US S3 Storage\",\n \"secretKey\": \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n \"type\": \"S3\",\n \"baseUrlForCanonicalHeader\": \"https://cdn.example.com\",\n \"prefix\": \"raw-assets\"\n }'" + } + } }, { - name: 'delete', - endpoint: '/v1/accounts/origins/{id}', - httpMethod: 'delete', - summary: 'Delete origin', - description: - '**Note:** This API is currently in beta. \nPermanently removes the origin identified by `id`. If the origin is in use by any URL‑endpoints, the API will return an error.\n', - stainlessPath: '(resource) accounts.origins > (method) delete', - qualified: 'client.accounts.origins.delete', - params: ['id: string;'], - markdown: - "## delete\n\n`client.accounts.origins.delete(id: string): void`\n\n**delete** `/v1/accounts/origins/{id}`\n\n**Note:** This API is currently in beta. \nPermanently removes the origin identified by `id`. If the origin is in use by any URL‑endpoints, the API will return an error.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the origin. This is generated by ImageKit when you create a new origin.\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.accounts.origins.delete('id')\n```", - perLanguage: { - typescript: { - method: 'client.accounts.origins.delete', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.accounts.origins.delete('id');", - }, - python: { - method: 'accounts.origins.delete', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.accounts.origins.delete(\n "id",\n)', - }, - java: { - method: 'accounts().origins().delete', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().origins().delete("id");\n }\n}', - }, - kotlin: { - method: 'accounts().origins().delete', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.accounts().origins().delete("id")\n}', - }, - go: { - method: 'client.Accounts.Origins.Delete', - example: - 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Accounts.Origins.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', - }, - ruby: { - method: 'accounts.origins.delete', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.accounts.origins.delete("id")\n\nputs(result)', - }, - cli: { - method: 'origins delete', - example: - "imagekit accounts:origins delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - php: { - method: 'accounts->origins->delete', - example: - "accounts->origins->delete('id');\n\nvar_dump($result);", - }, - csharp: { - method: 'Accounts.Origins.Delete', - example: - 'OriginDeleteParams parameters = new() { ID = "id" };\n\nawait client.Accounts.Origins.Delete(parameters);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "delete", + "endpoint": "/v1/accounts/origins/{id}", + "httpMethod": "delete", + "summary": "Delete origin", + "description": "**Note:** This API is currently in beta. \nPermanently removes the origin identified by `id`. If the origin is in use by any URL‑endpoints, the API will return an error.\n", + "stainlessPath": "(resource) accounts.origins > (method) delete", + "qualified": "client.accounts.origins.delete", + "params": [ + "id: string;" + ], + "markdown": "## delete\n\n`client.accounts.origins.delete(id: string): void`\n\n**delete** `/v1/accounts/origins/{id}`\n\n**Note:** This API is currently in beta. \nPermanently removes the origin identified by `id`. If the origin is in use by any URL‑endpoints, the API will return an error.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the origin. This is generated by ImageKit when you create a new origin.\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.accounts.origins.delete('id')\n```", + "perLanguage": { + "typescript": { + "method": "client.accounts.origins.delete", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.accounts.origins.delete('id');" + }, + "python": { + "method": "accounts.origins.delete", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nclient.accounts.origins.delete(\n \"id\",\n)" + }, + "java": { + "method": "accounts().origins().delete", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().origins().delete(\"id\");\n }\n}" + }, + "kotlin": { + "method": "accounts().origins().delete", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.accounts().origins().delete(\"id\")\n}" + }, + "go": { + "method": "client.Accounts.Origins.Delete", + "example": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\terr := client.Accounts.Origins.Delete(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n" + }, + "ruby": { + "method": "accounts.origins.delete", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresult = image_kit.accounts.origins.delete(\"id\")\n\nputs(result)" + }, + "cli": { + "method": "origins delete", + "example": "imagekit accounts:origins delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" + }, + "php": { + "method": "accounts->origins->delete", + "example": "accounts->origins->delete('id');\n\nvar_dump($result);" + }, + "csharp": { + "method": "Accounts.Origins.Delete", + "example": "OriginDeleteParams parameters = new() { ID = \"id\" };\n\nawait client.Accounts.Origins.Delete(parameters);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'list', - endpoint: '/v1/accounts/url-endpoints', - httpMethod: 'get', - summary: 'List URL‑endpoints', - description: - '**Note:** This API is currently in beta. \nReturns an array of all URL‑endpoints configured including the default URL-endpoint generated by ImageKit during account creation.\n', - stainlessPath: '(resource) accounts.urlEndpoints > (method) list', - qualified: 'client.accounts.urlEndpoints.list', - response: - "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }[]", - markdown: - "## list\n\n`client.accounts.urlEndpoints.list(): object[]`\n\n**get** `/v1/accounts/url-endpoints`\n\n**Note:** This API is currently in beta. \nReturns an array of all URL‑endpoints configured including the default URL-endpoint generated by ImageKit during account creation.\n\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponses = await client.accounts.urlEndpoints.list();\n\nconsole.log(urlEndpointResponses);\n```", - perLanguage: { - typescript: { - method: 'client.accounts.urlEndpoints.list', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponses = await client.accounts.urlEndpoints.list();\n\nconsole.log(urlEndpointResponses);", - }, - python: { - method: 'accounts.url_endpoints.list', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_responses = client.accounts.url_endpoints.list()\nprint(url_endpoint_responses)', - }, - java: { - method: 'accounts().urlEndpoints().list', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointListParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List urlEndpointResponses = client.accounts().urlEndpoints().list();\n }\n}', - }, - kotlin: { - method: 'accounts().urlEndpoints().list', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val urlEndpointResponses: List = client.accounts().urlEndpoints().list()\n}', - }, - go: { - method: 'client.Accounts.URLEndpoints.List', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponses, err := client.Accounts.URLEndpoints.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponses)\n}\n', - }, - ruby: { - method: 'accounts.url_endpoints.list', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nurl_endpoint_responses = image_kit.accounts.url_endpoints.list\n\nputs(url_endpoint_responses)', - }, - cli: { - method: 'urlEndpoints list', - example: - "imagekit accounts:url-endpoints list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - php: { - method: 'accounts->urlEndpoints->list', - example: - "accounts->urlEndpoints->list();\n\nvar_dump($urlEndpointResponses);", - }, - csharp: { - method: 'Accounts.UrlEndpoints.List', - example: - 'UrlEndpointListParams parameters = new();\n\nvar urlEndpointResponses = await client.Accounts.UrlEndpoints.List(parameters);\n\nConsole.WriteLine(urlEndpointResponses);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/accounts/url-endpoints \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "list", + "endpoint": "/v1/accounts/url-endpoints", + "httpMethod": "get", + "summary": "List URL‑endpoints", + "description": "**Note:** This API is currently in beta. \nReturns an array of all URL‑endpoints configured including the default URL-endpoint generated by ImageKit during account creation.\n", + "stainlessPath": "(resource) accounts.urlEndpoints > (method) list", + "qualified": "client.accounts.urlEndpoints.list", + "response": "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }[]", + "markdown": "## list\n\n`client.accounts.urlEndpoints.list(): object[]`\n\n**get** `/v1/accounts/url-endpoints`\n\n**Note:** This API is currently in beta. \nReturns an array of all URL‑endpoints configured including the default URL-endpoint generated by ImageKit during account creation.\n\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponses = await client.accounts.urlEndpoints.list();\n\nconsole.log(urlEndpointResponses);\n```", + "perLanguage": { + "typescript": { + "method": "client.accounts.urlEndpoints.list", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponses = await client.accounts.urlEndpoints.list();\n\nconsole.log(urlEndpointResponses);" + }, + "python": { + "method": "accounts.url_endpoints.list", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nurl_endpoint_responses = client.accounts.url_endpoints.list()\nprint(url_endpoint_responses)" + }, + "java": { + "method": "accounts().urlEndpoints().list", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointListParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List urlEndpointResponses = client.accounts().urlEndpoints().list();\n }\n}" + }, + "kotlin": { + "method": "accounts().urlEndpoints().list", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val urlEndpointResponses: List = client.accounts().urlEndpoints().list()\n}" + }, + "go": { + "method": "client.Accounts.URLEndpoints.List", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\turlEndpointResponses, err := client.Accounts.URLEndpoints.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", urlEndpointResponses)\n}\n" + }, + "ruby": { + "method": "accounts.url_endpoints.list", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nurl_endpoint_responses = image_kit.accounts.url_endpoints.list\n\nputs(url_endpoint_responses)" + }, + "cli": { + "method": "urlEndpoints list", + "example": "imagekit accounts:url-endpoints list \\\n --private-key 'My Private Key' \\\n --password 'My Password'" + }, + "php": { + "method": "accounts->urlEndpoints->list", + "example": "accounts->urlEndpoints->list();\n\nvar_dump($urlEndpointResponses);" + }, + "csharp": { + "method": "Accounts.UrlEndpoints.List", + "example": "UrlEndpointListParams parameters = new();\n\nvar urlEndpointResponses = await client.Accounts.UrlEndpoints.List(parameters);\n\nConsole.WriteLine(urlEndpointResponses);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/accounts/url-endpoints \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'create', - endpoint: '/v1/accounts/url-endpoints', - httpMethod: 'post', - summary: 'Create URL‑endpoint', - description: - '**Note:** This API is currently in beta. \nCreates a new URL‑endpoint and returns the resulting object.\n', - stainlessPath: '(resource) accounts.urlEndpoints > (method) create', - qualified: 'client.accounts.urlEndpoints.create', - params: [ - 'description: string;', - 'origins?: string[];', - 'urlPrefix?: string;', - "urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; };", + "name": "create", + "endpoint": "/v1/accounts/url-endpoints", + "httpMethod": "post", + "summary": "Create URL‑endpoint", + "description": "**Note:** This API is currently in beta. \nCreates a new URL‑endpoint and returns the resulting object.\n", + "stainlessPath": "(resource) accounts.urlEndpoints > (method) create", + "qualified": "client.accounts.urlEndpoints.create", + "params": [ + "description: string;", + "origins?: string[];", + "urlPrefix?: string;", + "urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; };" ], - response: - "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }", - markdown: - "## create\n\n`client.accounts.urlEndpoints.create(description: string, origins?: string[], urlPrefix?: string, urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**post** `/v1/accounts/url-endpoints`\n\n**Note:** This API is currently in beta. \nCreates a new URL‑endpoint and returns the resulting object.\n\n\n### Parameters\n\n- `description: string`\n Description of the URL endpoint.\n\n- `origins?: string[]`\n Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint.\n\n- `urlPrefix?: string`\n Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint).\n\n- `urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n Configuration for third-party URL rewriting.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.create({ description: 'My custom URL endpoint' });\n\nconsole.log(urlEndpointResponse);\n```", - perLanguage: { - typescript: { - method: 'client.accounts.urlEndpoints.create', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.create({\n description: 'My custom URL endpoint',\n});\n\nconsole.log(urlEndpointResponse.id);", - }, - python: { - method: 'accounts.url_endpoints.create', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.create(\n description="My custom URL endpoint",\n)\nprint(url_endpoint_response.id)', - }, - java: { - method: 'accounts().urlEndpoints().create', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}', - }, - kotlin: { - method: 'accounts().urlEndpoints().create', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointRequest = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().create(params)\n}', - }, - go: { - method: 'client.Accounts.URLEndpoints.New', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.New(context.TODO(), imagekit.AccountURLEndpointNewParams{\n\t\tURLEndpointRequest: imagekit.URLEndpointRequestParam{\n\t\t\tDescription: "My custom URL endpoint",\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponse.ID)\n}\n', - }, - ruby: { - method: 'accounts.url_endpoints.create', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.create(description: "My custom URL endpoint")\n\nputs(url_endpoint_response)', - }, - cli: { - method: 'urlEndpoints create', - example: - "imagekit accounts:url-endpoints create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --description 'My custom URL endpoint'", - }, - php: { - method: 'accounts->urlEndpoints->create', - example: - "accounts->urlEndpoints->create(\n description: 'My custom URL endpoint',\n origins: ['origin-id-1'],\n urlPrefix: 'product-images',\n urlRewriter: ['type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true],\n);\n\nvar_dump($urlEndpointResponse);", - }, - csharp: { - method: 'Accounts.UrlEndpoints.Create', - example: - 'UrlEndpointCreateParams parameters = new()\n{\n Description = "My custom URL endpoint"\n};\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Create(parameters);\n\nConsole.WriteLine(urlEndpointResponse);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/accounts/url-endpoints \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "description": "My custom URL endpoint",\n "origins": [\n "origin-id-1"\n ],\n "urlPrefix": "product-images"\n }\'', - }, - }, + "response": "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }", + "markdown": "## create\n\n`client.accounts.urlEndpoints.create(description: string, origins?: string[], urlPrefix?: string, urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**post** `/v1/accounts/url-endpoints`\n\n**Note:** This API is currently in beta. \nCreates a new URL‑endpoint and returns the resulting object.\n\n\n### Parameters\n\n- `description: string`\n Description of the URL endpoint.\n\n- `origins?: string[]`\n Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint.\n\n- `urlPrefix?: string`\n Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint).\n\n- `urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n Configuration for third-party URL rewriting.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.create({ description: 'My custom URL endpoint' });\n\nconsole.log(urlEndpointResponse);\n```", + "perLanguage": { + "typescript": { + "method": "client.accounts.urlEndpoints.create", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.create({\n description: 'My custom URL endpoint',\n});\n\nconsole.log(urlEndpointResponse.id);" + }, + "python": { + "method": "accounts.url_endpoints.create", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.create(\n description=\"My custom URL endpoint\",\n)\nprint(url_endpoint_response.id)" + }, + "java": { + "method": "accounts().urlEndpoints().create", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description(\"My custom URL endpoint\")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}" + }, + "kotlin": { + "method": "accounts().urlEndpoints().create", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointRequest = UrlEndpointRequest.builder()\n .description(\"My custom URL endpoint\")\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().create(params)\n}" + }, + "go": { + "method": "client.Accounts.URLEndpoints.New", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.New(context.TODO(), imagekit.AccountURLEndpointNewParams{\n\t\tURLEndpointRequest: imagekit.URLEndpointRequestParam{\n\t\t\tDescription: \"My custom URL endpoint\",\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", urlEndpointResponse.ID)\n}\n" + }, + "ruby": { + "method": "accounts.url_endpoints.create", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.create(description: \"My custom URL endpoint\")\n\nputs(url_endpoint_response)" + }, + "cli": { + "method": "urlEndpoints create", + "example": "imagekit accounts:url-endpoints create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --description 'My custom URL endpoint'" + }, + "php": { + "method": "accounts->urlEndpoints->create", + "example": "accounts->urlEndpoints->create(\n description: 'My custom URL endpoint',\n origins: ['origin-id-1'],\n urlPrefix: 'product-images',\n urlRewriter: ['type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true],\n);\n\nvar_dump($urlEndpointResponse);" + }, + "csharp": { + "method": "Accounts.UrlEndpoints.Create", + "example": "UrlEndpointCreateParams parameters = new()\n{\n Description = \"My custom URL endpoint\"\n};\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Create(parameters);\n\nConsole.WriteLine(urlEndpointResponse);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/accounts/url-endpoints \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"description\": \"My custom URL endpoint\",\n \"origins\": [\n \"origin-id-1\"\n ],\n \"urlPrefix\": \"product-images\"\n }'" + } + } }, { - name: 'get', - endpoint: '/v1/accounts/url-endpoints/{id}', - httpMethod: 'get', - summary: 'Get URL‑endpoint', - description: - '**Note:** This API is currently in beta. \nRetrieves the URL‑endpoint identified by `id`.\n', - stainlessPath: '(resource) accounts.urlEndpoints > (method) get', - qualified: 'client.accounts.urlEndpoints.get', - params: ['id: string;'], - response: - "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }", - markdown: - "## get\n\n`client.accounts.urlEndpoints.get(id: string): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**get** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nRetrieves the URL‑endpoint identified by `id`.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.get('id');\n\nconsole.log(urlEndpointResponse);\n```", - perLanguage: { - typescript: { - method: 'client.accounts.urlEndpoints.get', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.get('id');\n\nconsole.log(urlEndpointResponse.id);", - }, - python: { - method: 'accounts.url_endpoints.get', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.get(\n "id",\n)\nprint(url_endpoint_response.id)', - }, - java: { - method: 'accounts().urlEndpoints().get', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get("id");\n }\n}', - }, - kotlin: { - method: 'accounts().urlEndpoints().get', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().get("id")\n}', - }, - go: { - method: 'client.Accounts.URLEndpoints.Get', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.Get(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponse.ID)\n}\n', - }, - ruby: { - method: 'accounts.url_endpoints.get', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.get("id")\n\nputs(url_endpoint_response)', - }, - cli: { - method: 'urlEndpoints get', - example: - "imagekit accounts:url-endpoints get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - php: { - method: 'accounts->urlEndpoints->get', - example: - "accounts->urlEndpoints->get('id');\n\nvar_dump($urlEndpointResponse);", - }, - csharp: { - method: 'Accounts.UrlEndpoints.Get', - example: - 'UrlEndpointGetParams parameters = new() { ID = "id" };\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Get(parameters);\n\nConsole.WriteLine(urlEndpointResponse);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "get", + "endpoint": "/v1/accounts/url-endpoints/{id}", + "httpMethod": "get", + "summary": "Get URL‑endpoint", + "description": "**Note:** This API is currently in beta. \nRetrieves the URL‑endpoint identified by `id`.\n", + "stainlessPath": "(resource) accounts.urlEndpoints > (method) get", + "qualified": "client.accounts.urlEndpoints.get", + "params": [ + "id: string;" + ], + "response": "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }", + "markdown": "## get\n\n`client.accounts.urlEndpoints.get(id: string): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**get** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nRetrieves the URL‑endpoint identified by `id`.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.get('id');\n\nconsole.log(urlEndpointResponse);\n```", + "perLanguage": { + "typescript": { + "method": "client.accounts.urlEndpoints.get", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.get('id');\n\nconsole.log(urlEndpointResponse.id);" + }, + "python": { + "method": "accounts.url_endpoints.get", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.get(\n \"id\",\n)\nprint(url_endpoint_response.id)" + }, + "java": { + "method": "accounts().urlEndpoints().get", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get(\"id\");\n }\n}" + }, + "kotlin": { + "method": "accounts().urlEndpoints().get", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().get(\"id\")\n}" + }, + "go": { + "method": "client.Accounts.URLEndpoints.Get", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.Get(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", urlEndpointResponse.ID)\n}\n" + }, + "ruby": { + "method": "accounts.url_endpoints.get", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.get(\"id\")\n\nputs(url_endpoint_response)" + }, + "cli": { + "method": "urlEndpoints get", + "example": "imagekit accounts:url-endpoints get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" + }, + "php": { + "method": "accounts->urlEndpoints->get", + "example": "accounts->urlEndpoints->get('id');\n\nvar_dump($urlEndpointResponse);" + }, + "csharp": { + "method": "Accounts.UrlEndpoints.Get", + "example": "UrlEndpointGetParams parameters = new() { ID = \"id\" };\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Get(parameters);\n\nConsole.WriteLine(urlEndpointResponse);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'update', - endpoint: '/v1/accounts/url-endpoints/{id}', - httpMethod: 'put', - summary: 'Update URL‑endpoint', - description: - '**Note:** This API is currently in beta. \nUpdates the URL‑endpoint identified by `id` and returns the updated object.\n', - stainlessPath: '(resource) accounts.urlEndpoints > (method) update', - qualified: 'client.accounts.urlEndpoints.update', - params: [ - 'id: string;', - 'description: string;', - 'origins?: string[];', - 'urlPrefix?: string;', - "urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; };", + "name": "update", + "endpoint": "/v1/accounts/url-endpoints/{id}", + "httpMethod": "put", + "summary": "Update URL‑endpoint", + "description": "**Note:** This API is currently in beta. \nUpdates the URL‑endpoint identified by `id` and returns the updated object.\n", + "stainlessPath": "(resource) accounts.urlEndpoints > (method) update", + "qualified": "client.accounts.urlEndpoints.update", + "params": [ + "id: string;", + "description: string;", + "origins?: string[];", + "urlPrefix?: string;", + "urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; };" ], - response: - "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }", - markdown: - "## update\n\n`client.accounts.urlEndpoints.update(id: string, description: string, origins?: string[], urlPrefix?: string, urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**put** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nUpdates the URL‑endpoint identified by `id` and returns the updated object.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n- `description: string`\n Description of the URL endpoint.\n\n- `origins?: string[]`\n Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint.\n\n- `urlPrefix?: string`\n Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint).\n\n- `urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n Configuration for third-party URL rewriting.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.update('id', { description: 'My custom URL endpoint' });\n\nconsole.log(urlEndpointResponse);\n```", - perLanguage: { - typescript: { - method: 'client.accounts.urlEndpoints.update', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.update('id', {\n description: 'My custom URL endpoint',\n});\n\nconsole.log(urlEndpointResponse.id);", - }, - python: { - method: 'accounts.url_endpoints.update', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.update(\n id="id",\n description="My custom URL endpoint",\n)\nprint(url_endpoint_response.id)', - }, - java: { - method: 'accounts().urlEndpoints().update', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointUpdateParams params = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().update(params);\n }\n}', - }, - kotlin: { - method: 'accounts().urlEndpoints().update', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointUpdateParams = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().update(params)\n}', - }, - go: { - method: 'client.Accounts.URLEndpoints.Update', - example: - 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.AccountURLEndpointUpdateParams{\n\t\t\tURLEndpointRequest: imagekit.URLEndpointRequestParam{\n\t\t\t\tDescription: "My custom URL endpoint",\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponse.ID)\n}\n', - }, - ruby: { - method: 'accounts.url_endpoints.update', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.update("id", description: "My custom URL endpoint")\n\nputs(url_endpoint_response)', - }, - cli: { - method: 'urlEndpoints update', - example: - "imagekit accounts:url-endpoints update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id \\\n --description 'My custom URL endpoint'", - }, - php: { - method: 'accounts->urlEndpoints->update', - example: - "accounts->urlEndpoints->update(\n 'id',\n description: 'My custom URL endpoint',\n origins: ['origin-id-1'],\n urlPrefix: 'product-images',\n urlRewriter: ['type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true],\n);\n\nvar_dump($urlEndpointResponse);", - }, - csharp: { - method: 'Accounts.UrlEndpoints.Update', - example: - 'UrlEndpointUpdateParams parameters = new()\n{\n ID = "id",\n Description = "My custom URL endpoint",\n};\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Update(parameters);\n\nConsole.WriteLine(urlEndpointResponse);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "description": "My custom URL endpoint",\n "origins": [\n "origin-id-1"\n ],\n "urlPrefix": "product-images"\n }\'', - }, - }, + "response": "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }", + "markdown": "## update\n\n`client.accounts.urlEndpoints.update(id: string, description: string, origins?: string[], urlPrefix?: string, urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**put** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nUpdates the URL‑endpoint identified by `id` and returns the updated object.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n- `description: string`\n Description of the URL endpoint.\n\n- `origins?: string[]`\n Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint.\n\n- `urlPrefix?: string`\n Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint).\n\n- `urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n Configuration for third-party URL rewriting.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.update('id', { description: 'My custom URL endpoint' });\n\nconsole.log(urlEndpointResponse);\n```", + "perLanguage": { + "typescript": { + "method": "client.accounts.urlEndpoints.update", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.update('id', {\n description: 'My custom URL endpoint',\n});\n\nconsole.log(urlEndpointResponse.id);" + }, + "python": { + "method": "accounts.url_endpoints.update", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.update(\n id=\"id\",\n description=\"My custom URL endpoint\",\n)\nprint(url_endpoint_response.id)" + }, + "java": { + "method": "accounts().urlEndpoints().update", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointUpdateParams params = UrlEndpointUpdateParams.builder()\n .id(\"id\")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description(\"My custom URL endpoint\")\n .build())\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().update(params);\n }\n}" + }, + "kotlin": { + "method": "accounts().urlEndpoints().update", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointUpdateParams = UrlEndpointUpdateParams.builder()\n .id(\"id\")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description(\"My custom URL endpoint\")\n .build())\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().update(params)\n}" + }, + "go": { + "method": "client.Accounts.URLEndpoints.Update", + "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.Update(\n\t\tcontext.TODO(),\n\t\t\"id\",\n\t\timagekit.AccountURLEndpointUpdateParams{\n\t\t\tURLEndpointRequest: imagekit.URLEndpointRequestParam{\n\t\t\t\tDescription: \"My custom URL endpoint\",\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", urlEndpointResponse.ID)\n}\n" + }, + "ruby": { + "method": "accounts.url_endpoints.update", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.update(\"id\", description: \"My custom URL endpoint\")\n\nputs(url_endpoint_response)" + }, + "cli": { + "method": "urlEndpoints update", + "example": "imagekit accounts:url-endpoints update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id \\\n --description 'My custom URL endpoint'" + }, + "php": { + "method": "accounts->urlEndpoints->update", + "example": "accounts->urlEndpoints->update(\n 'id',\n description: 'My custom URL endpoint',\n origins: ['origin-id-1'],\n urlPrefix: 'product-images',\n urlRewriter: ['type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true],\n);\n\nvar_dump($urlEndpointResponse);" + }, + "csharp": { + "method": "Accounts.UrlEndpoints.Update", + "example": "UrlEndpointUpdateParams parameters = new()\n{\n ID = \"id\",\n Description = \"My custom URL endpoint\",\n};\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Update(parameters);\n\nConsole.WriteLine(urlEndpointResponse);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -X PUT \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"description\": \"My custom URL endpoint\",\n \"origins\": [\n \"origin-id-1\"\n ],\n \"urlPrefix\": \"product-images\"\n }'" + } + } }, { - name: 'delete', - endpoint: '/v1/accounts/url-endpoints/{id}', - httpMethod: 'delete', - summary: 'Delete URL‑endpoint', - description: - '**Note:** This API is currently in beta. \nDeletes the URL‑endpoint identified by `id`. You cannot delete the default URL‑endpoint created by ImageKit during account creation.\n', - stainlessPath: '(resource) accounts.urlEndpoints > (method) delete', - qualified: 'client.accounts.urlEndpoints.delete', - params: ['id: string;'], - markdown: - "## delete\n\n`client.accounts.urlEndpoints.delete(id: string): void`\n\n**delete** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nDeletes the URL‑endpoint identified by `id`. You cannot delete the default URL‑endpoint created by ImageKit during account creation.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.accounts.urlEndpoints.delete('id')\n```", - perLanguage: { - typescript: { - method: 'client.accounts.urlEndpoints.delete', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.accounts.urlEndpoints.delete('id');", - }, - python: { - method: 'accounts.url_endpoints.delete', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.accounts.url_endpoints.delete(\n "id",\n)', - }, - java: { - method: 'accounts().urlEndpoints().delete', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().urlEndpoints().delete("id");\n }\n}', - }, - kotlin: { - method: 'accounts().urlEndpoints().delete', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.accounts().urlEndpoints().delete("id")\n}', - }, - go: { - method: 'client.Accounts.URLEndpoints.Delete', - example: - 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Accounts.URLEndpoints.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', - }, - ruby: { - method: 'accounts.url_endpoints.delete', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.accounts.url_endpoints.delete("id")\n\nputs(result)', - }, - cli: { - method: 'urlEndpoints delete', - example: - "imagekit accounts:url-endpoints delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", - }, - php: { - method: 'accounts->urlEndpoints->delete', - example: - "accounts->urlEndpoints->delete('id');\n\nvar_dump($result);", - }, - csharp: { - method: 'Accounts.UrlEndpoints.Delete', - example: - 'UrlEndpointDeleteParams parameters = new() { ID = "id" };\n\nawait client.Accounts.UrlEndpoints.Delete(parameters);', - }, - http: { - example: - 'curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', - }, - }, + "name": "delete", + "endpoint": "/v1/accounts/url-endpoints/{id}", + "httpMethod": "delete", + "summary": "Delete URL‑endpoint", + "description": "**Note:** This API is currently in beta. \nDeletes the URL‑endpoint identified by `id`. You cannot delete the default URL‑endpoint created by ImageKit during account creation.\n", + "stainlessPath": "(resource) accounts.urlEndpoints > (method) delete", + "qualified": "client.accounts.urlEndpoints.delete", + "params": [ + "id: string;" + ], + "markdown": "## delete\n\n`client.accounts.urlEndpoints.delete(id: string): void`\n\n**delete** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nDeletes the URL‑endpoint identified by `id`. You cannot delete the default URL‑endpoint created by ImageKit during account creation.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.accounts.urlEndpoints.delete('id')\n```", + "perLanguage": { + "typescript": { + "method": "client.accounts.urlEndpoints.delete", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.accounts.urlEndpoints.delete('id');" + }, + "python": { + "method": "accounts.url_endpoints.delete", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nclient.accounts.url_endpoints.delete(\n \"id\",\n)" + }, + "java": { + "method": "accounts().urlEndpoints().delete", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().urlEndpoints().delete(\"id\");\n }\n}" + }, + "kotlin": { + "method": "accounts().urlEndpoints().delete", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.accounts().urlEndpoints().delete(\"id\")\n}" + }, + "go": { + "method": "client.Accounts.URLEndpoints.Delete", + "example": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\terr := client.Accounts.URLEndpoints.Delete(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n" + }, + "ruby": { + "method": "accounts.url_endpoints.delete", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresult = image_kit.accounts.url_endpoints.delete(\"id\")\n\nputs(result)" + }, + "cli": { + "method": "urlEndpoints delete", + "example": "imagekit accounts:url-endpoints delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" + }, + "php": { + "method": "accounts->urlEndpoints->delete", + "example": "accounts->urlEndpoints->delete('id');\n\nvar_dump($result);" + }, + "csharp": { + "method": "Accounts.UrlEndpoints.Delete", + "example": "UrlEndpointDeleteParams parameters = new() { ID = \"id\" };\n\nawait client.Accounts.UrlEndpoints.Delete(parameters);" + }, + "http": { + "example": "curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" + } + } }, { - name: 'upload', - endpoint: '/api/v2/files/upload', - httpMethod: 'post', - summary: 'Upload file V2', - description: - 'The V2 API enhances security by verifying the entire payload using JWT. This API is in beta.\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) about how to implement secure client-side file upload.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files, and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n', - stainlessPath: '(resource) beta.v2.files > (method) upload', - qualified: 'client.beta.v2.files.upload', - params: [ - 'file: string;', - 'fileName: string;', - 'token?: string;', - 'checks?: string;', - 'customCoordinates?: string;', - 'customMetadata?: object;', - 'description?: string;', + "name": "upload", + "endpoint": "/api/v2/files/upload", + "httpMethod": "post", + "summary": "Upload file V2", + "description": "The V2 API enhances security by verifying the entire payload using JWT. This API is in beta.\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) about how to implement secure client-side file upload.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files, and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n", + "stainlessPath": "(resource) beta.v2.files > (method) upload", + "qualified": "client.beta.v2.files.upload", + "params": [ + "file: string;", + "fileName: string;", + "token?: string;", + "checks?: string;", + "customCoordinates?: string;", + "customMetadata?: object;", + "description?: string;", "extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[];", - 'folder?: string;', - 'isPrivateFile?: boolean;', - 'isPublished?: boolean;', - 'overwriteAITags?: boolean;', - 'overwriteCustomMetadata?: boolean;', - 'overwriteFile?: boolean;', - 'overwriteTags?: boolean;', - 'responseFields?: string[];', - 'tags?: string[];', + "folder?: string;", + "isPrivateFile?: boolean;", + "isPublished?: boolean;", + "overwriteAITags?: boolean;", + "overwriteCustomMetadata?: boolean;", + "overwriteFile?: boolean;", + "overwriteTags?: boolean;", + "responseFields?: string[];", + "tags?: string[];", "transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; };", - 'useUniqueFileName?: boolean;', - 'webhookUrl?: string;', + "useUniqueFileName?: boolean;", + "webhookUrl?: string;" ], - response: - "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", - markdown: - "## upload\n\n`client.beta.v2.files.upload(file: string, fileName: string, token?: string, checks?: string, customCoordinates?: string, customMetadata?: object, description?: string, extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[], folder?: string, isPrivateFile?: boolean, isPublished?: boolean, overwriteAITags?: boolean, overwriteCustomMetadata?: boolean, overwriteFile?: boolean, overwriteTags?: boolean, responseFields?: string[], tags?: string[], transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }, useUniqueFileName?: boolean, webhookUrl?: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: object; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: metadata; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**post** `/api/v2/files/upload`\n\nThe V2 API enhances security by verifying the entire payload using JWT. This API is in beta.\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) about how to implement secure client-side file upload.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files, and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n\n\n### Parameters\n\n- `file: string`\n The API accepts any of the following:\n\n- **Binary data** – send the raw bytes as `multipart/form-data`.\n- **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.\n- **Base64 string** – the file encoded as a Base64 data URI or plain Base64.\n\nWhen supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.\n\n\n- `fileName: string`\n The name with which the file has to be uploaded.\n\n\n- `token?: string`\n This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses it to authenticate and check that the upload request parameters have not been tampered with after the token has been generated. Learn how to create the token on the page below. This field is only required for authentication when uploading a file from the client side.\n\n\n**Note**: Sending a JWT that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new token.\n\n\n**⚠️Warning**: JWT must be generated on the server-side because it is generated using your account's private API key. This field is required for authentication when uploading a file from the client-side.\n\n\n- `checks?: string`\n Server-side checks to run on the asset.\nRead more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks).\n\n\n- `customCoordinates?: string`\n Define an important area in the image. This is only relevant for image type files.\n\n - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100`\n - Can be used with fo-customtransformation.\n - If this field is not specified and the file is overwritten, then customCoordinates will be removed.\n\n\n- `customMetadata?: object`\n JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.\n\n\n- `description?: string`\n Optional text to describe the contents of the file.\n\n\n- `extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[]`\n Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.\n\n\n- `folder?: string`\n The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created. Using multiple `/` creates a nested folder.\n\n\n- `isPrivateFile?: boolean`\n Whether to mark the file as private or not.\n\nIf `true`, the file is marked as private and is accessible only using named transformation or signed URL.\n\n\n- `isPublished?: boolean`\n Whether to upload file as published or not.\n\nIf `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published.\n\nThe option to upload in draft state is only available in custom enterprise pricing plans.\n\n\n- `overwriteAITags?: boolean`\n If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags.\n\n\n- `overwriteCustomMetadata?: boolean`\n If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed.\n\n\n- `overwriteFile?: boolean`\n If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately.\n\n\n- `overwriteTags?: boolean`\n If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed.\n\n\n- `responseFields?: string[]`\n Array of response field keys to include in the API response body.\n\n\n- `tags?: string[]`\n Set the tags while uploading the file.\nProvide an array of tag strings (e.g. `[\"tag1\", \"tag2\", \"tag3\"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed.\nIf this field is not specified and the file is overwritten, the existing tags will be removed.\n\n\n- `transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }`\n Configure pre-processing (`pre`) and post-processing (`post`) transformations.\n\n- `pre` — applied before the file is uploaded to the Media Library. \n Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress).\n\n- `post` — applied immediately after upload. \n Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay.\n\nYou can mix and match any combination of post-processing types.\n\n - `post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]`\n List of transformations to apply *after* the file is uploaded. \nEach item must match one of the following types:\n`transformation`, `gif-to-video`, `thumbnail`, `abs`.\n\n - `pre?: string`\n Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion.\n\n\n- `useUniqueFileName?: boolean`\n Whether to use a unique filename for this file or not.\n\nIf `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename.\n\nIf `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced.\n\n\n- `webhookUrl?: string`\n The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure.\n\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a successful upload.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnailUrl?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.beta.v2.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'fileName' });\n\nconsole.log(response);\n```", - perLanguage: { - typescript: { - method: 'client.beta.v2.files.upload', - example: - "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.beta.v2.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);", - }, - python: { - method: 'beta.v2.files.upload', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.beta.v2.files.upload(\n file=b"Example data",\n file_name="fileName",\n)\nprint(response.video_codec)', - }, - java: { - method: 'beta().v2().files().upload', - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.beta.v2.files.FileUploadParams;\nimport io.imagekit.models.beta.v2.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.beta().v2().files().upload(params);\n }\n}', - }, - kotlin: { - method: 'beta().v2().files().upload', - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.beta.v2.files.FileUploadParams\nimport com.imagekit.api.models.beta.v2.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUploadParams = FileUploadParams.builder()\n .file("Example data".byteInputStream())\n .fileName("fileName")\n .build()\n val response: FileUploadResponse = client.beta().v2().files().upload(params)\n}', - }, - go: { - method: 'client.Beta.V2.Files.Upload', - example: - 'package main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Beta.V2.Files.Upload(context.TODO(), imagekit.BetaV2FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("Example data"))),\n\t\tFileName: "fileName",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n', - }, - ruby: { - method: 'beta.v2.files.upload', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.beta.v2.files.upload(file: StringIO.new("Example data"), file_name: "fileName")\n\nputs(response)', - }, - cli: { - method: 'files upload', - example: - "imagekit beta:v2:files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name fileName", - }, - php: { - method: 'beta->v2->files->upload', - example: - "beta->v2->files->upload(\n file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),\n fileName: 'fileName',\n token: 'token',\n checks: \"\\\"request.folder\\\" : \\\"marketing/\\\"\\n\",\n customCoordinates: 'customCoordinates',\n customMetadata: ['brand' => 'bar', 'color' => 'bar'],\n description: 'Running shoes',\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n folder: 'folder',\n isPrivateFile: true,\n isPublished: true,\n overwriteAITags: true,\n overwriteCustomMetadata: true,\n overwriteFile: true,\n overwriteTags: true,\n responseFields: ['tags', 'customCoordinates', 'isPrivateFile'],\n tags: ['t-shirt', 'round-neck', 'men'],\n transformation: [\n 'post' => [\n ['type' => 'thumbnail', 'value' => 'w-150,h-150'],\n [\n 'protocol' => 'dash',\n 'type' => 'abs',\n 'value' => 'sr-240_360_480_720_1080',\n ],\n ],\n 'pre' => 'w-300,h-300,q-80',\n ],\n useUniqueFileName: true,\n webhookURL: 'https://example.com',\n);\n\nvar_dump($response);", - }, - csharp: { - method: 'Beta.V2.Files.Upload', - example: - 'FileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes("Example data"),\n FileName = "fileName",\n};\n\nvar response = await client.Beta.V2.Files.Upload(parameters);\n\nConsole.WriteLine(response);', - }, - http: { - example: - 'curl https://upload.imagekit.io/api/v2/files/upload \\\n -H \'Content-Type: multipart/form-data\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -F \'file=@/path/to/file\' \\\n -F fileName=fileName \\\n -F checks=\'"request.folder" : "marketing/"\n \' \\\n -F customMetadata=\'{"brand":"bar","color":"bar"}\' \\\n -F description=\'Running shoes\' \\\n -F extensions=\'[{"name":"remove-bg","options":{"add_shadow":true}},{"maxTags":5,"minConfidence":95,"name":"google-auto-tagging"},{"name":"ai-auto-description"},{"name":"ai-tasks","tasks":[{"instruction":"What types of clothing items are visible in this image?","type":"select_tags","vocabulary":["shirt","tshirt","dress","trousers","jacket"]},{"instruction":"Is this a luxury or high-end fashion item?","type":"yes_no","on_yes":{"add_tags":["luxury","premium"]}}]},{"id":"ext_abc123","name":"saved-extension"}]\' \\\n -F responseFields=\'["tags","customCoordinates","isPrivateFile"]\' \\\n -F tags=\'["t-shirt","round-neck","men"]\' \\\n -F transformation=\'{"post":[{"type":"thumbnail","value":"w-150,h-150"},{"protocol":"dash","type":"abs","value":"sr-240_360_480_720_1080"}]}\'', - }, - }, + "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", + "markdown": "## upload\n\n`client.beta.v2.files.upload(file: string, fileName: string, token?: string, checks?: string, customCoordinates?: string, customMetadata?: object, description?: string, extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[], folder?: string, isPrivateFile?: boolean, isPublished?: boolean, overwriteAITags?: boolean, overwriteCustomMetadata?: boolean, overwriteFile?: boolean, overwriteTags?: boolean, responseFields?: string[], tags?: string[], transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }, useUniqueFileName?: boolean, webhookUrl?: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: object; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: metadata; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**post** `/api/v2/files/upload`\n\nThe V2 API enhances security by verifying the entire payload using JWT. This API is in beta.\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) about how to implement secure client-side file upload.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files, and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n\n\n### Parameters\n\n- `file: string`\n The API accepts any of the following:\n\n- **Binary data** – send the raw bytes as `multipart/form-data`.\n- **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.\n- **Base64 string** – the file encoded as a Base64 data URI or plain Base64.\n\nWhen supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.\n\n\n- `fileName: string`\n The name with which the file has to be uploaded.\n\n\n- `token?: string`\n This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses it to authenticate and check that the upload request parameters have not been tampered with after the token has been generated. Learn how to create the token on the page below. This field is only required for authentication when uploading a file from the client side.\n\n\n**Note**: Sending a JWT that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new token.\n\n\n**⚠️Warning**: JWT must be generated on the server-side because it is generated using your account's private API key. This field is required for authentication when uploading a file from the client-side.\n\n\n- `checks?: string`\n Server-side checks to run on the asset.\nRead more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks).\n\n\n- `customCoordinates?: string`\n Define an important area in the image. This is only relevant for image type files.\n\n - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100`\n - Can be used with fo-customtransformation.\n - If this field is not specified and the file is overwritten, then customCoordinates will be removed.\n\n\n- `customMetadata?: object`\n JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.\n\n\n- `description?: string`\n Optional text to describe the contents of the file.\n\n\n- `extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[]`\n Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.\n\n\n- `folder?: string`\n The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created. Using multiple `/` creates a nested folder.\n\n\n- `isPrivateFile?: boolean`\n Whether to mark the file as private or not.\n\nIf `true`, the file is marked as private and is accessible only using named transformation or signed URL.\n\n\n- `isPublished?: boolean`\n Whether to upload file as published or not.\n\nIf `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published.\n\nThe option to upload in draft state is only available in custom enterprise pricing plans.\n\n\n- `overwriteAITags?: boolean`\n If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags.\n\n\n- `overwriteCustomMetadata?: boolean`\n If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed.\n\n\n- `overwriteFile?: boolean`\n If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately.\n\n\n- `overwriteTags?: boolean`\n If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed.\n\n\n- `responseFields?: string[]`\n Array of response field keys to include in the API response body.\n\n\n- `tags?: string[]`\n Set the tags while uploading the file.\nProvide an array of tag strings (e.g. `[\"tag1\", \"tag2\", \"tag3\"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed.\nIf this field is not specified and the file is overwritten, the existing tags will be removed.\n\n\n- `transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }`\n Configure pre-processing (`pre`) and post-processing (`post`) transformations.\n\n- `pre` — applied before the file is uploaded to the Media Library. \n Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress).\n\n- `post` — applied immediately after upload. \n Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay.\n\nYou can mix and match any combination of post-processing types.\n\n - `post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]`\n List of transformations to apply *after* the file is uploaded. \nEach item must match one of the following types:\n`transformation`, `gif-to-video`, `thumbnail`, `abs`.\n\n - `pre?: string`\n Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion.\n\n\n- `useUniqueFileName?: boolean`\n Whether to use a unique filename for this file or not.\n\nIf `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename.\n\nIf `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced.\n\n\n- `webhookUrl?: string`\n The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure.\n\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a successful upload.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnailUrl?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.beta.v2.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'fileName' });\n\nconsole.log(response);\n```", + "perLanguage": { + "typescript": { + "method": "client.beta.v2.files.upload", + "example": "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.beta.v2.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);" + }, + "python": { + "method": "beta.v2.files.upload", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.beta.v2.files.upload(\n file=b\"Example data\",\n file_name=\"fileName\",\n)\nprint(response.video_codec)" + }, + "java": { + "method": "beta().v2().files().upload", + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.beta.v2.files.FileUploadParams;\nimport io.imagekit.models.beta.v2.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream(\"Example data\".getBytes()))\n .fileName(\"fileName\")\n .build();\n FileUploadResponse response = client.beta().v2().files().upload(params);\n }\n}" + }, + "kotlin": { + "method": "beta().v2().files().upload", + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.beta.v2.files.FileUploadParams\nimport com.imagekit.api.models.beta.v2.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUploadParams = FileUploadParams.builder()\n .file(\"Example data\".byteInputStream())\n .fileName(\"fileName\")\n .build()\n val response: FileUploadResponse = client.beta().v2().files().upload(params)\n}" + }, + "go": { + "method": "client.Beta.V2.Files.Upload", + "example": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Beta.V2.Files.Upload(context.TODO(), imagekit.BetaV2FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\tFileName: \"fileName\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.VideoCodec)\n}\n" + }, + "ruby": { + "method": "beta.v2.files.upload", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.beta.v2.files.upload(file: StringIO.new(\"Example data\"), file_name: \"fileName\")\n\nputs(response)" + }, + "cli": { + "method": "files upload", + "example": "imagekit beta:v2:files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name fileName" + }, + "php": { + "method": "beta->v2->files->upload", + "example": "beta->v2->files->upload(\n file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),\n fileName: 'fileName',\n token: 'token',\n checks: \"\\\"request.folder\\\" : \\\"marketing/\\\"\\n\",\n customCoordinates: 'customCoordinates',\n customMetadata: ['brand' => 'bar', 'color' => 'bar'],\n description: 'Running shoes',\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n folder: 'folder',\n isPrivateFile: true,\n isPublished: true,\n overwriteAITags: true,\n overwriteCustomMetadata: true,\n overwriteFile: true,\n overwriteTags: true,\n responseFields: ['tags', 'customCoordinates', 'isPrivateFile'],\n tags: ['t-shirt', 'round-neck', 'men'],\n transformation: [\n 'post' => [\n ['type' => 'thumbnail', 'value' => 'w-150,h-150'],\n [\n 'protocol' => 'dash',\n 'type' => 'abs',\n 'value' => 'sr-240_360_480_720_1080',\n ],\n ],\n 'pre' => 'w-300,h-300,q-80',\n ],\n useUniqueFileName: true,\n webhookURL: 'https://example.com',\n);\n\nvar_dump($response);" + }, + "csharp": { + "method": "Beta.V2.Files.Upload", + "example": "FileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes(\"Example data\"),\n FileName = \"fileName\",\n};\n\nvar response = await client.Beta.V2.Files.Upload(parameters);\n\nConsole.WriteLine(response);" + }, + "http": { + "example": "curl https://upload.imagekit.io/api/v2/files/upload \\\n -H 'Content-Type: multipart/form-data' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -F 'file=@/path/to/file' \\\n -F fileName=fileName \\\n -F checks='\"request.folder\" : \"marketing/\"\n ' \\\n -F customMetadata='{\"brand\":\"bar\",\"color\":\"bar\"}' \\\n -F description='Running shoes' \\\n -F extensions='[{\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true}},{\"maxTags\":5,\"minConfidence\":95,\"name\":\"google-auto-tagging\"},{\"name\":\"ai-auto-description\"},{\"name\":\"ai-tasks\",\"tasks\":[{\"instruction\":\"What types of clothing items are visible in this image?\",\"type\":\"select_tags\",\"vocabulary\":[\"shirt\",\"tshirt\",\"dress\",\"trousers\",\"jacket\"]},{\"instruction\":\"Is this a luxury or high-end fashion item?\",\"type\":\"yes_no\",\"on_yes\":{\"add_tags\":[\"luxury\",\"premium\"]}}]},{\"id\":\"ext_abc123\",\"name\":\"saved-extension\"}]' \\\n -F responseFields='[\"tags\",\"customCoordinates\",\"isPrivateFile\"]' \\\n -F tags='[\"t-shirt\",\"round-neck\",\"men\"]' \\\n -F transformation='{\"post\":[{\"type\":\"thumbnail\",\"value\":\"w-150,h-150\"},{\"protocol\":\"dash\",\"type\":\"abs\",\"value\":\"sr-240_360_480_720_1080\"}]}'" + } + } }, { - name: 'unwrap', - endpoint: '', - httpMethod: '', - summary: '', - description: '', - stainlessPath: '(resource) webhooks > (method) unwrap', - qualified: 'client.webhooks.unwrap', - perLanguage: { - typescript: { - method: 'client.webhooks.unwrap', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.webhooks.unwrap();", - }, - python: { - method: 'webhooks.unwrap', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.webhooks.unwrap()', - }, - java: { - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.webhooks.WebhookUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unwrap();\n }\n}', - }, - kotlin: { - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.webhooks.WebhookUnwrapParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.webhooks().unwrap()\n}', - }, - go: { - method: 'client.Webhooks.Unwrap', - example: - 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Webhooks.Unwrap(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', - }, - ruby: { - method: 'webhooks.unwrap', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.webhooks.unwrap\n\nputs(result)', - }, - cli: { - example: - "imagekit webhooks unwrap \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - php: { - method: 'webhooks->unwrap', - example: - "webhooks->unwrap();\n\nvar_dump($result);", - }, - csharp: { - example: 'WebhookUnwrapParams parameters = new();\n\nawait client.Webhooks.Unwrap(parameters);', - }, - }, + "name": "unwrap", + "endpoint": "", + "httpMethod": "", + "summary": "", + "description": "", + "stainlessPath": "(resource) webhooks > (method) unwrap", + "qualified": "client.webhooks.unwrap", + "perLanguage": { + "typescript": { + "method": "client.webhooks.unwrap", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.webhooks.unwrap();" + }, + "python": { + "method": "webhooks.unwrap", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nclient.webhooks.unwrap()" + }, + "java": { + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.webhooks.WebhookUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unwrap();\n }\n}" + }, + "kotlin": { + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.webhooks.WebhookUnwrapParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.webhooks().unwrap()\n}" + }, + "go": { + "method": "client.Webhooks.Unwrap", + "example": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\terr := client.Webhooks.Unwrap(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n" + }, + "ruby": { + "method": "webhooks.unwrap", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresult = image_kit.webhooks.unwrap\n\nputs(result)" + }, + "cli": { + "example": "imagekit webhooks unwrap \\\n --private-key 'My Private Key' \\\n --password 'My Password'" + }, + "php": { + "method": "webhooks->unwrap", + "example": "webhooks->unwrap();\n\nvar_dump($result);" + }, + "csharp": { + "example": "WebhookUnwrapParams parameters = new();\n\nawait client.Webhooks.Unwrap(parameters);" + } + } }, { - name: 'unsafe_unwrap', - endpoint: '', - httpMethod: '', - summary: '', - description: '', - stainlessPath: '(resource) webhooks > (method) unsafe_unwrap', - qualified: 'client.webhooks.unsafeUnwrap', - perLanguage: { - typescript: { - method: 'client.webhooks.unsafeUnwrap', - example: - "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.webhooks.unsafeUnwrap();", - }, - python: { - method: 'webhooks.unsafe_unwrap', - example: - 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.webhooks.unsafe_unwrap()', - }, - java: { - example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.webhooks.WebhookUnsafeUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unsafeUnwrap();\n }\n}', - }, - kotlin: { - example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.webhooks.WebhookUnsafeUnwrapParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.webhooks().unsafeUnwrap()\n}', - }, - go: { - method: 'client.Webhooks.UnsafeUnwrap', - example: - 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Webhooks.UnsafeUnwrap(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', - }, - ruby: { - method: 'webhooks.unsafe_unwrap', - example: - 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.webhooks.unsafe_unwrap\n\nputs(result)', - }, - cli: { - example: - "imagekit webhooks unsafe-unwrap \\\n --private-key 'My Private Key' \\\n --password 'My Password'", - }, - php: { - method: 'webhooks->unsafeUnwrap', - example: - "webhooks->unsafeUnwrap();\n\nvar_dump($result);", - }, - csharp: { - example: - 'WebhookUnsafeUnwrapParams parameters = new();\n\nawait client.Webhooks.UnsafeUnwrap(parameters);', - }, - }, - }, + "name": "unsafe_unwrap", + "endpoint": "", + "httpMethod": "", + "summary": "", + "description": "", + "stainlessPath": "(resource) webhooks > (method) unsafe_unwrap", + "qualified": "client.webhooks.unsafeUnwrap", + "perLanguage": { + "typescript": { + "method": "client.webhooks.unsafeUnwrap", + "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.webhooks.unsafeUnwrap();" + }, + "python": { + "method": "webhooks.unsafe_unwrap", + "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nclient.webhooks.unsafe_unwrap()" + }, + "java": { + "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.webhooks.WebhookUnsafeUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unsafeUnwrap();\n }\n}" + }, + "kotlin": { + "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.webhooks.WebhookUnsafeUnwrapParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.webhooks().unsafeUnwrap()\n}" + }, + "go": { + "method": "client.Webhooks.UnsafeUnwrap", + "example": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\terr := client.Webhooks.UnsafeUnwrap(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n" + }, + "ruby": { + "method": "webhooks.unsafe_unwrap", + "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresult = image_kit.webhooks.unsafe_unwrap\n\nputs(result)" + }, + "cli": { + "example": "imagekit webhooks unsafe-unwrap \\\n --private-key 'My Private Key' \\\n --password 'My Password'" + }, + "php": { + "method": "webhooks->unsafeUnwrap", + "example": "webhooks->unsafeUnwrap();\n\nvar_dump($result);" + }, + "csharp": { + "example": "WebhookUnsafeUnwrapParams parameters = new();\n\nawait client.Webhooks.UnsafeUnwrap(parameters);" + } + } + } ]; const EMBEDDED_READMES: { language: string; content: string }[] = [ { - language: 'cli', - content: - "# Image Kit CLI\n\nThe official CLI for the [Image Kit REST API](https://imagekit.io/docs/api-reference).\n\n## Installation\n\n### Installing with Go\n\nTo test or install the CLI locally, you need [Go](https://go.dev/doc/install) version 1.22 or later installed.\n\n~~~sh\ngo install 'github.com/stainless-sdks/imagekit-cli/cmd/imagekit@latest'\n~~~\n\nOnce you have run `go install`, the binary is placed in your Go bin directory:\n\n- **Default location**: `$HOME/go/bin` (or `$GOPATH/bin` if GOPATH is set)\n- **Check your path**: Run `go env GOPATH` to see the base directory\n\nIf commands aren't found after installation, add the Go bin directory to your PATH:\n\n~~~sh\n# Add to your shell profile (.zshrc, .bashrc, etc.)\nexport PATH=\"$PATH:$(go env GOPATH)/bin\"\n~~~\n\n### Running Locally\n\nAfter cloning the git repository for this project, you can use the\n`scripts/run` script to run the tool locally:\n\n~~~sh\n./scripts/run args...\n~~~\n\n## Usage\n\nThe CLI follows a resource-based command structure:\n\n~~~sh\nimagekit [resource] [flags...]\n~~~\n\n~~~sh\nimagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name file-name.jpg\n~~~\n\nFor details about specific commands, use the `--help` flag.\n\n### Environment variables\n\n| Environment variable | Description | Required | Default value |\n| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------- |\n| `IMAGEKIT_PRIVATE_KEY` | Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n | yes | |\n| `OPTIONAL_IMAGEKIT_IGNORES_THIS` | ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n | no | `\"do_not_set\"` |\n| `IMAGEKIT_WEBHOOK_SECRET` | Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n | no | `null` |\n\n### Global flags\n\n- `--private-key` - Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n (can also be set with `IMAGEKIT_PRIVATE_KEY` env var)\n- `--password` - ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n (can also be set with `OPTIONAL_IMAGEKIT_IGNORES_THIS` env var)\n- `--webhook-secret` - Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n (can also be set with `IMAGEKIT_WEBHOOK_SECRET` env var)\n- `--help` - Show command line usage\n- `--debug` - Enable debug logging (includes HTTP request/response details)\n- `--version`, `-v` - Show the CLI version\n- `--base-url` - Use a custom API backend URL\n- `--format` - Change the output format (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--format-error` - Change the output format for errors (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--transform` - Transform the data output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n- `--transform-error` - Transform the error output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n\n### Passing files as arguments\n\nTo pass files to your API, you can use the `@myfile.ext` syntax:\n\n~~~bash\nimagekit --arg @abe.jpg\n~~~\n\nFiles can also be passed inside JSON or YAML blobs:\n\n~~~bash\nimagekit --arg '{image: \"@abe.jpg\"}'\n# Equivalent:\nimagekit < --username '\\@abe'\n~~~\n\n#### Explicit encoding\n\nFor JSON endpoints, the CLI tool does filetype sniffing to determine whether the\nfile contents should be sent as a string literal (for plain text files) or as a\nbase64-encoded string literal (for binary files). If you need to explicitly send\nthe file as either plain text or base64-encoded data, you can use\n`@file://myfile.txt` (for string encoding) or `@data://myfile.dat` (for\nbase64-encoding). Note that absolute paths will begin with `@file://` or\n`@data://`, followed by a third `/` (for example, `@file:///tmp/file.txt`).\n\n~~~bash\nimagekit --arg @data://file.txt\n~~~\n\n## Linking different Go SDK versions\n\nYou can link the CLI against a different version of the Image Kit Go SDK\nfor development purposes using the `./scripts/link` script.\n\nTo link to a specific version from a repository (version can be a branch,\ngit tag, or commit hash):\n\n~~~bash\n./scripts/link github.com/org/repo@version\n~~~\n\nTo link to a local copy of the SDK:\n\n~~~bash\n./scripts/link ../path/to/imagekit-go\n~~~\n\nIf you run the link script without any arguments, it will default to `../imagekit-go`.\n", + "language": "cli", + "content": "# Image Kit CLI\n\nThe official CLI for the [Image Kit REST API](https://imagekit.io/docs/api-reference).\n\n## Installation\n\n### Installing with Go\n\nTo test or install the CLI locally, you need [Go](https://go.dev/doc/install) version 1.22 or later installed.\n\n~~~sh\ngo install 'github.com/stainless-sdks/imagekit-cli/cmd/imagekit@latest'\n~~~\n\nOnce you have run `go install`, the binary is placed in your Go bin directory:\n\n- **Default location**: `$HOME/go/bin` (or `$GOPATH/bin` if GOPATH is set)\n- **Check your path**: Run `go env GOPATH` to see the base directory\n\nIf commands aren't found after installation, add the Go bin directory to your PATH:\n\n~~~sh\n# Add to your shell profile (.zshrc, .bashrc, etc.)\nexport PATH=\"$PATH:$(go env GOPATH)/bin\"\n~~~\n\n### Running Locally\n\nAfter cloning the git repository for this project, you can use the\n`scripts/run` script to run the tool locally:\n\n~~~sh\n./scripts/run args...\n~~~\n\n## Usage\n\nThe CLI follows a resource-based command structure:\n\n~~~sh\nimagekit [resource] [flags...]\n~~~\n\n~~~sh\nimagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name file-name.jpg\n~~~\n\nFor details about specific commands, use the `--help` flag.\n\n### Environment variables\n\n| Environment variable | Description | Required | Default value |\n| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------- |\n| `IMAGEKIT_PRIVATE_KEY` | Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n | yes | |\n| `OPTIONAL_IMAGEKIT_IGNORES_THIS` | ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n | no | `\"do_not_set\"` |\n| `IMAGEKIT_WEBHOOK_SECRET` | Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n | no | `null` |\n\n### Global flags\n\n- `--private-key` - Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n (can also be set with `IMAGEKIT_PRIVATE_KEY` env var)\n- `--password` - ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n (can also be set with `OPTIONAL_IMAGEKIT_IGNORES_THIS` env var)\n- `--webhook-secret` - Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n (can also be set with `IMAGEKIT_WEBHOOK_SECRET` env var)\n- `--help` - Show command line usage\n- `--debug` - Enable debug logging (includes HTTP request/response details)\n- `--version`, `-v` - Show the CLI version\n- `--base-url` - Use a custom API backend URL\n- `--format` - Change the output format (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--format-error` - Change the output format for errors (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--transform` - Transform the data output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n- `--transform-error` - Transform the error output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n\n### Passing files as arguments\n\nTo pass files to your API, you can use the `@myfile.ext` syntax:\n\n~~~bash\nimagekit --arg @abe.jpg\n~~~\n\nFiles can also be passed inside JSON or YAML blobs:\n\n~~~bash\nimagekit --arg '{image: \"@abe.jpg\"}'\n# Equivalent:\nimagekit < --username '\\@abe'\n~~~\n\n#### Explicit encoding\n\nFor JSON endpoints, the CLI tool does filetype sniffing to determine whether the\nfile contents should be sent as a string literal (for plain text files) or as a\nbase64-encoded string literal (for binary files). If you need to explicitly send\nthe file as either plain text or base64-encoded data, you can use\n`@file://myfile.txt` (for string encoding) or `@data://myfile.dat` (for\nbase64-encoding). Note that absolute paths will begin with `@file://` or\n`@data://`, followed by a third `/` (for example, `@file:///tmp/file.txt`).\n\n~~~bash\nimagekit --arg @data://file.txt\n~~~\n\n## Linking different Go SDK versions\n\nYou can link the CLI against a different version of the Image Kit Go SDK\nfor development purposes using the `./scripts/link` script.\n\nTo link to a specific version from a repository (version can be a branch,\ngit tag, or commit hash):\n\n~~~bash\n./scripts/link github.com/org/repo@version\n~~~\n\nTo link to a local copy of the SDK:\n\n~~~bash\n./scripts/link ../path/to/imagekit-go\n~~~\n\nIf you run the link script without any arguments, it will default to `../imagekit-go`.\n" }, { - language: 'csharp', - content: - '# Image Kit C# API Library\n\nThe Image Kit C# SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in C#.\n\n## Installation\n\n```bash\ngit clone git@github.com:stainless-sdks/imagekit-csharp.git\ndotnet add reference imagekit-csharp/src/ImageKit\n```\n\n## Requirements\n\nThis library requires .NET Standard 2.0 or later.\n\n## Usage\n\nSee the [`examples`](examples) directory for complete and runnable examples.\n\n```csharp\nImageKitClient client = new();\n\nFileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes("https://www.example.com/public-url.jpg"),\n FileName = "file-name.jpg",\n};\n\nvar response = await client.Files.Upload(parameters);\n\nConsole.WriteLine(response);\n```', + "language": "csharp", + "content": "# Image Kit C# API Library\n\nThe Image Kit C# SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in C#.\n\n## Installation\n\n```bash\ngit clone git@github.com:stainless-sdks/imagekit-csharp.git\ndotnet add reference imagekit-csharp/src/ImageKit\n```\n\n## Requirements\n\nThis library requires .NET Standard 2.0 or later.\n\n## Usage\n\nSee the [`examples`](examples) directory for complete and runnable examples.\n\n```csharp\nImageKitClient client = new();\n\nFileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes(\"https://www.example.com/public-url.jpg\"),\n FileName = \"file-name.jpg\",\n};\n\nvar response = await client.Files.Upload(parameters);\n\nConsole.WriteLine(response);\n```" }, { - language: 'go', - content: - '# Image Kit Go API Library\n\nGo Reference\n\nThe Image Kit Go library provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference)\nfrom applications written in Go.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n\n\n```go\nimport (\n\t"github.com/imagekit-developer/imagekit-go" // imported as SDK_PackageName\n)\n```\n\n\n\nOr to pin the version:\n\n\n\n```sh\ngo get -u \'github.com/imagekit-developer/imagekit-go@v0.0.1\'\n```\n\n\n\n## Requirements\n\nThis library requires Go 1.22+.\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```go\npackage main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"), // defaults to os.LookupEnv("IMAGEKIT_PRIVATE_KEY")\n\t\toption.WithPassword("My Password"), // defaults to os.LookupEnv("OPTIONAL_IMAGEKIT_IGNORES_THIS")\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n\n```\n\n### Request fields\n\nAll request parameters are wrapped in a generic `Field` type,\nwhich we use to distinguish zero values from null or omitted fields.\n\nThis prevents accidentally sending a zero value if you forget a required parameter,\nand enables explicitly sending `null`, `false`, `\'\'`, or `0` on optional parameters.\nAny field not specified is not sent.\n\nTo construct fields with values, use the helpers `String()`, `Int()`, `Float()`, or most commonly, the generic `F[T]()`.\nTo send a null, use `Null[T]()`, and to send a nonconforming value, use `Raw[T](any)`. For example:\n\n```go\nparams := FooParams{\n\tName: SDK_PackageName.F("hello"),\n\n\t// Explicitly send `"description": null`\n\tDescription: SDK_PackageName.Null[string](),\n\n\tPoint: SDK_PackageName.F(SDK_PackageName.Point{\n\t\tX: SDK_PackageName.Int(0),\n\t\tY: SDK_PackageName.Int(1),\n\n\t\t// In cases where the API specifies a given type,\n\t\t// but you want to send something else, use `Raw`:\n\t\tZ: SDK_PackageName.Raw[int64](0.01), // sends a float\n\t}),\n}\n```\n\n### Response objects\n\nAll fields in response structs are value types (not pointers or wrappers).\n\nIf a given field is `null`, not present, or invalid, the corresponding field\nwill simply be its zero value.\n\nAll response structs also include a special `JSON` field, containing more detailed\ninformation about each property, which you can use like so:\n\n```go\nif res.Name == "" {\n\t// true if `"name"` is either not present or explicitly null\n\tres.JSON.Name.IsNull()\n\n\t// true if the `"name"` key was not present in the response JSON at all\n\tres.JSON.Name.IsMissing()\n\n\t// When the API returns data that cannot be coerced to the expected type:\n\tif res.JSON.Name.IsInvalid() {\n\t\traw := res.JSON.Name.Raw()\n\n\t\tlegacyName := struct{\n\t\t\tFirst string `json:"first"`\n\t\t\tLast string `json:"last"`\n\t\t}{}\n\t\tjson.Unmarshal([]byte(raw), &legacyName)\n\t\tname = legacyName.First + " " + legacyName.Last\n\t}\n}\n```\n\nThese `.JSON` structs also include an `Extras` map containing\nany properties in the json response that were not specified\nin the struct. This can be useful for API features not yet\npresent in the SDK.\n\n```go\nbody := res.JSON.ExtraFields["my_unexpected_field"].Raw()\n```\n\n### RequestOptions\n\nThis library uses the functional options pattern. Functions defined in the\n`SDK_PackageOptionName` package return a `RequestOption`, which is a closure that mutates a\n`RequestConfig`. These options can be supplied to the client or at individual\nrequests. For example:\n\n```go\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\t// Adds a header to every request made by the client\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "custom_header_info"),\n)\n\nclient.Files.Upload(context.TODO(), ...,\n\t// Override the header\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "some_other_custom_header_info"),\n\t// Add an undocumented field to the request body, using sjson syntax\n\tSDK_PackageOptionName.WithJSONSet("some.json.path", map[string]string{"my": "object"}),\n)\n```\n\nSee the [full list of request options](https://pkg.go.dev/github.com/imagekit-developer/imagekit-go/SDK_PackageOptionName).\n\n### Pagination\n\nThis library provides some conveniences for working with paginated list endpoints.\n\nYou can use `.ListAutoPaging()` methods to iterate through items across all pages:\n\n\n\nOr you can use simple `.List()` methods to fetch a single page and receive a standard response object\nwith additional helper methods like `.GetNextPage()`, e.g.:\n\n\n\n### Errors\n\nWhen the API returns a non-success status code, we return an error with type\n`*SDK_PackageName.Error`. This contains the `StatusCode`, `*http.Request`, and\n`*http.Response` values of the request, as well as the JSON of the error body\n(much like other response objects in the SDK).\n\nTo handle errors, we recommend that you use the `errors.As` pattern:\n\n```go\n_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\tFileName: "file-name.jpg",\n})\nif err != nil {\n\tvar apierr *imagekit.Error\n\tif errors.As(err, &apierr) {\n\t\tprintln(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request\n\t\tprintln(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response\n\t}\n\tpanic(err.Error()) // GET "/api/v1/files/upload": 400 Bad Request { ... }\n}\n```\n\nWhen other errors occur, they are returned unwrapped; for example,\nif HTTP transport fails, you might receive `*url.Error` wrapping `*net.OpError`.\n\n### Timeouts\n\nRequests do not time out by default; use context to configure a timeout for a request lifecycle.\n\nNote that if a request is [retried](#retries), the context timeout does not start over.\nTo set a per-retry timeout, use `SDK_PackageOptionName.WithRequestTimeout()`.\n\n```go\n// This sets the timeout for the request, including all the retries.\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\nclient.Files.Upload(\n\tctx,\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\t// This sets the per-retry timeout\n\toption.WithRequestTimeout(20*time.Second),\n)\n```\n\n### File uploads\n\nRequest parameters that correspond to file uploads in multipart requests are typed as\n`param.Field[io.Reader]`. The contents of the `io.Reader` will by default be sent as a multipart form\npart with the file name of "anonymous_file" and content-type of "application/octet-stream".\n\nThe file name and content-type can be customized by implementing `Name() string` or `ContentType()\nstring` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a\nfile returned by `os.Open` will be sent with the file name on disk.\n\nWe also provide a helper `SDK_PackageName.FileParam(reader io.Reader, filename string, contentType string)`\nwhich can be used to wrap any `io.Reader` with the appropriate file name and content type.\n\n```go\n// A file from the file system\nfile, err := os.Open("/path/to/file")\nimagekit.FileUploadParams{\n\tFile: file,\n\tFileName: "fileName",\n}\n\n// A file from a string\nimagekit.FileUploadParams{\n\tFile: strings.NewReader("my file contents"),\n\tFileName: "fileName",\n}\n\n// With a custom filename and contentType\nimagekit.FileUploadParams{\n\tFile: imagekit.NewFile(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"),\n\tFileName: "fileName",\n}\n```\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nWe retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit,\nand >=500 Internal errors.\n\nYou can use the `WithMaxRetries` option to configure or disable this:\n\n```go\n// Configure the default for all requests:\nclient := imagekit.NewClient(\n\toption.WithMaxRetries(0), // default is 2\n)\n\n// Override per-request:\nclient.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithMaxRetries(5),\n)\n```\n\n\n### Accessing raw response data (e.g. response headers)\n\nYou can access the raw HTTP response data by using the `option.WithResponseInto()` request option. This is useful when\nyou need to examine response headers, status codes, or other details.\n\n```go\n// Create a variable to store the HTTP response\nvar response *http.Response\nresponse, err := client.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithResponseInto(&response),\n)\nif err != nil {\n\t// handle error\n}\nfmt.Printf("%+v\\n", response)\n\nfmt.Printf("Status Code: %d\\n", response.StatusCode)\nfmt.Printf("Headers: %+#v\\n", response.Header)\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.Get`, `client.Post`, and other HTTP verbs.\n`RequestOptions` on the client, such as retries, will be respected when making these requests.\n\n```go\nvar (\n // params can be an io.Reader, a []byte, an encoding/json serializable object,\n // or a "…Params" struct defined in this library.\n params map[string]interface{}\n\n // result can be an []byte, *http.Response, a encoding/json deserializable object,\n // or a model defined in this library.\n result *http.Response\n)\nerr := client.Post(context.Background(), "/unspecified", params, &result)\nif err != nil {\n …\n}\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use either the `SDK_PackageOptionName.WithQuerySet()`\nor the `SDK_PackageOptionName.WithJSONSet()` methods.\n\n```go\nparams := FooNewParams{\n ID: SDK_PackageName.F("id_xxxx"),\n Data: SDK_PackageName.F(FooNewParamsData{\n FirstName: SDK_PackageName.F("John"),\n }),\n}\nclient.Foo.New(context.Background(), params, SDK_PackageOptionName.WithJSONSet("data.last_name", "Doe"))\n```\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may either access the raw JSON of the response as a string\nwith `result.JSON.RawJSON()`, or get the raw JSON of a particular field on the result with\n`result.JSON.Foo.Raw()`.\n\nAny fields that are not present on the response struct will be saved and can be accessed by `result.JSON.ExtraFields()` which returns the extra fields as a `map[string]Field`.\n\n### Middleware\n\nWe provide `SDK_PackageOptionName.WithMiddleware` which applies the given\nmiddleware to requests.\n\n```go\nfunc Logger(req *http.Request, next SDK_PackageOptionName.MiddlewareNext) (res *http.Response, err error) {\n\t// Before the request\n\tstart := time.Now()\n\tLogReq(req)\n\n\t// Forward the request to the next handler\n\tres, err = next(req)\n\n\t// Handle stuff after the request\n\tend := time.Now()\n\tLogRes(res, err, start - end)\n\n return res, err\n}\n\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\tSDK_PackageOptionName.WithMiddleware(Logger),\n)\n```\n\nWhen multiple middlewares are provided as variadic arguments, the middlewares\nare applied left to right. If `SDK_PackageOptionName.WithMiddleware` is given\nmultiple times, for example first in the client then the method, the\nmiddleware in the client will run first and the middleware given in the method\nwill run next.\n\nYou may also replace the default `http.Client` with\n`SDK_PackageOptionName.WithHTTPClient(client)`. Only one http client is\naccepted (this overwrites any previous client) and receives requests after any\nmiddleware has been applied.\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-go/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', + "language": "go", + "content": "# Image Kit Go API Library\n\n\"Go\n\nThe Image Kit Go library provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference)\nfrom applications written in Go.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n\n\n```go\nimport (\n\t\"github.com/imagekit-developer/imagekit-go\" // imported as SDK_PackageName\n)\n```\n\n\n\nOr to pin the version:\n\n\n\n```sh\ngo get -u 'github.com/imagekit-developer/imagekit-go@v0.0.1'\n```\n\n\n\n## Requirements\n\nThis library requires Go 1.22+.\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```go\npackage main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"), // defaults to os.LookupEnv(\"IMAGEKIT_PRIVATE_KEY\")\n\t\toption.WithPassword(\"My Password\"), // defaults to os.LookupEnv(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\")\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"https://www.example.com/public-url.jpg\"))),\n\t\tFileName: \"file-name.jpg\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.VideoCodec)\n}\n\n```\n\n### Request fields\n\nAll request parameters are wrapped in a generic `Field` type,\nwhich we use to distinguish zero values from null or omitted fields.\n\nThis prevents accidentally sending a zero value if you forget a required parameter,\nand enables explicitly sending `null`, `false`, `''`, or `0` on optional parameters.\nAny field not specified is not sent.\n\nTo construct fields with values, use the helpers `String()`, `Int()`, `Float()`, or most commonly, the generic `F[T]()`.\nTo send a null, use `Null[T]()`, and to send a nonconforming value, use `Raw[T](any)`. For example:\n\n```go\nparams := FooParams{\n\tName: SDK_PackageName.F(\"hello\"),\n\n\t// Explicitly send `\"description\": null`\n\tDescription: SDK_PackageName.Null[string](),\n\n\tPoint: SDK_PackageName.F(SDK_PackageName.Point{\n\t\tX: SDK_PackageName.Int(0),\n\t\tY: SDK_PackageName.Int(1),\n\n\t\t// In cases where the API specifies a given type,\n\t\t// but you want to send something else, use `Raw`:\n\t\tZ: SDK_PackageName.Raw[int64](0.01), // sends a float\n\t}),\n}\n```\n\n### Response objects\n\nAll fields in response structs are value types (not pointers or wrappers).\n\nIf a given field is `null`, not present, or invalid, the corresponding field\nwill simply be its zero value.\n\nAll response structs also include a special `JSON` field, containing more detailed\ninformation about each property, which you can use like so:\n\n```go\nif res.Name == \"\" {\n\t// true if `\"name\"` is either not present or explicitly null\n\tres.JSON.Name.IsNull()\n\n\t// true if the `\"name\"` key was not present in the response JSON at all\n\tres.JSON.Name.IsMissing()\n\n\t// When the API returns data that cannot be coerced to the expected type:\n\tif res.JSON.Name.IsInvalid() {\n\t\traw := res.JSON.Name.Raw()\n\n\t\tlegacyName := struct{\n\t\t\tFirst string `json:\"first\"`\n\t\t\tLast string `json:\"last\"`\n\t\t}{}\n\t\tjson.Unmarshal([]byte(raw), &legacyName)\n\t\tname = legacyName.First + \" \" + legacyName.Last\n\t}\n}\n```\n\nThese `.JSON` structs also include an `Extras` map containing\nany properties in the json response that were not specified\nin the struct. This can be useful for API features not yet\npresent in the SDK.\n\n```go\nbody := res.JSON.ExtraFields[\"my_unexpected_field\"].Raw()\n```\n\n### RequestOptions\n\nThis library uses the functional options pattern. Functions defined in the\n`SDK_PackageOptionName` package return a `RequestOption`, which is a closure that mutates a\n`RequestConfig`. These options can be supplied to the client or at individual\nrequests. For example:\n\n```go\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\t// Adds a header to every request made by the client\n\tSDK_PackageOptionName.WithHeader(\"X-Some-Header\", \"custom_header_info\"),\n)\n\nclient.Files.Upload(context.TODO(), ...,\n\t// Override the header\n\tSDK_PackageOptionName.WithHeader(\"X-Some-Header\", \"some_other_custom_header_info\"),\n\t// Add an undocumented field to the request body, using sjson syntax\n\tSDK_PackageOptionName.WithJSONSet(\"some.json.path\", map[string]string{\"my\": \"object\"}),\n)\n```\n\nSee the [full list of request options](https://pkg.go.dev/github.com/imagekit-developer/imagekit-go/SDK_PackageOptionName).\n\n### Pagination\n\nThis library provides some conveniences for working with paginated list endpoints.\n\nYou can use `.ListAutoPaging()` methods to iterate through items across all pages:\n\n\n\nOr you can use simple `.List()` methods to fetch a single page and receive a standard response object\nwith additional helper methods like `.GetNextPage()`, e.g.:\n\n\n\n### Errors\n\nWhen the API returns a non-success status code, we return an error with type\n`*SDK_PackageName.Error`. This contains the `StatusCode`, `*http.Request`, and\n`*http.Response` values of the request, as well as the JSON of the error body\n(much like other response objects in the SDK).\n\nTo handle errors, we recommend that you use the `errors.As` pattern:\n\n```go\n_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\tFile: io.Reader(bytes.NewBuffer([]byte(\"https://www.example.com/public-url.jpg\"))),\n\tFileName: \"file-name.jpg\",\n})\nif err != nil {\n\tvar apierr *imagekit.Error\n\tif errors.As(err, &apierr) {\n\t\tprintln(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request\n\t\tprintln(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response\n\t}\n\tpanic(err.Error()) // GET \"/api/v1/files/upload\": 400 Bad Request { ... }\n}\n```\n\nWhen other errors occur, they are returned unwrapped; for example,\nif HTTP transport fails, you might receive `*url.Error` wrapping `*net.OpError`.\n\n### Timeouts\n\nRequests do not time out by default; use context to configure a timeout for a request lifecycle.\n\nNote that if a request is [retried](#retries), the context timeout does not start over.\nTo set a per-retry timeout, use `SDK_PackageOptionName.WithRequestTimeout()`.\n\n```go\n// This sets the timeout for the request, including all the retries.\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\nclient.Files.Upload(\n\tctx,\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"https://www.example.com/public-url.jpg\"))),\n\t\tFileName: \"file-name.jpg\",\n\t},\n\t// This sets the per-retry timeout\n\toption.WithRequestTimeout(20*time.Second),\n)\n```\n\n### File uploads\n\nRequest parameters that correspond to file uploads in multipart requests are typed as\n`param.Field[io.Reader]`. The contents of the `io.Reader` will by default be sent as a multipart form\npart with the file name of \"anonymous_file\" and content-type of \"application/octet-stream\".\n\nThe file name and content-type can be customized by implementing `Name() string` or `ContentType()\nstring` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a\nfile returned by `os.Open` will be sent with the file name on disk.\n\nWe also provide a helper `SDK_PackageName.FileParam(reader io.Reader, filename string, contentType string)`\nwhich can be used to wrap any `io.Reader` with the appropriate file name and content type.\n\n```go\n// A file from the file system\nfile, err := os.Open(\"/path/to/file\")\nimagekit.FileUploadParams{\n\tFile: file,\n\tFileName: \"fileName\",\n}\n\n// A file from a string\nimagekit.FileUploadParams{\n\tFile: strings.NewReader(\"my file contents\"),\n\tFileName: \"fileName\",\n}\n\n// With a custom filename and contentType\nimagekit.FileUploadParams{\n\tFile: imagekit.NewFile(strings.NewReader(`{\"hello\": \"foo\"}`), \"file.go\", \"application/json\"),\n\tFileName: \"fileName\",\n}\n```\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nWe retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit,\nand >=500 Internal errors.\n\nYou can use the `WithMaxRetries` option to configure or disable this:\n\n```go\n// Configure the default for all requests:\nclient := imagekit.NewClient(\n\toption.WithMaxRetries(0), // default is 2\n)\n\n// Override per-request:\nclient.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"https://www.example.com/public-url.jpg\"))),\n\t\tFileName: \"file-name.jpg\",\n\t},\n\toption.WithMaxRetries(5),\n)\n```\n\n\n### Accessing raw response data (e.g. response headers)\n\nYou can access the raw HTTP response data by using the `option.WithResponseInto()` request option. This is useful when\nyou need to examine response headers, status codes, or other details.\n\n```go\n// Create a variable to store the HTTP response\nvar response *http.Response\nresponse, err := client.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"https://www.example.com/public-url.jpg\"))),\n\t\tFileName: \"file-name.jpg\",\n\t},\n\toption.WithResponseInto(&response),\n)\nif err != nil {\n\t// handle error\n}\nfmt.Printf(\"%+v\\n\", response)\n\nfmt.Printf(\"Status Code: %d\\n\", response.StatusCode)\nfmt.Printf(\"Headers: %+#v\\n\", response.Header)\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.Get`, `client.Post`, and other HTTP verbs.\n`RequestOptions` on the client, such as retries, will be respected when making these requests.\n\n```go\nvar (\n // params can be an io.Reader, a []byte, an encoding/json serializable object,\n // or a \"…Params\" struct defined in this library.\n params map[string]interface{}\n\n // result can be an []byte, *http.Response, a encoding/json deserializable object,\n // or a model defined in this library.\n result *http.Response\n)\nerr := client.Post(context.Background(), \"/unspecified\", params, &result)\nif err != nil {\n …\n}\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use either the `SDK_PackageOptionName.WithQuerySet()`\nor the `SDK_PackageOptionName.WithJSONSet()` methods.\n\n```go\nparams := FooNewParams{\n ID: SDK_PackageName.F(\"id_xxxx\"),\n Data: SDK_PackageName.F(FooNewParamsData{\n FirstName: SDK_PackageName.F(\"John\"),\n }),\n}\nclient.Foo.New(context.Background(), params, SDK_PackageOptionName.WithJSONSet(\"data.last_name\", \"Doe\"))\n```\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may either access the raw JSON of the response as a string\nwith `result.JSON.RawJSON()`, or get the raw JSON of a particular field on the result with\n`result.JSON.Foo.Raw()`.\n\nAny fields that are not present on the response struct will be saved and can be accessed by `result.JSON.ExtraFields()` which returns the extra fields as a `map[string]Field`.\n\n### Middleware\n\nWe provide `SDK_PackageOptionName.WithMiddleware` which applies the given\nmiddleware to requests.\n\n```go\nfunc Logger(req *http.Request, next SDK_PackageOptionName.MiddlewareNext) (res *http.Response, err error) {\n\t// Before the request\n\tstart := time.Now()\n\tLogReq(req)\n\n\t// Forward the request to the next handler\n\tres, err = next(req)\n\n\t// Handle stuff after the request\n\tend := time.Now()\n\tLogRes(res, err, start - end)\n\n return res, err\n}\n\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\tSDK_PackageOptionName.WithMiddleware(Logger),\n)\n```\n\nWhen multiple middlewares are provided as variadic arguments, the middlewares\nare applied left to right. If `SDK_PackageOptionName.WithMiddleware` is given\nmultiple times, for example first in the client then the method, the\nmiddleware in the client will run first and the middleware given in the method\nwill run next.\n\nYou may also replace the default `http.Client` with\n`SDK_PackageOptionName.WithHTTPClient(client)`. Only one http client is\naccepted (this overwrites any previous client) and receives requests after any\nmiddleware has been applied.\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-go/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n" }, { - language: 'java', - content: - '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.client.ImageKitClientAsync;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.MultipartField;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.core.http.Headers;\nimport io.imagekit.core.http.HttpResponseFor;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.JsonMissing;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', + "language": "java", + "content": "# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation(\"io.imagekit:image-kit-java:0.0.1\")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream(\"https://www.example.com/public-url.jpg\".getBytes()))\n .fileName(\"file-name.jpg\")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey(\"My Private Key\")\n .password(\"My Password\")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey(\"My Private Key\")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `\"do_not_set\"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `\"https://api.imagekit.io\"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don't create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl(\"https://example.com\");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream(\"https://www.example.com/public-url.jpg\".getBytes()))\n .fileName(\"file-name.jpg\")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.client.ImageKitClientAsync;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream(\"https://www.example.com/public-url.jpg\".getBytes()))\n .fileName(\"file-name.jpg\")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(Paths.get(\"/path/to/file\"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(new URL(\"https://example.com//path/to/file\").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(\"content\".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.MultipartField;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(MultipartField.builder()\n .value(new URL(\"https://example.com//path/to/file\").openStream())\n .filename(\"/path/to/file\")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don't provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.core.http.Headers;\nimport io.imagekit.core.http.HttpResponseFor;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream(\"https://www.example.com/public-url.jpg\".getBytes()))\n .fileName(\"file-name.jpg\")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don't work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n \"https://example.com\", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp's default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader(\"Secret-Header\", \"42\")\n .putAdditionalQueryParam(\"secret_query_param\", \"42\")\n .putAdditionalBodyProperty(\"secretProperty\", JsonValue.from(\"42\"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty(\"secretProperty\", JsonValue.from(\"42\"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName(\"file-name.jpg\")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from(\"Hello World!\");\n\n// Create a JSON array value equivalent to `[\"Hello\", \"World\"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n \"Hello\", \"World\"\n));\n\n// Create a JSON object value equivalent to `{ \"a\": 1, \"b\": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n \"a\", 1,\n \"b\", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// \"a\": [1, 2],\n// \"b\": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n \"a\", List.of(\n 1, 2\n ),\n \"b\", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.JsonMissing;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get(\"secretProperty\");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return \"It's null!\";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return \"It's a boolean!\";\n }\n\n @Override\n public String visitNumber(Number value) {\n return \"It's a number!\";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property's raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don't you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don't want to introduce a breaking change every time we add a field to a class.\n\n### Why don't you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don't play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n" }, { - language: 'kotlin', - content: - '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\nThe Image Kit Kotlin SDK is similar to the Image Kit Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', + "language": "kotlin", + "content": "# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\nThe Image Kit Kotlin SDK is similar to the Image Kit Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation(\"com.imagekit.api:image-kit-kotlin:0.0.1\")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(\"https://www.example.com/public-url.jpg\".byteInputStream())\n .fileName(\"file-name.jpg\")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey(\"My Private Key\")\n .password(\"My Password\")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey(\"My Private Key\")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `\"do_not_set\"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `\"https://api.imagekit.io\"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don't create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl(\"https://example.com\")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(\"https://www.example.com/public-url.jpg\".byteInputStream())\n .fileName(\"file-name.jpg\")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(\"https://www.example.com/public-url.jpg\".byteInputStream())\n .fileName(\"file-name.jpg\")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(Paths.get(\"/path/to/file\"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(URL(\"https://example.com//path/to/file\").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(\"content\".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(MultipartField.builder()\n .value(URL(\"https://example.com//path/to/file\").openStream())\n .filename(\"/path/to/file\")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don't provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(\"https://www.example.com/public-url.jpg\".byteInputStream())\n .fileName(\"file-name.jpg\")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don't work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n \"https://example.com\", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp's default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader(\"Secret-Header\", \"42\")\n .putAdditionalQueryParam(\"secret_query_param\", \"42\")\n .putAdditionalBodyProperty(\"secretProperty\", JsonValue.from(\"42\"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty(\"secretProperty\", JsonValue.from(\"42\"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName(\"file-name.jpg\")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from(\"Hello World!\")\n\n// Create a JSON array value equivalent to `[\"Hello\", \"World\"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n \"Hello\", \"World\"\n))\n\n// Create a JSON object value equivalent to `{ \"a\": 1, \"b\": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n \"a\" to 1, \"b\" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// \"a\": [1, 2],\n// \"b\": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n \"a\" to listOf(\n 1, 2\n ), \"b\" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get(\"secretProperty\")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> \"It's null!\"\n is JsonBoolean -> \"It's a boolean!\"\n is JsonNumber -> \"It's a number!\"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> \"It's something else!\"\n}\n```\n\nTo access a property's raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don't you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don't want to introduce a breaking change every time we add a field to a class.\n\n### Why don't you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don't play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n" }, { - language: 'php', - content: - '# Image Kit PHP API Library\n\nThe Image Kit PHP library provides convenient access to the Image Kit REST API from any PHP 8.1.0+ application.\n\n## Installation\n\nTo use this package, install via Composer by adding the following to your application\'s `composer.json`:\n\n```json\n{\n "repositories": [\n {\n "type": "vcs",\n "url": "git@github.com:stainless-sdks/imagekit-php.git"\n }\n ],\n "require": {\n "imagekit/imagekit": "dev-main"\n }\n}\n```\n\n## Usage\n\n```php\nfiles->upload(\n file: FileParam::fromString(\'https://www.example.com/public-url.jpg\', filename: uniqid(\'file-upload-\', true)),\n fileName: \'file-name.jpg\',\n);\n\nvar_dump($response->videoCodec);\n```', + "language": "php", + "content": "# Image Kit PHP API Library\n\nThe Image Kit PHP library provides convenient access to the Image Kit REST API from any PHP 8.1.0+ application.\n\n## Installation\n\nTo use this package, install via Composer by adding the following to your application's `composer.json`:\n\n```json\n{\n \"repositories\": [\n {\n \"type\": \"vcs\",\n \"url\": \"git@github.com:stainless-sdks/imagekit-php.git\"\n }\n ],\n \"require\": {\n \"imagekit/imagekit\": \"dev-main\"\n }\n}\n```\n\n## Usage\n\n```php\nfiles->upload(\n file: FileParam::fromString('https://www.example.com/public-url.jpg', filename: uniqid('file-upload-', true)),\n fileName: 'file-name.jpg',\n);\n\nvar_dump($response->videoCodec);\n```" }, { - language: 'python', - content: - '# Image Kit Python API library\n\n\n[![PyPI version](https://img.shields.io/pypi/v/imagekitio.svg?label=pypi%20(stable))](https://pypi.org/project/imagekitio/)\n\nThe Image Kit Python library provides convenient access to the Image Kit REST API from any Python 3.9+\napplication. The library includes type definitions for all request params and response fields,\nand offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n## Installation\n\n```sh\n# install from PyPI\npip install imagekitio\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nresponse = client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.video_codec)\n```\n\nWhile you can provide a `private_key` keyword argument,\nwe recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nto add `IMAGEKIT_PRIVATE_KEY="My Private Key"` to your `.env` file\nso that your Private Key is not stored in source control.\n\n## Async usage\n\nSimply import `AsyncImageKit` instead of `ImageKit` and use `await` with each API call:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import AsyncImageKit\n\nclient = AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nasync def main() -> None:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n### With aiohttp\n\nBy default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.\n\nYou can enable this by installing `aiohttp`:\n\n```sh\n# install from PyPI\npip install imagekitio[aiohttp]\n```\n\nThen you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import DefaultAioHttpClient\nfrom imagekitio import AsyncImageKit\n\nasync def main() -> None:\n async with AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n http_client=DefaultAioHttpClient(),\n) as client:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\n\n\n## Using types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:\n\n- Serializing back into JSON, `model.to_json()`\n- Converting to a dictionary, `model.to_dict()`\n\nTyped requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.\n\n\n\n## Nested params\n\nNested parameters are dictionaries, typed using `TypedDict`, for example:\n\n```python\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nresponse = client.files.upload(\n file=b"Example data",\n file_name="fileName",\n transformation={\n "post": [{\n "type": "thumbnail",\n "value": "w-150,h-150",\n }, {\n "protocol": "dash",\n "type": "abs",\n "value": "sr-240_360_480_720_1080",\n }]\n },\n)\nprint(response.transformation)\n```\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.\n\n```python\nfrom pathlib import Path\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nclient.files.upload(\n file=Path("/path/to/file"),\n file_name="fileName",\n)\n```\n\nThe async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.\n\n## Handling errors\n\nWhen the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `imagekitio.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (that is, 4xx or 5xx\nresponse), a subclass of `imagekitio.APIStatusError` is raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `imagekitio.APIError`.\n\n```python\nimport imagekitio\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\ntry:\n client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\nexcept imagekitio.APIConnectionError as e:\n print("The server could not be reached")\n print(e.__cause__) # an underlying Exception, likely raised within httpx.\nexcept imagekitio.RateLimitError as e:\n print("A 429 status code was received; we should back off a bit.")\nexcept imagekitio.APIStatusError as e:\n print("Another non-200-range status code was received")\n print(e.status_code)\n print(e.response)\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors are automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors are all retried by default.\n\nYou can use the `max_retries` option to configure or disable retry settings:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # default is 2\n max_retries=0,\n)\n\n# Or, configure per-request:\nclient.with_options(max_retries = 5).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\n### Timeouts\n\nBy default requests time out after 1 minute. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # 20 seconds (default is 1 minute)\n timeout=20.0,\n)\n\n# More granular control:\nclient = ImageKit(\n timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n)\n\n# Override per-request:\nclient.with_options(timeout = 5.0).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests that time out are [retried twice by default](#retries).\n\n\n\n## Advanced\n\n### Logging\n\nWe use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.\n\nYou can enable logging by setting the environment variable `IMAGE_KIT_LOG` to `info`.\n\n```shell\n$ export IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging.\n\n### How to tell whether `None` means `null` or missing\n\nIn an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:\n\n```py\nif response.my_field is None:\n if \'my_field\' not in response.model_fields_set:\n print(\'Got json like {}, without a "my_field" key present at all.\')\n else:\n print(\'Got json like {"my_field": null}.\')\n```\n\n### Accessing raw response data (e.g. headers)\n\nThe "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,\n\n```py\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\nresponse = client.files.with_raw_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.headers.get(\'X-My-Header\'))\n\nfile = response.parse() # get the object that `files.upload()` would have returned\nprint(file.video_codec)\n```\n\nThese methods return an [`APIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) object.\n\nThe async client returns an [`AsyncAPIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.\n\n#### `.with_streaming_response`\n\nThe above interface eagerly reads the full response body when you make the request, which may not always be what you want.\n\nTo stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.\n\n```python\nwith client.files.with_streaming_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n) as response :\n print(response.headers.get(\'X-My-Header\'))\n\n for line in response.iter_lines():\n print(line)\n```\n\nThe context manager is required so that the response will reliably be closed.\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API.\n\nIf you need to access undocumented endpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other\nhttp verbs. Options on the client will be respected (such as retries) when making this request.\n\n```py\nimport httpx\n\nresponse = client.post(\n "/foo",\n cast_to=httpx.Response,\n body={"my_param": True},\n)\n\nprint(response.headers.get("x-foo"))\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You\ncan also get all the extra fields on the Pydantic model as a dict with\n[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).\n\n### Configuring the HTTP client\n\nYou can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:\n\n- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)\n- Custom [transports](https://www.python-httpx.org/advanced/transports/)\n- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality\n\n```python\nimport httpx\nfrom imagekitio import ImageKit, DefaultHttpxClient\n\nclient = ImageKit(\n # Or use the `IMAGE_KIT_BASE_URL` env var\n base_url="http://my.test.server.example.com:8083",\n http_client=DefaultHttpxClient(proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),\n)\n```\n\nYou can also customize the client on a per-request basis by using `with_options()`:\n\n```python\nclient.with_options(http_client=DefaultHttpxClient(...))\n```\n\n### Managing HTTP resources\n\nBy default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.\n\n```py\nfrom imagekitio import ImageKit\n\nwith ImageKit() as client:\n # make requests here\n ...\n\n# HTTP client is now closed\n```\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you\'ve upgraded to the latest version but aren\'t seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport imagekitio\nprint(imagekitio.__version__)\n```\n\n## Requirements\n\nPython 3.9 or higher.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', + "language": "python", + "content": "# Image Kit Python API library\n\n\n[![PyPI version](https://img.shields.io/pypi/v/imagekitio.svg?label=pypi%20(stable))](https://pypi.org/project/imagekitio/)\n\nThe Image Kit Python library provides convenient access to the Image Kit REST API from any Python 3.9+\napplication. The library includes type definitions for all request params and response fields,\nand offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n## Installation\n\n```sh\n# install from PyPI\npip install imagekitio\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\n\nresponse = client.files.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n)\nprint(response.video_codec)\n```\n\nWhile you can provide a `private_key` keyword argument,\nwe recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nto add `IMAGEKIT_PRIVATE_KEY=\"My Private Key\"` to your `.env` file\nso that your Private Key is not stored in source control.\n\n## Async usage\n\nSimply import `AsyncImageKit` instead of `ImageKit` and use `await` with each API call:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import AsyncImageKit\n\nclient = AsyncImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\n\nasync def main() -> None:\n response = await client.files.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n### With aiohttp\n\nBy default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.\n\nYou can enable this by installing `aiohttp`:\n\n```sh\n# install from PyPI\npip install imagekitio[aiohttp]\n```\n\nThen you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import DefaultAioHttpClient\nfrom imagekitio import AsyncImageKit\n\nasync def main() -> None:\n async with AsyncImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n http_client=DefaultAioHttpClient(),\n) as client:\n response = await client.files.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\n\n\n## Using types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:\n\n- Serializing back into JSON, `model.to_json()`\n- Converting to a dictionary, `model.to_dict()`\n\nTyped requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.\n\n\n\n## Nested params\n\nNested parameters are dictionaries, typed using `TypedDict`, for example:\n\n```python\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nresponse = client.files.upload(\n file=b\"Example data\",\n file_name=\"fileName\",\n transformation={\n \"post\": [{\n \"type\": \"thumbnail\",\n \"value\": \"w-150,h-150\",\n }, {\n \"protocol\": \"dash\",\n \"type\": \"abs\",\n \"value\": \"sr-240_360_480_720_1080\",\n }]\n },\n)\nprint(response.transformation)\n```\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.\n\n```python\nfrom pathlib import Path\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nclient.files.upload(\n file=Path(\"/path/to/file\"),\n file_name=\"fileName\",\n)\n```\n\nThe async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.\n\n## Handling errors\n\nWhen the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `imagekitio.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (that is, 4xx or 5xx\nresponse), a subclass of `imagekitio.APIStatusError` is raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `imagekitio.APIError`.\n\n```python\nimport imagekitio\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\ntry:\n client.files.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n )\nexcept imagekitio.APIConnectionError as e:\n print(\"The server could not be reached\")\n print(e.__cause__) # an underlying Exception, likely raised within httpx.\nexcept imagekitio.RateLimitError as e:\n print(\"A 429 status code was received; we should back off a bit.\")\nexcept imagekitio.APIStatusError as e:\n print(\"Another non-200-range status code was received\")\n print(e.status_code)\n print(e.response)\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors are automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors are all retried by default.\n\nYou can use the `max_retries` option to configure or disable retry settings:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # default is 2\n max_retries=0,\n)\n\n# Or, configure per-request:\nclient.with_options(max_retries = 5).files.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n)\n```\n\n### Timeouts\n\nBy default requests time out after 1 minute. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # 20 seconds (default is 1 minute)\n timeout=20.0,\n)\n\n# More granular control:\nclient = ImageKit(\n timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n)\n\n# Override per-request:\nclient.with_options(timeout = 5.0).files.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n)\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests that time out are [retried twice by default](#retries).\n\n\n\n## Advanced\n\n### Logging\n\nWe use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.\n\nYou can enable logging by setting the environment variable `IMAGE_KIT_LOG` to `info`.\n\n```shell\n$ export IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging.\n\n### How to tell whether `None` means `null` or missing\n\nIn an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:\n\n```py\nif response.my_field is None:\n if 'my_field' not in response.model_fields_set:\n print('Got json like {}, without a \"my_field\" key present at all.')\n else:\n print('Got json like {\"my_field\": null}.')\n```\n\n### Accessing raw response data (e.g. headers)\n\nThe \"raw\" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,\n\n```py\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\nresponse = client.files.with_raw_response.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n)\nprint(response.headers.get('X-My-Header'))\n\nfile = response.parse() # get the object that `files.upload()` would have returned\nprint(file.video_codec)\n```\n\nThese methods return an [`APIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) object.\n\nThe async client returns an [`AsyncAPIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.\n\n#### `.with_streaming_response`\n\nThe above interface eagerly reads the full response body when you make the request, which may not always be what you want.\n\nTo stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.\n\n```python\nwith client.files.with_streaming_response.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n) as response :\n print(response.headers.get('X-My-Header'))\n\n for line in response.iter_lines():\n print(line)\n```\n\nThe context manager is required so that the response will reliably be closed.\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API.\n\nIf you need to access undocumented endpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other\nhttp verbs. Options on the client will be respected (such as retries) when making this request.\n\n```py\nimport httpx\n\nresponse = client.post(\n \"/foo\",\n cast_to=httpx.Response,\n body={\"my_param\": True},\n)\n\nprint(response.headers.get(\"x-foo\"))\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You\ncan also get all the extra fields on the Pydantic model as a dict with\n[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).\n\n### Configuring the HTTP client\n\nYou can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:\n\n- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)\n- Custom [transports](https://www.python-httpx.org/advanced/transports/)\n- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality\n\n```python\nimport httpx\nfrom imagekitio import ImageKit, DefaultHttpxClient\n\nclient = ImageKit(\n # Or use the `IMAGE_KIT_BASE_URL` env var\n base_url=\"http://my.test.server.example.com:8083\",\n http_client=DefaultHttpxClient(proxy=\"http://my.test.proxy.example.com\", transport=httpx.HTTPTransport(local_address=\"0.0.0.0\")),\n)\n```\n\nYou can also customize the client on a per-request basis by using `with_options()`:\n\n```python\nclient.with_options(http_client=DefaultHttpxClient(...))\n```\n\n### Managing HTTP resources\n\nBy default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.\n\n```py\nfrom imagekitio import ImageKit\n\nwith ImageKit() as client:\n # make requests here\n ...\n\n# HTTP client is now closed\n```\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you've upgraded to the latest version but aren't seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport imagekitio\nprint(imagekitio.__version__)\n```\n\n## Requirements\n\nPython 3.9 or higher.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n" }, { - language: 'ruby', - content: - '# Image Kit Ruby API library\n\nThe Image Kit Ruby library provides convenient access to the Image Kit REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/imagekit-developer/imagekit-ruby#Sorbet) for usage with Sorbet. The standard library\'s `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nDocumentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/imagekitio).\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference).\n\n## Installation\n\nTo use this gem, install via Bundler by adding the following to your application\'s `Gemfile`:\n\n\n\n```ruby\ngem "imagekitio", "~> 0.0.1"\n```\n\n\n\n## Usage\n\n```ruby\nrequire "bundler/setup"\nrequire "imagekitio"\n\nimage_kit = Imagekitio::Client.new(\n private_key: ENV["IMAGEKIT_PRIVATE_KEY"], # This is the default and can be omitted\n password: ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"] # This is the default and can be omitted\n)\n\nresponse = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\nputs(response.videoCodec)\n```\n\n\n\n\n\n### File uploads\n\nRequest parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, [`StringIO`](https://rubyapi.org/3.2/o/stringio), or more.\n\n```ruby\nrequire "pathname"\n\n# Use `Pathname` to send the filename and/or avoid paging a large file into memory:\nresponse = image_kit.files.upload(file: Pathname("/path/to/file"))\n\n# Alternatively, pass file contents or a `StringIO` directly:\nresponse = image_kit.files.upload(file: File.read("/path/to/file"))\n\n# Or, to control the filename and/or content type:\nfile = Imagekitio::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…")\nresponse = image_kit.files.upload(file: file)\n\nputs(response.videoCodec)\n```\n\nNote that you can also pass a raw `IO` descriptor, but this disables retries, as the library can\'t be sure if the descriptor is a file or pipe (which cannot be rewound).\n\n### Handling errors\n\nWhen the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Imagekitio::Errors::APIError` will be thrown:\n\n```ruby\nbegin\n file = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n )\nrescue Imagekitio::Errors::APIConnectionError => e\n puts("The server could not be reached")\n puts(e.cause) # an underlying Exception, likely raised within `net/http`\nrescue Imagekitio::Errors::RateLimitError => e\n puts("A 429 status code was received; we should back off a bit.")\nrescue Imagekitio::Errors::APIStatusError => e\n puts("Another non-200-range status code was received")\n puts(e.status)\nend\n```\n\nError codes are as follows:\n\n| Cause | Error Type |\n| ---------------- | -------------------------- |\n| HTTP 400 | `BadRequestError` |\n| HTTP 401 | `AuthenticationError` |\n| HTTP 403 | `PermissionDeniedError` |\n| HTTP 404 | `NotFoundError` |\n| HTTP 409 | `ConflictError` |\n| HTTP 422 | `UnprocessableEntityError` |\n| HTTP 429 | `RateLimitError` |\n| HTTP >= 500 | `InternalServerError` |\n| Other HTTP error | `APIStatusError` |\n| Timeout | `APITimeoutError` |\n| Network error | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\n\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.\n\nYou can use the `max_retries` option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n max_retries: 0 # default is 2\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {max_retries: 5}\n)\n```\n\n### Timeouts\n\nBy default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n timeout: nil # default is 60\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {timeout: 5}\n)\n```\n\nOn timeout, `Imagekitio::Errors::APITimeoutError` is raised.\n\nNote that requests that time out are retried by default.\n\n## Advanced concepts\n\n### BaseModel\n\nAll parameter and response objects inherit from `Imagekitio::Internal::Type::BaseModel`, which provides several conveniences, including:\n\n1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.\n\n2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.\n\n3. Both instances and the classes themselves can be pretty-printed.\n\n4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.\n\n### Making custom or undocumented requests\n\n#### Undocumented properties\n\nYou can send undocumented parameters to any endpoint, and read undocumented response properties, like so:\n\nNote: the `extra_` parameters of the same name overrides the documented parameters.\n\n```ruby\nresponse =\n image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {\n extra_query: {my_query_parameter: value},\n extra_body: {my_body_parameter: value},\n extra_headers: {"my-header": value}\n }\n )\n\nputs(response[:my_undocumented_property])\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:\n\n```ruby\nresponse = client.request(\n method: :post,\n path: \'/undocumented/endpoint\',\n query: {"dog": "woof"},\n headers: {"useful-header": "interesting-value"},\n body: {"hello": "world"}\n)\n```\n\n### Concurrency & connection pooling\n\nThe `Imagekitio::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.\n\nEach instance of `Imagekitio::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.\n\nWhen all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.\n\nUnless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.\n\n## Sorbet\n\nThis library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.\n\nYou can provide typesafe request parameters like so:\n\n```ruby\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n```\n\nOr, equivalently:\n\n```ruby\n# Hashes work, but are not typesafe:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\n# You can also splat a full Params class:\nparams = Imagekitio::FileUploadParams.new(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\nimage_kit.files.upload(**params)\n```\n\n### Enums\n\nSince this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:\n\n```ruby\n# :all\nputs(Imagekitio::AssetListParams::FileType::ALL)\n\n# Revealed type: `T.all(Imagekitio::AssetListParams::FileType, Symbol)`\nT.reveal_type(Imagekitio::AssetListParams::FileType::ALL)\n```\n\nEnum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:\n\n```ruby\n# Using the enum constants preserves the tagged type information:\nimage_kit.assets.list(\n file_type: Imagekitio::AssetListParams::FileType::ALL,\n # …\n)\n\n# Literal values are also permissible:\nimage_kit.assets.list(\n file_type: :all,\n # …\n)\n```\n\n## Versioning\n\nThis package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.\n\nThis package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.\n\n## Requirements\n\nRuby 3.2.0 or higher.\n\n## Contributing\n\nSee [the contributing documentation](https://github.com/imagekit-developer/imagekit-ruby/tree/master/CONTRIBUTING.md).\n', + "language": "ruby", + "content": "# Image Kit Ruby API library\n\nThe Image Kit Ruby library provides convenient access to the Image Kit REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/imagekit-developer/imagekit-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nDocumentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/imagekitio).\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference).\n\n## Installation\n\nTo use this gem, install via Bundler by adding the following to your application's `Gemfile`:\n\n\n\n```ruby\ngem \"imagekitio\", \"~> 0.0.1\"\n```\n\n\n\n## Usage\n\n```ruby\nrequire \"bundler/setup\"\nrequire \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(\n private_key: ENV[\"IMAGEKIT_PRIVATE_KEY\"], # This is the default and can be omitted\n password: ENV[\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"] # This is the default and can be omitted\n)\n\nresponse = image_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\"\n)\n\nputs(response.videoCodec)\n```\n\n\n\n\n\n### File uploads\n\nRequest parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, [`StringIO`](https://rubyapi.org/3.2/o/stringio), or more.\n\n```ruby\nrequire \"pathname\"\n\n# Use `Pathname` to send the filename and/or avoid paging a large file into memory:\nresponse = image_kit.files.upload(file: Pathname(\"/path/to/file\"))\n\n# Alternatively, pass file contents or a `StringIO` directly:\nresponse = image_kit.files.upload(file: File.read(\"/path/to/file\"))\n\n# Or, to control the filename and/or content type:\nfile = Imagekitio::FilePart.new(File.read(\"/path/to/file\"), filename: \"/path/to/file\", content_type: \"…\")\nresponse = image_kit.files.upload(file: file)\n\nputs(response.videoCodec)\n```\n\nNote that you can also pass a raw `IO` descriptor, but this disables retries, as the library can't be sure if the descriptor is a file or pipe (which cannot be rewound).\n\n### Handling errors\n\nWhen the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Imagekitio::Errors::APIError` will be thrown:\n\n```ruby\nbegin\n file = image_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\"\n )\nrescue Imagekitio::Errors::APIConnectionError => e\n puts(\"The server could not be reached\")\n puts(e.cause) # an underlying Exception, likely raised within `net/http`\nrescue Imagekitio::Errors::RateLimitError => e\n puts(\"A 429 status code was received; we should back off a bit.\")\nrescue Imagekitio::Errors::APIStatusError => e\n puts(\"Another non-200-range status code was received\")\n puts(e.status)\nend\n```\n\nError codes are as follows:\n\n| Cause | Error Type |\n| ---------------- | -------------------------- |\n| HTTP 400 | `BadRequestError` |\n| HTTP 401 | `AuthenticationError` |\n| HTTP 403 | `PermissionDeniedError` |\n| HTTP 404 | `NotFoundError` |\n| HTTP 409 | `ConflictError` |\n| HTTP 422 | `UnprocessableEntityError` |\n| HTTP 429 | `RateLimitError` |\n| HTTP >= 500 | `InternalServerError` |\n| Other HTTP error | `APIStatusError` |\n| Timeout | `APITimeoutError` |\n| Network error | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\n\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.\n\nYou can use the `max_retries` option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n max_retries: 0 # default is 2\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\",\n request_options: {max_retries: 5}\n)\n```\n\n### Timeouts\n\nBy default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n timeout: nil # default is 60\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\",\n request_options: {timeout: 5}\n)\n```\n\nOn timeout, `Imagekitio::Errors::APITimeoutError` is raised.\n\nNote that requests that time out are retried by default.\n\n## Advanced concepts\n\n### BaseModel\n\nAll parameter and response objects inherit from `Imagekitio::Internal::Type::BaseModel`, which provides several conveniences, including:\n\n1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.\n\n2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.\n\n3. Both instances and the classes themselves can be pretty-printed.\n\n4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.\n\n### Making custom or undocumented requests\n\n#### Undocumented properties\n\nYou can send undocumented parameters to any endpoint, and read undocumented response properties, like so:\n\nNote: the `extra_` parameters of the same name overrides the documented parameters.\n\n```ruby\nresponse =\n image_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\",\n request_options: {\n extra_query: {my_query_parameter: value},\n extra_body: {my_body_parameter: value},\n extra_headers: {\"my-header\": value}\n }\n )\n\nputs(response[:my_undocumented_property])\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:\n\n```ruby\nresponse = client.request(\n method: :post,\n path: '/undocumented/endpoint',\n query: {\"dog\": \"woof\"},\n headers: {\"useful-header\": \"interesting-value\"},\n body: {\"hello\": \"world\"}\n)\n```\n\n### Concurrency & connection pooling\n\nThe `Imagekitio::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.\n\nEach instance of `Imagekitio::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.\n\nWhen all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.\n\nUnless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.\n\n## Sorbet\n\nThis library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.\n\nYou can provide typesafe request parameters like so:\n\n```ruby\nimage_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\"\n)\n```\n\nOr, equivalently:\n\n```ruby\n# Hashes work, but are not typesafe:\nimage_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\"\n)\n\n# You can also splat a full Params class:\nparams = Imagekitio::FileUploadParams.new(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\"\n)\nimage_kit.files.upload(**params)\n```\n\n### Enums\n\nSince this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide \"tagged symbols\" instead, which is always a primitive at runtime:\n\n```ruby\n# :all\nputs(Imagekitio::AssetListParams::FileType::ALL)\n\n# Revealed type: `T.all(Imagekitio::AssetListParams::FileType, Symbol)`\nT.reveal_type(Imagekitio::AssetListParams::FileType::ALL)\n```\n\nEnum parameters have a \"relaxed\" type, so you can either pass in enum constants or their literal value:\n\n```ruby\n# Using the enum constants preserves the tagged type information:\nimage_kit.assets.list(\n file_type: Imagekitio::AssetListParams::FileType::ALL,\n # …\n)\n\n# Literal values are also permissible:\nimage_kit.assets.list(\n file_type: :all,\n # …\n)\n```\n\n## Versioning\n\nThis package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.\n\nThis package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.\n\n## Requirements\n\nRuby 3.2.0 or higher.\n\n## Contributing\n\nSee [the contributing documentation](https://github.com/imagekit-developer/imagekit-ruby/tree/master/CONTRIBUTING.md).\n" }, { - language: 'terraform', - content: - '# Image Kit Terraform Provider\n\nThe [Image Kit Terraform provider](https://registry.terraform.io/providers/stainless-sdks/imagekit/latest/docs) provides convenient access to\nthe [Image Kit REST API](https://imagekit.io/docs/api-reference) from Terraform.\n\n\n\n## Requirements\n\nThis provider requires Terraform CLI 1.0 or later. You can [install it for your system](https://developer.hashicorp.com/terraform/install)\non Hashicorp\'s website.\n\n## Usage\n\nAdd the following to your `main.tf` file:\n\n\n\n```hcl\n# Declare the provider and version\nterraform {\n required_providers {\n SDK_ProviderTypeName = {\n source = "stainless-sdks/imagekit"\n version = "~> 0.0.1"\n }\n }\n}\n\n# Initialize the provider\nprovider "imagekit" {\n # Your ImageKit private API key (starts with `private_`).\n You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n private_key = "My Private Key" # or set IMAGEKIT_PRIVATE_KEY env variable\n # ImageKit uses your API key as username and ignores the password. \n The SDK sets a dummy value. You can ignore this field.\n password = "My Password" # or set OPTIONAL_IMAGEKIT_IGNORES_THIS env variable\n # Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\n You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\n Only required if you\'re using webhooks.\n webhook_secret = "My Webhook Secret" # or set IMAGEKIT_WEBHOOK_SECRET env variable\n}\n\n# Configure a resource\nresource "imagekit_account_origin" "example_account_origin" {\n access_key = "AKIAIOSFODNN7EXAMPLE"\n bucket = "product-images"\n name = "US S3 Storage"\n secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"\n type = "S3"\n base_url_for_canonical_header = "https://cdn.example.com"\n include_canonical_header = false\n prefix = "raw-assets"\n}\n```\n\n\n\nInitialize your project by running `terraform init` in the directory.\n\nAdditional examples can be found in the [./examples](./examples) folder within this repository, and you can\nrefer to the full documentation on [the Terraform Registry](https://registry.terraform.io/providers/stainless-sdks/imagekit/latest/docs).\n\n### Provider Options\nWhen you initialize the provider, the following options are supported. It is recommended to use environment variables for sensitive values like access tokens.\nIf an environment variable is provided, then the option does not need to be set in the terraform source.\n\n| Property | Environment variable | Required | Default value |\n| -------------- | -------------------------------- | -------- | -------------- |\n| private_key | `IMAGEKIT_PRIVATE_KEY` | true | — |\n| webhook_secret | `IMAGEKIT_WEBHOOK_SECRET` | false | — |\n| password | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-terraform/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', + "language": "terraform", + "content": "# Image Kit Terraform Provider\n\nThe [Image Kit Terraform provider](https://registry.terraform.io/providers/stainless-sdks/imagekit/latest/docs) provides convenient access to\nthe [Image Kit REST API](https://imagekit.io/docs/api-reference) from Terraform.\n\n\n\n## Requirements\n\nThis provider requires Terraform CLI 1.0 or later. You can [install it for your system](https://developer.hashicorp.com/terraform/install)\non Hashicorp's website.\n\n## Usage\n\nAdd the following to your `main.tf` file:\n\n\n\n```hcl\n# Declare the provider and version\nterraform {\n required_providers {\n SDK_ProviderTypeName = {\n source = \"stainless-sdks/imagekit\"\n version = \"~> 0.0.1\"\n }\n }\n}\n\n# Initialize the provider\nprovider \"imagekit\" {\n # Your ImageKit private API key (starts with `private_`).\n You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n private_key = \"My Private Key\" # or set IMAGEKIT_PRIVATE_KEY env variable\n # ImageKit uses your API key as username and ignores the password. \n The SDK sets a dummy value. You can ignore this field.\n password = \"My Password\" # or set OPTIONAL_IMAGEKIT_IGNORES_THIS env variable\n # Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\n You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\n Only required if you're using webhooks.\n webhook_secret = \"My Webhook Secret\" # or set IMAGEKIT_WEBHOOK_SECRET env variable\n}\n\n# Configure a resource\nresource \"imagekit_account_origin\" \"example_account_origin\" {\n access_key = \"AKIAIOSFODNN7EXAMPLE\"\n bucket = \"product-images\"\n name = \"US S3 Storage\"\n secret_key = \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\"\n type = \"S3\"\n base_url_for_canonical_header = \"https://cdn.example.com\"\n include_canonical_header = false\n prefix = \"raw-assets\"\n}\n```\n\n\n\nInitialize your project by running `terraform init` in the directory.\n\nAdditional examples can be found in the [./examples](./examples) folder within this repository, and you can\nrefer to the full documentation on [the Terraform Registry](https://registry.terraform.io/providers/stainless-sdks/imagekit/latest/docs).\n\n### Provider Options\nWhen you initialize the provider, the following options are supported. It is recommended to use environment variables for sensitive values like access tokens.\nIf an environment variable is provided, then the option does not need to be set in the terraform source.\n\n| Property | Environment variable | Required | Default value |\n| -------------- | -------------------------------- | -------- | -------------- |\n| private_key | `IMAGEKIT_PRIVATE_KEY` | true | — |\n| webhook_secret | `IMAGEKIT_WEBHOOK_SECRET` | false | — |\n| password | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `\"do_not_set\"` |\n\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-terraform/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n" }, { - language: 'typescript', - content: - "# Image Kit TypeScript API Library\n\n[![NPM version](https://img.shields.io/npm/v/@imagekit/nodejs.svg?label=npm%20(stable))](https://npmjs.org/package/@imagekit/nodejs) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@imagekit/nodejs)\n\nThis library provides convenient access to the Image Kit REST API from server-side TypeScript or JavaScript.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n```sh\nnpm install @imagekit/nodejs\n```\n\n\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n\n```js\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n});\n\nconsole.log(response.videoCodec);\n```\n\n\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst params: ImageKit.FileUploadParams = {\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n};\nconst response: ImageKit.FileUploadResponse = await client.files.upload(params);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed in many different forms:\n- `File` (or an object with the same structure)\n- a `fetch` `Response` (or an object with the same structure)\n- an `fs.ReadStream`\n- the return value of our `toFile` helper\n\n```ts\nimport fs from 'fs';\nimport ImageKit, { toFile } from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\n// If you have access to Node `fs` we recommend using `fs.createReadStream()`:\nawait client.files.upload({ file: fs.createReadStream('/path/to/file'), fileName: 'fileName' });\n\n// Or if you have the web `File` API you can pass a `File` instance:\nawait client.files.upload({ file: new File(['my bytes'], 'file'), fileName: 'fileName' });\n\n// You can also pass a `fetch` `Response`:\nawait client.files.upload({ file: await fetch('https://somesite/file'), fileName: 'fileName' });\n\n// Finally, if none of the above are convenient, you can use our `toFile` helper:\nawait client.files.upload({\n file: await toFile(Buffer.from('my bytes'), 'file'),\n fileName: 'fileName',\n});\nawait client.files.upload({\n file: await toFile(new Uint8Array([0, 1, 2]), 'file'),\n fileName: 'fileName',\n});\n```\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n\n```ts\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .catch(async (err) => {\n if (err instanceof ImageKit.APIError) {\n console.log(err.status); // 400\n console.log(err.name); // BadRequestError\n console.log(err.headers); // {server: 'nginx', ...}\n } else {\n throw err;\n }\n });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n\n```js\n// Configure the default for all requests:\nconst client = new ImageKit({\n maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n\n```ts\n// Configure the default for all requests:\nconst client = new ImageKit({\n timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n\n\n\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n\n```ts\nconst client = new ImageKit();\n\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: response, response: raw } = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(response.videoCodec);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `IMAGE_KIT_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new ImageKit({\n logger: logger.child({ name: 'ImageKit' }),\n logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.\nOptions on the client, such as retries, will be respected when making these requests.\n\n```ts\nawait client.post('/some/path', {\n body: { some_prop: 'foo' },\n query: { some_query_arg: 'bar' },\n});\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented\nparameter. This library doesn't validate at runtime that the request matches the type, so any extra values you\nsend will be sent as-is.\n\n```ts\nclient.files.upload({\n // ...\n // @ts-expect-error baz is not yet public\n baz: 'undocumented option',\n});\n```\n\nFor requests with the `GET` verb, any extra params will be in the query, all other requests will send the\nextra param in the body.\n\nIf you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may access the response object with `// @ts-expect-error` on\nthe response object, or cast the response object to the requisite type. Like the request params, we do not\nvalidate or strip extra properties from the response from the API.\n\n### Customizing the fetch client\n\nBy default, this library expects a global `fetch` function is defined.\n\nIf you want to use a different `fetch` function, you can either polyfill the global:\n\n```ts\nimport fetch from 'my-fetch';\n\nglobalThis.fetch = fetch;\n```\n\nOr pass it to the client:\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport fetch from 'my-fetch';\n\nconst client = new ImageKit({ fetch });\n```\n\n### Fetch options\n\nIf you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n // `RequestInit` options\n },\n});\n```\n\n#### Configuring proxies\n\nTo modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy\noptions to requests:\n\n **Node** [[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport * as undici from 'undici';\n\nconst proxyAgent = new undici.ProxyAgent('http://localhost:8888');\nconst client = new ImageKit({\n fetchOptions: {\n dispatcher: proxyAgent,\n },\n});\n```\n\n **Bun** [[docs](https://bun.sh/guides/http/proxy)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n proxy: 'http://localhost:8888',\n },\n});\n```\n\n **Deno** [[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]\n\n```ts\nimport ImageKit from 'npm:@imagekit/nodejs';\n\nconst httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });\nconst client = new ImageKit({\n fetchOptions: {\n client: httpClient,\n },\n});\n```\n\n## Frequently Asked Questions\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-nodejs/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n", - }, + "language": "typescript", + "content": "# Image Kit TypeScript API Library\n\n[![NPM version](https://img.shields.io/npm/v/@imagekit/nodejs.svg?label=npm%20(stable))](https://npmjs.org/package/@imagekit/nodejs) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@imagekit/nodejs)\n\nThis library provides convenient access to the Image Kit REST API from server-side TypeScript or JavaScript.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n```sh\nnpm install @imagekit/nodejs\n```\n\n\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n\n```js\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n});\n\nconsole.log(response.videoCodec);\n```\n\n\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst params: ImageKit.FileUploadParams = {\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n};\nconst response: ImageKit.FileUploadResponse = await client.files.upload(params);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed in many different forms:\n- `File` (or an object with the same structure)\n- a `fetch` `Response` (or an object with the same structure)\n- an `fs.ReadStream`\n- the return value of our `toFile` helper\n\n```ts\nimport fs from 'fs';\nimport ImageKit, { toFile } from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\n// If you have access to Node `fs` we recommend using `fs.createReadStream()`:\nawait client.files.upload({ file: fs.createReadStream('/path/to/file'), fileName: 'fileName' });\n\n// Or if you have the web `File` API you can pass a `File` instance:\nawait client.files.upload({ file: new File(['my bytes'], 'file'), fileName: 'fileName' });\n\n// You can also pass a `fetch` `Response`:\nawait client.files.upload({ file: await fetch('https://somesite/file'), fileName: 'fileName' });\n\n// Finally, if none of the above are convenient, you can use our `toFile` helper:\nawait client.files.upload({\n file: await toFile(Buffer.from('my bytes'), 'file'),\n fileName: 'fileName',\n});\nawait client.files.upload({\n file: await toFile(new Uint8Array([0, 1, 2]), 'file'),\n fileName: 'fileName',\n});\n```\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n\n```ts\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .catch(async (err) => {\n if (err instanceof ImageKit.APIError) {\n console.log(err.status); // 400\n console.log(err.name); // BadRequestError\n console.log(err.headers); // {server: 'nginx', ...}\n } else {\n throw err;\n }\n });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n\n```js\n// Configure the default for all requests:\nconst client = new ImageKit({\n maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n\n```ts\n// Configure the default for all requests:\nconst client = new ImageKit({\n timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n\n\n\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n\n```ts\nconst client = new ImageKit();\n\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: response, response: raw } = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(response.videoCodec);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `IMAGE_KIT_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new ImageKit({\n logger: logger.child({ name: 'ImageKit' }),\n logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.\nOptions on the client, such as retries, will be respected when making these requests.\n\n```ts\nawait client.post('/some/path', {\n body: { some_prop: 'foo' },\n query: { some_query_arg: 'bar' },\n});\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented\nparameter. This library doesn't validate at runtime that the request matches the type, so any extra values you\nsend will be sent as-is.\n\n```ts\nclient.files.upload({\n // ...\n // @ts-expect-error baz is not yet public\n baz: 'undocumented option',\n});\n```\n\nFor requests with the `GET` verb, any extra params will be in the query, all other requests will send the\nextra param in the body.\n\nIf you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may access the response object with `// @ts-expect-error` on\nthe response object, or cast the response object to the requisite type. Like the request params, we do not\nvalidate or strip extra properties from the response from the API.\n\n### Customizing the fetch client\n\nBy default, this library expects a global `fetch` function is defined.\n\nIf you want to use a different `fetch` function, you can either polyfill the global:\n\n```ts\nimport fetch from 'my-fetch';\n\nglobalThis.fetch = fetch;\n```\n\nOr pass it to the client:\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport fetch from 'my-fetch';\n\nconst client = new ImageKit({ fetch });\n```\n\n### Fetch options\n\nIf you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n // `RequestInit` options\n },\n});\n```\n\n#### Configuring proxies\n\nTo modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy\noptions to requests:\n\n **Node** [[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport * as undici from 'undici';\n\nconst proxyAgent = new undici.ProxyAgent('http://localhost:8888');\nconst client = new ImageKit({\n fetchOptions: {\n dispatcher: proxyAgent,\n },\n});\n```\n\n **Bun** [[docs](https://bun.sh/guides/http/proxy)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n proxy: 'http://localhost:8888',\n },\n});\n```\n\n **Deno** [[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]\n\n```ts\nimport ImageKit from 'npm:@imagekit/nodejs';\n\nconst httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });\nconst client = new ImageKit({\n fetchOptions: {\n client: httpClient,\n },\n});\n```\n\n## Frequently Asked Questions\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-nodejs/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n" + } ]; const INDEX_OPTIONS = { @@ -3412,18 +2894,21 @@ export class LocalDocsSearch { maxResults?: number; maxLength?: number; }): SearchResult { - const { query, language = 'typescript', detail = 'default', maxResults = 5, maxLength = 100_000 } = props; + const { + query, + language = 'typescript', + detail = 'default', + maxResults = 5, + maxLength = 100_000, + } = props; const useMarkdown = detail === 'verbose' || detail === 'high'; // Search both indices and merge results by score. // Filter prose hits so language-tagged content (READMEs and docs with // frontmatter) only matches the requested language. - const methodHits = this.methodIndex - .search(query) - .map((hit) => ({ ...hit, _kind: 'http_method' as const })); - const proseHits = this.proseIndex - .search(query) + const methodHits = this.methodIndex.search(query).map((hit) => ({ ...hit, _kind: 'http_method' as const })); + const proseHits = this.proseIndex.search(query) .filter((hit) => { const source = ((hit as Record)['_original'] as ProseChunk | undefined)?.source; if (!source) return true; diff --git a/packages/mcp-server/src/methods.ts b/packages/mcp-server/src/methods.ts index a2a4f930..c1633d66 100644 --- a/packages/mcp-server/src/methods.ts +++ b/packages/mcp-server/src/methods.ts @@ -7,294 +7,244 @@ export type SdkMethod = { fullyQualifiedName: string; httpMethod?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'query'; httpPath?: string; -}; +} -export const sdkMethods: SdkMethod[] = [ - { - clientCallName: 'client.customMetadataFields.create', - fullyQualifiedName: 'customMetadataFields.create', - httpMethod: 'post', - httpPath: '/v1/customMetadataFields', - }, - { - clientCallName: 'client.customMetadataFields.update', - fullyQualifiedName: 'customMetadataFields.update', - httpMethod: 'patch', - httpPath: '/v1/customMetadataFields/{id}', - }, - { - clientCallName: 'client.customMetadataFields.list', - fullyQualifiedName: 'customMetadataFields.list', - httpMethod: 'get', - httpPath: '/v1/customMetadataFields', - }, - { - clientCallName: 'client.customMetadataFields.delete', - fullyQualifiedName: 'customMetadataFields.delete', - httpMethod: 'delete', - httpPath: '/v1/customMetadataFields/{id}', - }, - { - clientCallName: 'client.files.update', - fullyQualifiedName: 'files.update', - httpMethod: 'patch', - httpPath: '/v1/files/{fileId}/details', - }, - { - clientCallName: 'client.files.delete', - fullyQualifiedName: 'files.delete', - httpMethod: 'delete', - httpPath: '/v1/files/{fileId}', - }, - { - clientCallName: 'client.files.copy', - fullyQualifiedName: 'files.copy', - httpMethod: 'post', - httpPath: '/v1/files/copy', - }, - { - clientCallName: 'client.files.get', - fullyQualifiedName: 'files.get', - httpMethod: 'get', - httpPath: '/v1/files/{fileId}/details', - }, - { - clientCallName: 'client.files.move', - fullyQualifiedName: 'files.move', - httpMethod: 'post', - httpPath: '/v1/files/move', - }, - { - clientCallName: 'client.files.rename', - fullyQualifiedName: 'files.rename', - httpMethod: 'put', - httpPath: '/v1/files/rename', - }, - { - clientCallName: 'client.files.upload', - fullyQualifiedName: 'files.upload', - httpMethod: 'post', - httpPath: '/api/v1/files/upload', - }, - { - clientCallName: 'client.files.bulk.delete', - fullyQualifiedName: 'files.bulk.delete', - httpMethod: 'post', - httpPath: '/v1/files/batch/deleteByFileIds', - }, - { - clientCallName: 'client.files.bulk.addTags', - fullyQualifiedName: 'files.bulk.addTags', - httpMethod: 'post', - httpPath: '/v1/files/addTags', - }, - { - clientCallName: 'client.files.bulk.removeAITags', - fullyQualifiedName: 'files.bulk.removeAITags', - httpMethod: 'post', - httpPath: '/v1/files/removeAITags', - }, - { - clientCallName: 'client.files.bulk.removeTags', - fullyQualifiedName: 'files.bulk.removeTags', - httpMethod: 'post', - httpPath: '/v1/files/removeTags', - }, - { - clientCallName: 'client.files.versions.list', - fullyQualifiedName: 'files.versions.list', - httpMethod: 'get', - httpPath: '/v1/files/{fileId}/versions', - }, - { - clientCallName: 'client.files.versions.delete', - fullyQualifiedName: 'files.versions.delete', - httpMethod: 'delete', - httpPath: '/v1/files/{fileId}/versions/{versionId}', - }, - { - clientCallName: 'client.files.versions.get', - fullyQualifiedName: 'files.versions.get', - httpMethod: 'get', - httpPath: '/v1/files/{fileId}/versions/{versionId}', - }, - { - clientCallName: 'client.files.versions.restore', - fullyQualifiedName: 'files.versions.restore', - httpMethod: 'put', - httpPath: '/v1/files/{fileId}/versions/{versionId}/restore', - }, - { - clientCallName: 'client.files.metadata.get', - fullyQualifiedName: 'files.metadata.get', - httpMethod: 'get', - httpPath: '/v1/files/{fileId}/metadata', - }, - { - clientCallName: 'client.files.metadata.getFromURL', - fullyQualifiedName: 'files.metadata.getFromURL', - httpMethod: 'get', - httpPath: '/v1/metadata', - }, - { - clientCallName: 'client.savedExtensions.create', - fullyQualifiedName: 'savedExtensions.create', - httpMethod: 'post', - httpPath: '/v1/saved-extensions', - }, - { - clientCallName: 'client.savedExtensions.update', - fullyQualifiedName: 'savedExtensions.update', - httpMethod: 'patch', - httpPath: '/v1/saved-extensions/{id}', - }, - { - clientCallName: 'client.savedExtensions.list', - fullyQualifiedName: 'savedExtensions.list', - httpMethod: 'get', - httpPath: '/v1/saved-extensions', - }, - { - clientCallName: 'client.savedExtensions.delete', - fullyQualifiedName: 'savedExtensions.delete', - httpMethod: 'delete', - httpPath: '/v1/saved-extensions/{id}', - }, - { - clientCallName: 'client.savedExtensions.get', - fullyQualifiedName: 'savedExtensions.get', - httpMethod: 'get', - httpPath: '/v1/saved-extensions/{id}', - }, - { - clientCallName: 'client.assets.list', - fullyQualifiedName: 'assets.list', - httpMethod: 'get', - httpPath: '/v1/files', - }, - { - clientCallName: 'client.cache.invalidation.create', - fullyQualifiedName: 'cache.invalidation.create', - httpMethod: 'post', - httpPath: '/v1/files/purge', - }, - { - clientCallName: 'client.cache.invalidation.get', - fullyQualifiedName: 'cache.invalidation.get', - httpMethod: 'get', - httpPath: '/v1/files/purge/{requestId}', - }, - { - clientCallName: 'client.folders.create', - fullyQualifiedName: 'folders.create', - httpMethod: 'post', - httpPath: '/v1/folder', - }, - { - clientCallName: 'client.folders.delete', - fullyQualifiedName: 'folders.delete', - httpMethod: 'delete', - httpPath: '/v1/folder', - }, - { - clientCallName: 'client.folders.copy', - fullyQualifiedName: 'folders.copy', - httpMethod: 'post', - httpPath: '/v1/bulkJobs/copyFolder', - }, - { - clientCallName: 'client.folders.move', - fullyQualifiedName: 'folders.move', - httpMethod: 'post', - httpPath: '/v1/bulkJobs/moveFolder', - }, - { - clientCallName: 'client.folders.rename', - fullyQualifiedName: 'folders.rename', - httpMethod: 'post', - httpPath: '/v1/bulkJobs/renameFolder', - }, - { - clientCallName: 'client.folders.job.get', - fullyQualifiedName: 'folders.job.get', - httpMethod: 'get', - httpPath: '/v1/bulkJobs/{jobId}', - }, - { - clientCallName: 'client.accounts.usage.get', - fullyQualifiedName: 'accounts.usage.get', - httpMethod: 'get', - httpPath: '/v1/accounts/usage', - }, - { - clientCallName: 'client.accounts.origins.create', - fullyQualifiedName: 'accounts.origins.create', - httpMethod: 'post', - httpPath: '/v1/accounts/origins', - }, - { - clientCallName: 'client.accounts.origins.update', - fullyQualifiedName: 'accounts.origins.update', - httpMethod: 'put', - httpPath: '/v1/accounts/origins/{id}', - }, - { - clientCallName: 'client.accounts.origins.list', - fullyQualifiedName: 'accounts.origins.list', - httpMethod: 'get', - httpPath: '/v1/accounts/origins', - }, - { - clientCallName: 'client.accounts.origins.delete', - fullyQualifiedName: 'accounts.origins.delete', - httpMethod: 'delete', - httpPath: '/v1/accounts/origins/{id}', - }, - { - clientCallName: 'client.accounts.origins.get', - fullyQualifiedName: 'accounts.origins.get', - httpMethod: 'get', - httpPath: '/v1/accounts/origins/{id}', - }, - { - clientCallName: 'client.accounts.urlEndpoints.create', - fullyQualifiedName: 'accounts.urlEndpoints.create', - httpMethod: 'post', - httpPath: '/v1/accounts/url-endpoints', - }, - { - clientCallName: 'client.accounts.urlEndpoints.update', - fullyQualifiedName: 'accounts.urlEndpoints.update', - httpMethod: 'put', - httpPath: '/v1/accounts/url-endpoints/{id}', - }, - { - clientCallName: 'client.accounts.urlEndpoints.list', - fullyQualifiedName: 'accounts.urlEndpoints.list', - httpMethod: 'get', - httpPath: '/v1/accounts/url-endpoints', - }, - { - clientCallName: 'client.accounts.urlEndpoints.delete', - fullyQualifiedName: 'accounts.urlEndpoints.delete', - httpMethod: 'delete', - httpPath: '/v1/accounts/url-endpoints/{id}', - }, - { - clientCallName: 'client.accounts.urlEndpoints.get', - fullyQualifiedName: 'accounts.urlEndpoints.get', - httpMethod: 'get', - httpPath: '/v1/accounts/url-endpoints/{id}', - }, - { - clientCallName: 'client.beta.v2.files.upload', - fullyQualifiedName: 'beta.v2.files.upload', - httpMethod: 'post', - httpPath: '/api/v2/files/upload', - }, - { clientCallName: 'client.webhooks.unsafeUnwrap', fullyQualifiedName: 'webhooks.unsafeUnwrap' }, - { clientCallName: 'client.webhooks.unwrap', fullyQualifiedName: 'webhooks.unwrap' }, -]; +export const sdkMethods: SdkMethod[] = [{ + clientCallName: 'client.customMetadataFields.create', + fullyQualifiedName: 'customMetadataFields.create', + httpMethod: 'post', + httpPath: '/v1/customMetadataFields', +},{ + clientCallName: 'client.customMetadataFields.update', + fullyQualifiedName: 'customMetadataFields.update', + httpMethod: 'patch', + httpPath: '/v1/customMetadataFields/{id}', +},{ + clientCallName: 'client.customMetadataFields.list', + fullyQualifiedName: 'customMetadataFields.list', + httpMethod: 'get', + httpPath: '/v1/customMetadataFields', +},{ + clientCallName: 'client.customMetadataFields.delete', + fullyQualifiedName: 'customMetadataFields.delete', + httpMethod: 'delete', + httpPath: '/v1/customMetadataFields/{id}', +},{ + clientCallName: 'client.files.update', + fullyQualifiedName: 'files.update', + httpMethod: 'patch', + httpPath: '/v1/files/{fileId}/details', +},{ + clientCallName: 'client.files.delete', + fullyQualifiedName: 'files.delete', + httpMethod: 'delete', + httpPath: '/v1/files/{fileId}', +},{ + clientCallName: 'client.files.copy', + fullyQualifiedName: 'files.copy', + httpMethod: 'post', + httpPath: '/v1/files/copy', +},{ + clientCallName: 'client.files.get', + fullyQualifiedName: 'files.get', + httpMethod: 'get', + httpPath: '/v1/files/{fileId}/details', +},{ + clientCallName: 'client.files.move', + fullyQualifiedName: 'files.move', + httpMethod: 'post', + httpPath: '/v1/files/move', +},{ + clientCallName: 'client.files.rename', + fullyQualifiedName: 'files.rename', + httpMethod: 'put', + httpPath: '/v1/files/rename', +},{ + clientCallName: 'client.files.upload', + fullyQualifiedName: 'files.upload', + httpMethod: 'post', + httpPath: '/api/v1/files/upload', +},{ + clientCallName: 'client.files.bulk.delete', + fullyQualifiedName: 'files.bulk.delete', + httpMethod: 'post', + httpPath: '/v1/files/batch/deleteByFileIds', +},{ + clientCallName: 'client.files.bulk.addTags', + fullyQualifiedName: 'files.bulk.addTags', + httpMethod: 'post', + httpPath: '/v1/files/addTags', +},{ + clientCallName: 'client.files.bulk.removeAITags', + fullyQualifiedName: 'files.bulk.removeAITags', + httpMethod: 'post', + httpPath: '/v1/files/removeAITags', +},{ + clientCallName: 'client.files.bulk.removeTags', + fullyQualifiedName: 'files.bulk.removeTags', + httpMethod: 'post', + httpPath: '/v1/files/removeTags', +},{ + clientCallName: 'client.files.versions.list', + fullyQualifiedName: 'files.versions.list', + httpMethod: 'get', + httpPath: '/v1/files/{fileId}/versions', +},{ + clientCallName: 'client.files.versions.delete', + fullyQualifiedName: 'files.versions.delete', + httpMethod: 'delete', + httpPath: '/v1/files/{fileId}/versions/{versionId}', +},{ + clientCallName: 'client.files.versions.get', + fullyQualifiedName: 'files.versions.get', + httpMethod: 'get', + httpPath: '/v1/files/{fileId}/versions/{versionId}', +},{ + clientCallName: 'client.files.versions.restore', + fullyQualifiedName: 'files.versions.restore', + httpMethod: 'put', + httpPath: '/v1/files/{fileId}/versions/{versionId}/restore', +},{ + clientCallName: 'client.files.metadata.get', + fullyQualifiedName: 'files.metadata.get', + httpMethod: 'get', + httpPath: '/v1/files/{fileId}/metadata', +},{ + clientCallName: 'client.files.metadata.getFromURL', + fullyQualifiedName: 'files.metadata.getFromURL', + httpMethod: 'get', + httpPath: '/v1/metadata', +},{ + clientCallName: 'client.savedExtensions.create', + fullyQualifiedName: 'savedExtensions.create', + httpMethod: 'post', + httpPath: '/v1/saved-extensions', +},{ + clientCallName: 'client.savedExtensions.update', + fullyQualifiedName: 'savedExtensions.update', + httpMethod: 'patch', + httpPath: '/v1/saved-extensions/{id}', +},{ + clientCallName: 'client.savedExtensions.list', + fullyQualifiedName: 'savedExtensions.list', + httpMethod: 'get', + httpPath: '/v1/saved-extensions', +},{ + clientCallName: 'client.savedExtensions.delete', + fullyQualifiedName: 'savedExtensions.delete', + httpMethod: 'delete', + httpPath: '/v1/saved-extensions/{id}', +},{ + clientCallName: 'client.savedExtensions.get', + fullyQualifiedName: 'savedExtensions.get', + httpMethod: 'get', + httpPath: '/v1/saved-extensions/{id}', +},{ + clientCallName: 'client.assets.list', + fullyQualifiedName: 'assets.list', + httpMethod: 'get', + httpPath: '/v1/files', +},{ + clientCallName: 'client.cache.invalidation.create', + fullyQualifiedName: 'cache.invalidation.create', + httpMethod: 'post', + httpPath: '/v1/files/purge', +},{ + clientCallName: 'client.cache.invalidation.get', + fullyQualifiedName: 'cache.invalidation.get', + httpMethod: 'get', + httpPath: '/v1/files/purge/{requestId}', +},{ + clientCallName: 'client.folders.create', + fullyQualifiedName: 'folders.create', + httpMethod: 'post', + httpPath: '/v1/folder', +},{ + clientCallName: 'client.folders.delete', + fullyQualifiedName: 'folders.delete', + httpMethod: 'delete', + httpPath: '/v1/folder', +},{ + clientCallName: 'client.folders.copy', + fullyQualifiedName: 'folders.copy', + httpMethod: 'post', + httpPath: '/v1/bulkJobs/copyFolder', +},{ + clientCallName: 'client.folders.move', + fullyQualifiedName: 'folders.move', + httpMethod: 'post', + httpPath: '/v1/bulkJobs/moveFolder', +},{ + clientCallName: 'client.folders.rename', + fullyQualifiedName: 'folders.rename', + httpMethod: 'post', + httpPath: '/v1/bulkJobs/renameFolder', +},{ + clientCallName: 'client.folders.job.get', + fullyQualifiedName: 'folders.job.get', + httpMethod: 'get', + httpPath: '/v1/bulkJobs/{jobId}', +},{ + clientCallName: 'client.accounts.usage.get', + fullyQualifiedName: 'accounts.usage.get', + httpMethod: 'get', + httpPath: '/v1/accounts/usage', +},{ + clientCallName: 'client.accounts.origins.create', + fullyQualifiedName: 'accounts.origins.create', + httpMethod: 'post', + httpPath: '/v1/accounts/origins', +},{ + clientCallName: 'client.accounts.origins.update', + fullyQualifiedName: 'accounts.origins.update', + httpMethod: 'put', + httpPath: '/v1/accounts/origins/{id}', +},{ + clientCallName: 'client.accounts.origins.list', + fullyQualifiedName: 'accounts.origins.list', + httpMethod: 'get', + httpPath: '/v1/accounts/origins', +},{ + clientCallName: 'client.accounts.origins.delete', + fullyQualifiedName: 'accounts.origins.delete', + httpMethod: 'delete', + httpPath: '/v1/accounts/origins/{id}', +},{ + clientCallName: 'client.accounts.origins.get', + fullyQualifiedName: 'accounts.origins.get', + httpMethod: 'get', + httpPath: '/v1/accounts/origins/{id}', +},{ + clientCallName: 'client.accounts.urlEndpoints.create', + fullyQualifiedName: 'accounts.urlEndpoints.create', + httpMethod: 'post', + httpPath: '/v1/accounts/url-endpoints', +},{ + clientCallName: 'client.accounts.urlEndpoints.update', + fullyQualifiedName: 'accounts.urlEndpoints.update', + httpMethod: 'put', + httpPath: '/v1/accounts/url-endpoints/{id}', +},{ + clientCallName: 'client.accounts.urlEndpoints.list', + fullyQualifiedName: 'accounts.urlEndpoints.list', + httpMethod: 'get', + httpPath: '/v1/accounts/url-endpoints', +},{ + clientCallName: 'client.accounts.urlEndpoints.delete', + fullyQualifiedName: 'accounts.urlEndpoints.delete', + httpMethod: 'delete', + httpPath: '/v1/accounts/url-endpoints/{id}', +},{ + clientCallName: 'client.accounts.urlEndpoints.get', + fullyQualifiedName: 'accounts.urlEndpoints.get', + httpMethod: 'get', + httpPath: '/v1/accounts/url-endpoints/{id}', +},{ + clientCallName: 'client.beta.v2.files.upload', + fullyQualifiedName: 'beta.v2.files.upload', + httpMethod: 'post', + httpPath: '/api/v2/files/upload', +},{ clientCallName: 'client.webhooks.unsafeUnwrap', fullyQualifiedName: 'webhooks.unsafeUnwrap' },{ clientCallName: 'client.webhooks.unwrap', fullyQualifiedName: 'webhooks.unwrap' }]; function allowedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] | undefined { if (!options) { @@ -309,9 +259,9 @@ function allowedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] if (options.codeAllowHttpGets) { // Add all methods that map to an HTTP GET - sdkMethods - .filter((method) => method.httpMethod === 'get') - .forEach((method) => allowedMethodsSet.add(method)); + sdkMethods.filter((method) => method.httpMethod === 'get').forEach( + (method) => allowedMethodsSet.add(method) + ); } if (options.codeAllowedMethods) { @@ -320,15 +270,13 @@ function allowedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] try { return new RegExp(pattern); } catch (e) { - throw new Error( - `Invalid regex pattern for allowed method: "${pattern}": ${e instanceof Error ? e.message : e}`, - ); + throw new Error(`Invalid regex pattern for allowed method: "${pattern}": ${e instanceof Error ? e.message : e}`); } }); - sdkMethods - .filter((method) => allowedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName))) - .forEach((method) => allowedMethodsSet.add(method)); + sdkMethods.filter((method) => + allowedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName)) + ).forEach((method) => allowedMethodsSet.add(method)); } allowedMethods = Array.from(allowedMethodsSet); @@ -343,14 +291,12 @@ function allowedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] try { return new RegExp(pattern); } catch (e) { - throw new Error( - `Invalid regex pattern for blocked method: "${pattern}": ${e instanceof Error ? e.message : e}`, - ); + throw new Error(`Invalid regex pattern for blocked method: "${pattern}": ${e instanceof Error ? e.message : e}`); } }); - allowedMethods = allowedMethods.filter( - (method) => !blockedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName)), + allowedMethods = allowedMethods.filter((method) => + !blockedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName)) ); } diff --git a/packages/mcp-server/src/options.ts b/packages/mcp-server/src/options.ts index f1518764..873ab8e8 100644 --- a/packages/mcp-server/src/options.ts +++ b/packages/mcp-server/src/options.ts @@ -31,46 +31,31 @@ export type McpCodeExecutionMode = 'stainless-sandbox' | 'local'; export function parseCLIOptions(): CLIOptions { const opts = yargs(hideBin(process.argv)) - .option('code-allow-http-gets', { - type: 'boolean', - description: - 'Allow all code tool methods that map to HTTP GET operations. If all code-allow-* flags are unset, then everything is allowed.', - }) + .option('code-allow-http-gets', { type: 'boolean', description: 'Allow all code tool methods that map to HTTP GET operations. If all code-allow-* flags are unset, then everything is allowed.' }) .option('code-allowed-methods', { type: 'string', array: true, - description: - 'Methods to explicitly allow for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.', + description: 'Methods to explicitly allow for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.', }) .option('code-blocked-methods', { type: 'string', array: true, - description: - 'Methods to explicitly block for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.', + description: 'Methods to explicitly block for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.', }) .option('code-execution-mode', { type: 'string', choices: ['stainless-sandbox', 'local'], default: 'stainless-sandbox', - description: - "Where to run code execution in code tool; 'stainless-sandbox' will execute code in Stainless-hosted sandboxes whereas 'local' will execute code locally on the MCP server machine.", - }) - .option('custom-instructions-path', { - type: 'string', - description: 'Path to custom instructions for the MCP server', + description: 'Where to run code execution in code tool; \'stainless-sandbox\' will execute code in Stainless-hosted sandboxes whereas \'local\' will execute code locally on the MCP server machine.', }) + .option('custom-instructions-path', { type: 'string', description: 'Path to custom instructions for the MCP server' }) .option('debug', { type: 'boolean', description: 'Enable debug logging' }) - .option('docs-dir', { - type: 'string', - description: - 'Path to a directory of local documentation files (markdown/JSON) to include in local docs search.', - }) + .option('docs-dir', { type: 'string', description: 'Path to a directory of local documentation files (markdown/JSON) to include in local docs search.' }) .option('docs-search-mode', { type: 'string', choices: ['stainless-api', 'local'], default: 'stainless-api', - description: - "Where to search documentation; 'stainless-api' uses the Stainless-hosted search API whereas 'local' uses an in-memory search index built from embedded SDK method data and optional local docs files.", + description: 'Where to search documentation; \'stainless-api\' uses the Stainless-hosted search API whereas \'local\' uses an in-memory search index built from embedded SDK method data and optional local docs files.', }) .option('log-format', { type: 'string', @@ -92,8 +77,7 @@ export function parseCLIOptions(): CLIOptions { .option('stainless-api-key', { type: 'string', default: readEnv('STAINLESS_API_KEY'), - description: - 'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.', + description: 'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.', }) .option('tools', { type: 'string', @@ -114,18 +98,15 @@ export function parseCLIOptions(): CLIOptions { const argv = opts.parseSync(); const shouldIncludeToolType = (toolType: 'code' | 'docs') => - argv.noTools?.includes(toolType) ? false - : argv.tools?.includes(toolType) ? true - : undefined; + argv.noTools?.includes(toolType) ? false + : argv.tools?.includes(toolType) ? true + : undefined; const includeCodeTool = shouldIncludeToolType('code'); const includeDocsTools = shouldIncludeToolType('docs'); const transport = argv.transport as 'stdio' | 'http'; - const logFormat = - argv.logFormat ? (argv.logFormat as 'json' | 'pretty') - : process.stderr.isTTY ? 'pretty' - : 'json'; + const logFormat = argv.logFormat ? argv.logFormat as 'json' | 'pretty' : (process.stderr.isTTY ? 'pretty' : 'json'); return { ...(includeCodeTool !== undefined && { includeCodeTool }), @@ -166,8 +147,8 @@ export function parseQueryOptions(defaultOptions: McpOptions, query: unknown): M const queryOptions = QueryOptions.parse(queryObject); let codeTool: boolean | undefined = - queryOptions.no_tools && queryOptions.no_tools?.includes('code') ? false - : queryOptions.tools?.includes('code') ? true + queryOptions.no_tools && queryOptions.no_tools?.includes("code") ? false + : queryOptions.tools?.includes("code") ? true : defaultOptions.includeCodeTool; let docsTools: boolean | undefined = diff --git a/packages/mcp-server/src/server.ts b/packages/mcp-server/src/server.ts index 4668d948..1d4c4b21 100644 --- a/packages/mcp-server/src/server.ts +++ b/packages/mcp-server/src/server.ts @@ -3,9 +3,7 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { - CallToolRequestSchema, - ListToolsRequestSchema, - SetLevelRequestSchema, + CallToolRequestSchema,ListToolsRequestSchema,SetLevelRequestSchema } from '@modelcontextprotocol/sdk/types.js'; import { ClientOptions } from '@imagekit/nodejs'; import ImageKit from '@imagekit/nodejs'; @@ -16,25 +14,24 @@ import { LocalDocsSearch } from './local-docs-search'; import { getInstructions } from './instructions'; import { McpOptions } from './options'; import { blockedMethodsForCodeTool } from './methods'; -import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from './types'; +import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from "./types" export const newMcpServer = async ({ stainlessApiKey, customInstructionsPath, }: { - stainlessApiKey?: string | undefined; - customInstructionsPath?: string | undefined; -}) => - new McpServer( - { - name: 'imagekit_nodejs_api', - version: '7.5.0', - }, - { - instructions: await getInstructions({ stainlessApiKey, customInstructionsPath }), - capabilities: { tools: {}, logging: {} }, - }, - ); + stainlessApiKey?: string | undefined, + customInstructionsPath?: string | undefined, +}) => new McpServer( + { + name: 'imagekit_nodejs_api', + version: '7.5.0', + }, + { + instructions: await getInstructions({stainlessApiKey, customInstructionsPath}), + capabilities: { tools: {}, logging: {} }, + } +); /** * Initializes the provided MCP Server with the given tools and handlers. @@ -56,15 +53,15 @@ export async function initMcpServer(params: { (message: string, ...rest: unknown[]) => { void server.sendLoggingMessage({ level, - data: { message, rest }, + data: {message, rest}, }); - }; + } const logger = { - debug: logAtLevel('debug'), - info: logAtLevel('info'), - warn: logAtLevel('warning'), - error: logAtLevel('error'), - }; + debug: logAtLevel("debug"), + info: logAtLevel("info"), + warn: logAtLevel("warning"), + error: logAtLevel("error"), + } if (params.mcpOptions?.docsSearchMode === 'local') { const docsDir = params.mcpOptions?.docsDir; @@ -81,13 +78,14 @@ export async function initMcpServer(params: { if (!_client) { try { _client = new ImageKit({ - logger, - ...params.clientOptions, - defaultHeaders: { - ...params.clientOptions?.defaultHeaders, - 'X-Stainless-MCP': 'true', - }, - }); + + logger, + ...params.clientOptions, + defaultHeaders: { + ...params.clientOptions?.defaultHeaders, + 'X-Stainless-MCP': 'true', + }, +}); if (_logLevel) { _client = _client.withOptions({ logLevel: _logLevel }); } @@ -120,12 +118,10 @@ export async function initMcpServer(params: { client = getClient(); } catch (error) { return { - content: [ - { - type: 'text' as const, - text: `Failed to initialize client: ${error instanceof Error ? error.message : String(error)}`, - }, - ], + content: [{ + type: 'text' as const, + text: `Failed to initialize client: ${error instanceof Error ? error.message : String(error)}`, + }], isError: true, }; } @@ -175,16 +171,17 @@ export async function initMcpServer(params: { /** * Selects the tools to include in the MCP Server based on the provided options. */ -export function selectTools(options?: McpOptions): McpTool[] { +export function selectTools( + options?: McpOptions +): McpTool[] { + const includedTools = []; if (options?.includeCodeTool ?? true) { - includedTools.push( - codeTool({ - blockedMethods: blockedMethodsForCodeTool(options), - codeExecutionMode: options?.codeExecutionMode ?? 'stainless-sandbox', - }), - ); + includedTools.push(codeTool({ + blockedMethods: blockedMethodsForCodeTool(options), + codeExecutionMode: options?.codeExecutionMode ?? 'stainless-sandbox', + })); } if (options?.includeDocsTools ?? true) { includedTools.push(docsSearchTool); @@ -195,14 +192,13 @@ export function selectTools(options?: McpOptions): McpTool[] { /** * Runs the provided handler with the given client and arguments. */ -export async function executeHandler({ - handler, - reqContext, - args, -}: { - handler: HandlerFunction; - reqContext: McpRequestContext; - args: Record | undefined; -}): Promise { - return await handler({ reqContext, args: args || {} }); +export async function executeHandler( + {handler, reqContext, args}: + { + handler: HandlerFunction; + reqContext: McpRequestContext; + args: Record | undefined; + } +): Promise { + return await handler({reqContext, args: args || {}}); } diff --git a/packages/mcp-server/src/types.ts b/packages/mcp-server/src/types.ts index 32be9c01..56d44ef4 100644 --- a/packages/mcp-server/src/types.ts +++ b/packages/mcp-server/src/types.ts @@ -4,43 +4,41 @@ import ImageKit from '@imagekit/nodejs'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; type TextContentBlock = { - type: 'text'; - text: string; -}; + type: "text", + text: string +} type ImageContentBlock = { - type: 'image'; - data: string; - mimeType: string; -}; + type: "image", + data: string, + mimeType: string +} type AudioContentBlock = { - type: 'audio'; - data: string; - mimeType: string; -}; + type: "audio", + data: string, + mimeType: string +} type ResourceContentBlock = { - type: 'resource'; - resource: - | { - uri: string; - mimeType: string; - text: string; - } - | { - uri: string; - mimeType: string; - blob: string; - }; -}; + type: "resource", + resource: { + uri: string, + mimeType: string, + text: string + } | { + uri: string, + mimeType: string, + blob: string + } +} export type ContentBlock = TextContentBlock | ImageContentBlock | AudioContentBlock | ResourceContentBlock; export type ToolCallResult = { content: ContentBlock[]; isError?: boolean; -}; +} export type McpRequestContext = { client: ImageKit; @@ -48,7 +46,7 @@ export type McpRequestContext = { upstreamClientEnvs?: Record | undefined; mcpSessionId?: string | undefined; mcpClientInfo?: { name: string; version: string } | undefined; -}; +} export type HandlerFunction = ({ reqContext, @@ -58,7 +56,9 @@ export type HandlerFunction = ({ args: Record | undefined; }) => Promise; -export function asTextContentResult(result: unknown): ToolCallResult { +export function asTextContentResult( + result: unknown, +): ToolCallResult { return { content: [ { @@ -69,18 +69,24 @@ export function asTextContentResult(result: unknown): ToolCallResult { }; } -export async function asBinaryContentResult(response: Response): Promise { +export async function asBinaryContentResult( + response: Response, +): Promise { const blob = await response.blob(); const mimeType = blob.type; const data = Buffer.from(await blob.arrayBuffer()).toString('base64'); if (mimeType.startsWith('image/')) { return { - content: [{ type: 'image', mimeType, data }], - }; + content: [ + {type: 'image', mimeType, data} + ] + } } else if (mimeType.startsWith('audio/')) { return { - content: [{ type: 'audio', mimeType, data }], - }; + content: [ + {type: 'audio', mimeType, data} + ] + } } else { return { content: [ @@ -98,7 +104,9 @@ export async function asBinaryContentResult(response: Response): Promise Running prettier --write" -# format things eslint didn't -PRETTIER_FILES="$(grep '\.\(js\|json\)$' "$FILE_LIST" || true)" +PRETTIER_FILES="$(grep '\.\([mc]?tsx?\|[mc]?jsx?\|json\)$' "$FILE_LIST" || true)" if ! [ -z "$PRETTIER_FILES" ]; then echo "$PRETTIER_FILES" | xargs ./node_modules/.bin/prettier \ - --write --cache --cache-strategy metadata --no-error-on-unmatched-pattern \ - '!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs' + --write --cache --cache-strategy metadata --no-error-on-unmatched-pattern fi diff --git a/scripts/format b/scripts/format index 7a756401..b1b2c17a 100755 --- a/scripts/format +++ b/scripts/format @@ -8,5 +8,4 @@ echo "==> Running eslint --fix" ./node_modules/.bin/eslint --fix . echo "==> Running prettier --write" -# format things eslint didn't -./node_modules/.bin/prettier --write --cache --cache-strategy metadata . '!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs' +./node_modules/.bin/prettier --write --cache --cache-strategy metadata . diff --git a/scripts/lint b/scripts/lint index 3ffb78a6..1f532548 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,6 +4,9 @@ set -e cd "$(dirname "$0")/.." +echo "==> Running prettier --check" +./node_modules/.bin/prettier --check . + echo "==> Running eslint" ./node_modules/.bin/eslint . diff --git a/src/api-promise.ts b/src/api-promise.ts index 8c775ee6..4e701286 100644 --- a/src/api-promise.ts +++ b/src/api-promise.ts @@ -1,2 +1,2 @@ /** @deprecated Import from ./core/api-promise instead */ -export * from './core/api-promise'; +export * from "./core/api-promise" \ No newline at end of file diff --git a/src/client.ts b/src/client.ts index 77700f16..c9f630e3 100644 --- a/src/client.ts +++ b/src/client.ts @@ -18,84 +18,20 @@ import * as Uploads from './core/uploads'; import * as API from './resources/index'; import { APIPromise } from './core/api-promise'; import { AssetListParams, AssetListResponse, Assets } from './resources/assets'; -import { - CustomMetadataField, - CustomMetadataFieldCreateParams, - CustomMetadataFieldDeleteResponse, - CustomMetadataFieldListParams, - CustomMetadataFieldListResponse, - CustomMetadataFieldUpdateParams, - CustomMetadataFields, -} from './resources/custom-metadata-fields'; -import { - SavedExtensionCreateParams, - SavedExtensionListResponse, - SavedExtensionUpdateParams, - SavedExtensions, -} from './resources/saved-extensions'; -import { - BaseWebhookEvent, - FileCreateEvent, - FileDeleteEvent, - FileUpdateEvent, - FileVersionCreateEvent, - FileVersionDeleteEvent, - UnsafeUnwrapWebhookEvent, - UnwrapWebhookEvent, - UploadPostTransformErrorEvent, - UploadPostTransformSuccessEvent, - UploadPreTransformErrorEvent, - UploadPreTransformSuccessEvent, - VideoTransformationAcceptedEvent, - VideoTransformationErrorEvent, - VideoTransformationReadyEvent, - Webhooks, -} from './resources/webhooks'; +import { CustomMetadataField, CustomMetadataFieldCreateParams, CustomMetadataFieldDeleteResponse, CustomMetadataFieldListParams, CustomMetadataFieldListResponse, CustomMetadataFieldUpdateParams, CustomMetadataFields } from './resources/custom-metadata-fields'; +import { SavedExtensionCreateParams, SavedExtensionListResponse, SavedExtensionUpdateParams, SavedExtensions } from './resources/saved-extensions'; +import { BaseWebhookEvent, FileCreateEvent, FileDeleteEvent, FileUpdateEvent, FileVersionCreateEvent, FileVersionDeleteEvent, UnsafeUnwrapWebhookEvent, UnwrapWebhookEvent, UploadPostTransformErrorEvent, UploadPostTransformSuccessEvent, UploadPreTransformErrorEvent, UploadPreTransformSuccessEvent, VideoTransformationAcceptedEvent, VideoTransformationErrorEvent, VideoTransformationReadyEvent, Webhooks } from './resources/webhooks'; import { Accounts } from './resources/accounts/accounts'; import { Beta } from './resources/beta/beta'; import { Cache } from './resources/cache/cache'; -import { - File, - FileCopyParams, - FileCopyResponse, - FileMoveParams, - FileMoveResponse, - FileRenameParams, - FileRenameResponse, - FileUpdateParams, - FileUpdateResponse, - FileUploadParams, - FileUploadResponse, - Files, - Folder, - Metadata, - UpdateFileRequest, -} from './resources/files/files'; -import { - FolderCopyParams, - FolderCopyResponse, - FolderCreateParams, - FolderCreateResponse, - FolderDeleteParams, - FolderDeleteResponse, - FolderMoveParams, - FolderMoveResponse, - FolderRenameParams, - FolderRenameResponse, - Folders, -} from './resources/folders/folders'; +import { File, FileCopyParams, FileCopyResponse, FileMoveParams, FileMoveResponse, FileRenameParams, FileRenameResponse, FileUpdateParams, FileUpdateResponse, FileUploadParams, FileUploadResponse, Files, Folder, Metadata, UpdateFileRequest } from './resources/files/files'; +import { FolderCopyParams, FolderCopyResponse, FolderCreateParams, FolderCreateResponse, FolderDeleteParams, FolderDeleteResponse, FolderMoveParams, FolderMoveResponse, FolderRenameParams, FolderRenameResponse, Folders } from './resources/folders/folders'; import { type Fetch } from './internal/builtin-types'; import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers'; import { FinalRequestOptions, RequestOptions } from './internal/request-options'; import { toBase64 } from './internal/utils/base64'; import { readEnv } from './internal/utils/env'; -import { - type LogLevel, - type Logger, - formatRequestDetails, - loggerFor, - parseLogLevel, -} from './internal/utils/log'; +import { type LogLevel, type Logger, formatRequestDetails, loggerFor, parseLogLevel } from './internal/utils/log'; import { isEmptyObj } from './internal/utils/values'; export interface ClientOptions { @@ -107,7 +43,7 @@ export interface ClientOptions { privateKey?: string | undefined; /** - * ImageKit uses your API key as username and ignores the password. + * ImageKit uses your API key as username and ignores the password. * The SDK sets a dummy value. You can ignore this field. * */ @@ -191,7 +127,7 @@ export interface ClientOptions { } /** - * API Client for interfacing with the Image Kit API. + * API Client for interfacing with the Image Kit API. */ export class ImageKit { privateKey: string; @@ -233,7 +169,7 @@ export class ImageKit { }: ClientOptions = {}) { if (privateKey === undefined) { throw new Errors.ImageKitError( - "The IMAGEKIT_PRIVATE_KEY environment variable is missing or empty; either provide it, or instantiate the ImageKit client with an privateKey option, like new ImageKit({ privateKey: 'My Private Key' }).", + 'The IMAGEKIT_PRIVATE_KEY environment variable is missing or empty; either provide it, or instantiate the ImageKit client with an privateKey option, like new ImageKit({ privateKey: \'My Private Key\' }).' ); } @@ -251,10 +187,7 @@ export class ImageKit { const defaultLogLevel = 'warn'; // Set default logLevel early so that we can log a warning in parseLogLevel. this.logLevel = defaultLogLevel; - this.logLevel = - parseLogLevel(options.logLevel, 'ClientOptions.logLevel', this) ?? - parseLogLevel(readEnv('IMAGE_KIT_LOG'), "process.env['IMAGE_KIT_LOG']", this) ?? - defaultLogLevel; + this.logLevel = parseLogLevel(options.logLevel, 'ClientOptions.logLevel', this) ?? parseLogLevel(readEnv('IMAGE_KIT_LOG'), 'process.env[\'IMAGE_KIT_LOG\']', this) ?? defaultLogLevel; this.fetchOptions = options.fetchOptions; this.maxRetries = options.maxRetries ?? 2; this.fetch = options.fetch ?? Shims.getDefaultFetch(); @@ -283,7 +216,7 @@ export class ImageKit { privateKey: this.privateKey, password: this.password, webhookSecret: this.webhookSecret, - ...options, + ...options }); return client; } @@ -296,7 +229,7 @@ export class ImageKit { } protected defaultQuery(): Record | undefined { - return this._options.defaultQuery; + return this._options.defaultQuery } protected validateHeaders({ values, nulls }: NullableHeaders) { @@ -307,9 +240,7 @@ export class ImageKit { return; } - throw new Error( - 'Could not resolve authentication method. Expected the privateKey or password to be set. Or for the "Authorization" headers to be explicitly omitted', - ); + throw new Error('Could not resolve authentication method. Expected the privateKey or password to be set. Or for the "Authorization" headers to be explicitly omitted') } protected async authHeaders(opts: FinalRequestOptions): Promise { @@ -321,9 +252,9 @@ export class ImageKit { return undefined; } - const credentials = `${this.privateKey}:${this.password}`; - const Authorization = `Basic ${toBase64(credentials)}`; - return buildHeaders([{ Authorization }]); + const credentials = `${this.privateKey}:${this.password}` + const Authorization = `Basic ${toBase64(credentials)}` + return buildHeaders([{ Authorization }]) } /** @@ -350,11 +281,7 @@ export class ImageKit { return Errors.APIError.generate(status, error, message, headers); } - buildURL( - path: string, - query: Record | null | undefined, - defaultBaseURL?: string | undefined, - ): string { + buildURL(path: string, query: Record | null | undefined, defaultBaseURL?: string | undefined): string { const baseURL = (!this.#baseURLOverridden() && defaultBaseURL) || this.baseURL; const url = isAbsoluteURL(path) ? @@ -442,9 +369,7 @@ export class ImageKit { await this.prepareOptions(options); - const { req, url, timeout } = await this.buildRequest(options, { - retryCount: maxRetries - retriesRemaining, - }); + const { req, url, timeout } = await this.buildRequest(options, { retryCount: maxRetries - retriesRemaining }); await this.prepareRequest(req, { url, options }); @@ -453,16 +378,7 @@ export class ImageKit { const retryLogStr = retryOfRequestLogID === undefined ? '' : `, retryOf: ${retryOfRequestLogID}`; const startTime = Date.now(); - loggerFor(this).debug( - `[${requestLogID}] sending request`, - formatRequestDetails({ - retryOfRequestLogID, - method: options.method, - url, - options, - headers: req.headers, - }), - ); + loggerFor(this).debug(`[${requestLogID}] sending request`, formatRequestDetails({ retryOfRequestLogID, method: options.method, url, options, headers: req.headers })); if (options.signal?.aborted) { throw new Errors.APIUserAbortError(); @@ -481,45 +397,21 @@ export class ImageKit { // deno throws "TypeError: error sending request for url (https://example/): client error (Connect): tcp connect error: Operation timed out (os error 60): Operation timed out (os error 60)" // undici throws "TypeError: fetch failed" with cause "ConnectTimeoutError: Connect Timeout Error (attempted address: example:443, timeout: 1ms)" // others do not provide enough information to distinguish timeouts from other connection errors - const isTimeout = - isAbortError(response) || - /timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : '')); + const isTimeout = isAbortError(response) || /timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : '')) if (retriesRemaining) { - loggerFor(this).info( - `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`, - ); - loggerFor(this).debug( - `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${retryMessage})`, - formatRequestDetails({ - retryOfRequestLogID, - url, - durationMs: headersTime - startTime, - message: response.message, - }), - ); + loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`) + loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${retryMessage})`, formatRequestDetails({ retryOfRequestLogID, url, durationMs: headersTime - startTime, message: response.message })); return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID); } - loggerFor(this).info( - `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - error; no more retries left`, - ); - loggerFor(this).debug( - `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (error; no more retries left)`, - formatRequestDetails({ - retryOfRequestLogID, - url, - durationMs: headersTime - startTime, - message: response.message, - }), - ); + loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - error; no more retries left`) + loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (error; no more retries left)`, formatRequestDetails({ retryOfRequestLogID, url, durationMs: headersTime - startTime, message: response.message })); if (isTimeout) { throw new Errors.APIConnectionTimeoutError(); } throw new Errors.APIConnectionError({ cause: response }); } - const responseInfo = `[${requestLogID}${retryLogStr}] ${req.method} ${url} ${ - response.ok ? 'succeeded' : 'failed' - } with status ${response.status} in ${headersTime - startTime}ms`; + const responseInfo = `[${requestLogID}${retryLogStr}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`; if (!response.ok) { const shouldRetry = await this.shouldRetry(response); @@ -528,60 +420,27 @@ export class ImageKit { // We don't need the body of this response. await Shims.CancelReadableStream(response.body); - loggerFor(this).info(`${responseInfo} - ${retryMessage}`); - loggerFor(this).debug( - `[${requestLogID}] response error (${retryMessage})`, - formatRequestDetails({ - retryOfRequestLogID, - url: response.url, - status: response.status, - headers: response.headers, - durationMs: headersTime - startTime, - }), - ); - return this.retryRequest( - options, - retriesRemaining, - retryOfRequestLogID ?? requestLogID, - response.headers, - ); + loggerFor(this).info(`${responseInfo} - ${retryMessage}`) + loggerFor(this).debug(`[${requestLogID}] response error (${retryMessage})`, formatRequestDetails({ retryOfRequestLogID, url: response.url, status: response.status, headers: response.headers, durationMs: headersTime - startTime })); + return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID, response.headers); } const retryMessage = shouldRetry ? `error; no more retries left` : `error; not retryable`; - loggerFor(this).info(`${responseInfo} - ${retryMessage}`); + loggerFor(this).info(`${responseInfo} - ${retryMessage}`) const errText = await response.text().catch((err: any) => castToError(err).message); const errJSON = safeJSON(errText) as any; const errMessage = errJSON ? undefined : errText; - loggerFor(this).debug( - `[${requestLogID}] response error (${retryMessage})`, - formatRequestDetails({ - retryOfRequestLogID, - url: response.url, - status: response.status, - headers: response.headers, - message: errMessage, - durationMs: Date.now() - startTime, - }), - ); + loggerFor(this).debug(`[${requestLogID}] response error (${retryMessage})`, formatRequestDetails({ retryOfRequestLogID, url: response.url, status: response.status, headers: response.headers, message: errMessage, durationMs: Date.now() - startTime })); const err = this.makeStatusError(response.status, errJSON, errMessage, response.headers); throw err; } - loggerFor(this).info(responseInfo); - loggerFor(this).debug( - `[${requestLogID}] response start`, - formatRequestDetails({ - retryOfRequestLogID, - url: response.url, - status: response.status, - headers: response.headers, - durationMs: headersTime - startTime, - }), - ); + loggerFor(this).info(responseInfo) + loggerFor(this).debug(`[${requestLogID}] response start`, formatRequestDetails({ retryOfRequestLogID, url: response.url, status: response.status, headers: response.headers, durationMs: headersTime - startTime })); return { response, options, controller, requestLogID, retryOfRequestLogID, startTime }; } @@ -598,9 +457,7 @@ export class ImageKit { const timeout = setTimeout(abort, ms); - const isReadableBody = - ((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) || - (typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body); + const isReadableBody = ((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) || (typeof options.body === "object" && options.body !== null && Symbol.asyncIterator in options.body); const fetchOptions: RequestInit = { signal: controller.signal as any, @@ -615,6 +472,7 @@ export class ImageKit { } try { + // use undefined this binding; fetch errors if bound to something else in browser/cloudflare return await this.fetch.call(undefined, url, fetchOptions); } finally { @@ -715,12 +573,11 @@ export class ImageKit { const req: FinalizedRequestInit = { method, headers: reqHeaders, - ...(options.signal && { signal: options.signal }), - ...((globalThis as any).ReadableStream && - body instanceof (globalThis as any).ReadableStream && { duplex: 'half' }), + ...(options.signal && { signal: options.signal}), + ...((globalThis as any).ReadableStream && body instanceof (globalThis as any).ReadableStream && { duplex: "half" }), ...(body && { body }), - ...((this.fetchOptions as any) ?? {}), - ...((options.fetchOptions as any) ?? {}), + ...(this.fetchOptions as any ?? {}), + ...(options.fetchOptions as any ?? {}), }; return { req, url, timeout: options.timeout }; @@ -745,17 +602,15 @@ export class ImageKit { const headers = buildHeaders([ idempotencyHeaders, - { - Accept: 'application/json', - 'User-Agent': this.getUserAgent(), - 'X-Stainless-Retry-Count': String(retryCount), - ...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}), - ...getPlatformHeaders(), - }, + {Accept: 'application/json', + 'User-Agent': this.getUserAgent(), + 'X-Stainless-Retry-Count': String(retryCount), + ...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}), + ...getPlatformHeaders()}, await this.authHeaders(options), this._options.defaultHeaders, bodyHeaders, - options.headers, + options.headers ]); this.validateHeaders(headers); @@ -782,9 +637,11 @@ export class ImageKit { ArrayBuffer.isView(body) || body instanceof ArrayBuffer || body instanceof DataView || - (typeof body === 'string' && + ( + typeof body === 'string' && // Preserve legacy string encoding behavior for now - headers.values.has('content-type')) || + headers.values.has('content-type') + ) || // `Blob` is superset of `File` ((globalThis as any).Blob && body instanceof (globalThis as any).Blob) || // `FormData` -> `multipart/form-data` @@ -815,7 +672,7 @@ export class ImageKit { } static ImageKit = this; - static DEFAULT_TIMEOUT = 60000; // 1 minute + static DEFAULT_TIMEOUT = 60000 // 1 minute static ImageKitError = Errors.ImageKitError; static APIError = Errors.APIError; @@ -856,107 +713,113 @@ ImageKit.Beta = Beta; ImageKit.Webhooks = Webhooks; export declare namespace ImageKit { - export type RequestOptions = Opts.RequestOptions; - - export { - CustomMetadataFields as CustomMetadataFields, - type CustomMetadataField as CustomMetadataField, - type CustomMetadataFieldListResponse as CustomMetadataFieldListResponse, - type CustomMetadataFieldDeleteResponse as CustomMetadataFieldDeleteResponse, - type CustomMetadataFieldCreateParams as CustomMetadataFieldCreateParams, - type CustomMetadataFieldUpdateParams as CustomMetadataFieldUpdateParams, - type CustomMetadataFieldListParams as CustomMetadataFieldListParams, - }; - - export { - Files as Files, - type File as File, - type Folder as Folder, - type Metadata as Metadata, - type UpdateFileRequest as UpdateFileRequest, - type FileUpdateResponse as FileUpdateResponse, - type FileCopyResponse as FileCopyResponse, - type FileMoveResponse as FileMoveResponse, - type FileRenameResponse as FileRenameResponse, - type FileUploadResponse as FileUploadResponse, - type FileUpdateParams as FileUpdateParams, - type FileCopyParams as FileCopyParams, - type FileMoveParams as FileMoveParams, - type FileRenameParams as FileRenameParams, - type FileUploadParams as FileUploadParams, - }; - - export { - SavedExtensions as SavedExtensions, - type SavedExtensionListResponse as SavedExtensionListResponse, - type SavedExtensionCreateParams as SavedExtensionCreateParams, - type SavedExtensionUpdateParams as SavedExtensionUpdateParams, - }; - - export { - Assets as Assets, - type AssetListResponse as AssetListResponse, - type AssetListParams as AssetListParams, - }; - - export { Cache as Cache }; - - export { - Folders as Folders, - type FolderCreateResponse as FolderCreateResponse, - type FolderDeleteResponse as FolderDeleteResponse, - type FolderCopyResponse as FolderCopyResponse, - type FolderMoveResponse as FolderMoveResponse, - type FolderRenameResponse as FolderRenameResponse, - type FolderCreateParams as FolderCreateParams, - type FolderDeleteParams as FolderDeleteParams, - type FolderCopyParams as FolderCopyParams, - type FolderMoveParams as FolderMoveParams, - type FolderRenameParams as FolderRenameParams, - }; - - export { Accounts as Accounts }; - - export { Beta as Beta }; - - export { - Webhooks as Webhooks, - type BaseWebhookEvent as BaseWebhookEvent, - type FileCreateEvent as FileCreateEvent, - type FileDeleteEvent as FileDeleteEvent, - type FileUpdateEvent as FileUpdateEvent, - type FileVersionCreateEvent as FileVersionCreateEvent, - type FileVersionDeleteEvent as FileVersionDeleteEvent, - type UploadPostTransformErrorEvent as UploadPostTransformErrorEvent, - type UploadPostTransformSuccessEvent as UploadPostTransformSuccessEvent, - type UploadPreTransformErrorEvent as UploadPreTransformErrorEvent, - type UploadPreTransformSuccessEvent as UploadPreTransformSuccessEvent, - type VideoTransformationAcceptedEvent as VideoTransformationAcceptedEvent, - type VideoTransformationErrorEvent as VideoTransformationErrorEvent, - type VideoTransformationReadyEvent as VideoTransformationReadyEvent, - type UnsafeUnwrapWebhookEvent as UnsafeUnwrapWebhookEvent, - type UnwrapWebhookEvent as UnwrapWebhookEvent, - }; - - export type BaseOverlay = API.BaseOverlay; - export type ExtensionConfig = API.ExtensionConfig; - export type Extensions = API.Extensions; - export type GetImageAttributesOptions = API.GetImageAttributesOptions; - export type ImageOverlay = API.ImageOverlay; - export type Overlay = API.Overlay; - export type OverlayPosition = API.OverlayPosition; - export type OverlayTiming = API.OverlayTiming; - export type ResponsiveImageAttributes = API.ResponsiveImageAttributes; - export type SavedExtension = API.SavedExtension; - export type SolidColorOverlay = API.SolidColorOverlay; - export type SolidColorOverlayTransformation = API.SolidColorOverlayTransformation; - export type SrcOptions = API.SrcOptions; - export type StreamingResolution = API.StreamingResolution; - export type SubtitleOverlay = API.SubtitleOverlay; - export type SubtitleOverlayTransformation = API.SubtitleOverlayTransformation; - export type TextOverlay = API.TextOverlay; - export type TextOverlayTransformation = API.TextOverlayTransformation; - export type Transformation = API.Transformation; - export type TransformationPosition = API.TransformationPosition; - export type VideoOverlay = API.VideoOverlay; -} + export type RequestOptions = Opts.RequestOptions; + + export { + CustomMetadataFields as CustomMetadataFields, + type CustomMetadataField as CustomMetadataField, + type CustomMetadataFieldListResponse as CustomMetadataFieldListResponse, + type CustomMetadataFieldDeleteResponse as CustomMetadataFieldDeleteResponse, + type CustomMetadataFieldCreateParams as CustomMetadataFieldCreateParams, + type CustomMetadataFieldUpdateParams as CustomMetadataFieldUpdateParams, + type CustomMetadataFieldListParams as CustomMetadataFieldListParams +}; + +export { + Files as Files, + type File as File, + type Folder as Folder, + type Metadata as Metadata, + type UpdateFileRequest as UpdateFileRequest, + type FileUpdateResponse as FileUpdateResponse, + type FileCopyResponse as FileCopyResponse, + type FileMoveResponse as FileMoveResponse, + type FileRenameResponse as FileRenameResponse, + type FileUploadResponse as FileUploadResponse, + type FileUpdateParams as FileUpdateParams, + type FileCopyParams as FileCopyParams, + type FileMoveParams as FileMoveParams, + type FileRenameParams as FileRenameParams, + type FileUploadParams as FileUploadParams +}; + +export { + SavedExtensions as SavedExtensions, + type SavedExtensionListResponse as SavedExtensionListResponse, + type SavedExtensionCreateParams as SavedExtensionCreateParams, + type SavedExtensionUpdateParams as SavedExtensionUpdateParams +}; + +export { + Assets as Assets, + type AssetListResponse as AssetListResponse, + type AssetListParams as AssetListParams +}; + +export { + Cache as Cache +}; + +export { + Folders as Folders, + type FolderCreateResponse as FolderCreateResponse, + type FolderDeleteResponse as FolderDeleteResponse, + type FolderCopyResponse as FolderCopyResponse, + type FolderMoveResponse as FolderMoveResponse, + type FolderRenameResponse as FolderRenameResponse, + type FolderCreateParams as FolderCreateParams, + type FolderDeleteParams as FolderDeleteParams, + type FolderCopyParams as FolderCopyParams, + type FolderMoveParams as FolderMoveParams, + type FolderRenameParams as FolderRenameParams +}; + +export { + Accounts as Accounts +}; + +export { + Beta as Beta +}; + +export { + Webhooks as Webhooks, + type BaseWebhookEvent as BaseWebhookEvent, + type FileCreateEvent as FileCreateEvent, + type FileDeleteEvent as FileDeleteEvent, + type FileUpdateEvent as FileUpdateEvent, + type FileVersionCreateEvent as FileVersionCreateEvent, + type FileVersionDeleteEvent as FileVersionDeleteEvent, + type UploadPostTransformErrorEvent as UploadPostTransformErrorEvent, + type UploadPostTransformSuccessEvent as UploadPostTransformSuccessEvent, + type UploadPreTransformErrorEvent as UploadPreTransformErrorEvent, + type UploadPreTransformSuccessEvent as UploadPreTransformSuccessEvent, + type VideoTransformationAcceptedEvent as VideoTransformationAcceptedEvent, + type VideoTransformationErrorEvent as VideoTransformationErrorEvent, + type VideoTransformationReadyEvent as VideoTransformationReadyEvent, + type UnsafeUnwrapWebhookEvent as UnsafeUnwrapWebhookEvent, + type UnwrapWebhookEvent as UnwrapWebhookEvent +}; + +export type BaseOverlay = API.BaseOverlay; +export type ExtensionConfig = API.ExtensionConfig; +export type Extensions = API.Extensions; +export type GetImageAttributesOptions = API.GetImageAttributesOptions; +export type ImageOverlay = API.ImageOverlay; +export type Overlay = API.Overlay; +export type OverlayPosition = API.OverlayPosition; +export type OverlayTiming = API.OverlayTiming; +export type ResponsiveImageAttributes = API.ResponsiveImageAttributes; +export type SavedExtension = API.SavedExtension; +export type SolidColorOverlay = API.SolidColorOverlay; +export type SolidColorOverlayTransformation = API.SolidColorOverlayTransformation; +export type SrcOptions = API.SrcOptions; +export type StreamingResolution = API.StreamingResolution; +export type SubtitleOverlay = API.SubtitleOverlay; +export type SubtitleOverlayTransformation = API.SubtitleOverlayTransformation; +export type TextOverlay = API.TextOverlay; +export type TextOverlayTransformation = API.TextOverlayTransformation; +export type Transformation = API.Transformation; +export type TransformationPosition = API.TransformationPosition; +export type VideoOverlay = API.VideoOverlay; + } diff --git a/src/core/api-promise.ts b/src/core/api-promise.ts index 53821f14..4ff22d1a 100644 --- a/src/core/api-promise.ts +++ b/src/core/api-promise.ts @@ -16,10 +16,7 @@ export class APIPromise extends Promise { constructor( client: ImageKit, private responsePromise: Promise, - private parseResponse: ( - client: ImageKit, - props: APIResponseProps, - ) => PromiseOrValue = defaultParseResponse, + private parseResponse: (client: ImageKit, props: APIResponseProps) => PromiseOrValue = defaultParseResponse, ) { super((resolve) => { // this is maybe a bit weird but this has to be a no-op to not implicitly @@ -31,9 +28,7 @@ export class APIPromise extends Promise { } _thenUnwrap(transform: (data: T, props: APIResponseProps) => U): APIPromise { - return new APIPromise(this.#client, this.responsePromise, async (client, props) => - transform(await this.parseResponse(client, props), props), - ); + return new APIPromise(this.#client, this.responsePromise, async (client, props) => transform(await this.parseResponse(client, props), props)); } /** diff --git a/src/core/error.ts b/src/core/error.ts index 47d1cc24..47b07699 100644 --- a/src/core/error.ts +++ b/src/core/error.ts @@ -2,13 +2,10 @@ import { castToError } from '../internal/errors'; -export class ImageKitError extends Error {} +export class ImageKitError extends Error { +} -export class APIError< - TStatus extends number | undefined = number | undefined, - THeaders extends Headers | undefined = Headers | undefined, - TError extends Object | undefined = Object | undefined, -> extends ImageKitError { +export class APIError extends ImageKitError { /** HTTP status for the response that caused the error */ readonly status: TStatus; /** HTTP headers for the response that caused the error */ @@ -16,6 +13,9 @@ export class APIError< /** JSON body of the response that caused the error */ readonly error: TError; + + ; + constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) { super(`${APIError.makeMessage(status, error, message)}`); this.status = status; @@ -26,8 +26,7 @@ export class APIError< private static makeMessage(status: number | undefined, error: any, message: string | undefined) { const msg = error?.message ? - typeof error.message === 'string' ? - error.message + typeof error.message === 'string' ? error.message : JSON.stringify(error.message) : error ? JSON.stringify(error) : message; @@ -44,12 +43,7 @@ export class APIError< return '(no status code or body)'; } - static generate( - status: number | undefined, - errorResponse: Object | undefined, - message: string | undefined, - headers: Headers | undefined, - ): APIError { + static generate(status: number | undefined, errorResponse: Object | undefined, message: string | undefined, headers: Headers | undefined): APIError { if (!status || !headers) { return new APIConnectionError({ message, cause: castToError(errorResponse) }); } @@ -113,18 +107,26 @@ export class APIConnectionTimeoutError extends APIConnectionError { } } -export class BadRequestError extends APIError<400, Headers> {} +export class BadRequestError extends APIError<400, Headers> { +} -export class AuthenticationError extends APIError<401, Headers> {} +export class AuthenticationError extends APIError<401, Headers> { +} -export class PermissionDeniedError extends APIError<403, Headers> {} +export class PermissionDeniedError extends APIError<403, Headers> { +} -export class NotFoundError extends APIError<404, Headers> {} +export class NotFoundError extends APIError<404, Headers> { +} -export class ConflictError extends APIError<409, Headers> {} +export class ConflictError extends APIError<409, Headers> { +} -export class UnprocessableEntityError extends APIError<422, Headers> {} +export class UnprocessableEntityError extends APIError<422, Headers> { +} -export class RateLimitError extends APIError<429, Headers> {} +export class RateLimitError extends APIError<429, Headers> { +} -export class InternalServerError extends APIError {} +export class InternalServerError extends APIError { +} diff --git a/src/error.ts b/src/error.ts index fc55f46c..d0832d34 100644 --- a/src/error.ts +++ b/src/error.ts @@ -1,2 +1,2 @@ /** @deprecated Import from ./core/error instead */ -export * from './core/error'; +export * from "./core/error" \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 71734d88..5f81d419 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,18 +5,4 @@ export { ImageKit as default } from './client'; export { type Uploadable, toFile } from './core/uploads'; export { APIPromise } from './core/api-promise'; export { ImageKit, type ClientOptions } from './client'; -export { - ImageKitError, - APIError, - APIConnectionError, - APIConnectionTimeoutError, - APIUserAbortError, - NotFoundError, - ConflictError, - RateLimitError, - BadRequestError, - AuthenticationError, - InternalServerError, - PermissionDeniedError, - UnprocessableEntityError, -} from './core/error'; +export { ImageKitError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError } from './core/error'; diff --git a/src/internal/builtin-types.ts b/src/internal/builtin-types.ts index c23d3bde..6059d5db 100644 --- a/src/internal/builtin-types.ts +++ b/src/internal/builtin-types.ts @@ -1,20 +1,23 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export type Fetch = (input: string | URL | Request, init?: RequestInit) => Promise; +export type Fetch = ( + input: string | URL | Request, + init?: RequestInit, +) => Promise /** * An alias to the builtin `RequestInit` type so we can * easily alias it in import statements if there are name clashes. - * - * https://developer.mozilla.org/docs/Web/API/RequestInit + * + * https://developer.mozilla.org/docs/Web/API/RequestInit */ type _RequestInit = RequestInit; /** * An alias to the builtin `Response` type so we can * easily alias it in import statements if there are name clashes. - * - * https://developer.mozilla.org/docs/Web/API/Response + * + * https://developer.mozilla.org/docs/Web/API/Response */ type _Response = Response; @@ -51,15 +54,7 @@ type _Array = Array; */ type _Record = Record; -export type { - _Array as Array, - _BodyInit as BodyInit, - _HeadersInit as HeadersInit, - _Record as Record, - _RequestInfo as RequestInfo, - _RequestInit as RequestInit, - _Response as Response, -}; +export type { _Array as Array, _BodyInit as BodyInit, _HeadersInit as HeadersInit, _Record as Record, _RequestInfo as RequestInfo, _RequestInit as RequestInit, _Response as Response }; /** * A copy of the builtin `EndingType` type as it isn't fully supported in certain diff --git a/src/internal/detect-platform.ts b/src/internal/detect-platform.ts index e82d95c9..394ede88 100644 --- a/src/internal/detect-platform.ts +++ b/src/internal/detect-platform.ts @@ -25,11 +25,7 @@ function getDetectedPlatform(): DetectedPlatform { if (typeof EdgeRuntime !== 'undefined') { return 'edge'; } - if ( - Object.prototype.toString.call( - typeof (globalThis as any).process !== 'undefined' ? (globalThis as any).process : 0, - ) === '[object process]' - ) { + if (Object.prototype.toString.call(typeof (globalThis as any).process !== 'undefined' ? (globalThis as any).process : 0) === '[object process]') { return 'node'; } return 'unknown'; diff --git a/src/internal/errors.ts b/src/internal/errors.ts index 82c7b14d..c14a742b 100644 --- a/src/internal/errors.ts +++ b/src/internal/errors.ts @@ -2,12 +2,12 @@ export function isAbortError(err: unknown) { return ( - typeof err === 'object' && - err !== null && - // Spec-compliant fetch implementations - (('name' in err && (err as any).name === 'AbortError') || + typeof err === 'object' && err !== null && ( + // Spec-compliant fetch implementations + ('name' in err && (err as any).name === 'AbortError') || // Expo fetch - ('message' in err && String((err as any).message).includes('FetchRequestCanceledException'))) + ('message' in err && String((err as any).message).includes('FetchRequestCanceledException')) + ) ); } @@ -24,10 +24,10 @@ export const castToError = (err: any): Error => { if (err.name) error.name = err.name; return error; } - } catch {} + } catch { } try { return new Error(JSON.stringify(err)); - } catch {} + } catch { } } return new Error(err); }; diff --git a/src/internal/headers.ts b/src/internal/headers.ts index c724a9d2..fa2ea2b9 100644 --- a/src/internal/headers.ts +++ b/src/internal/headers.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { isReadonlyArray } from './utils/values'; +import { isReadonlyArray } from "./utils/values"; type HeaderValue = string | undefined | null; export type HeadersLike = @@ -51,7 +51,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator(client: ImageKit, props: APIResponseProps): Promise { const { response, requestLogID, retryOfRequestLogID, startTime } = props; const body = await (async () => { + // fetch refuses to read the body when the status code is 204. if (response.status === 204) { return null as T; @@ -42,15 +43,6 @@ export async function defaultParseResponse(client: ImageKit, props: APIRespon const text = await response.text(); return text as unknown as T; })(); - loggerFor(client).debug( - `[${requestLogID}] response parsed`, - formatRequestDetails({ - retryOfRequestLogID, - url: response.url, - status: response.status, - body, - durationMs: Date.now() - startTime, - }), - ); + loggerFor(client).debug(`[${requestLogID}] response parsed`, formatRequestDetails({ retryOfRequestLogID, url: response.url, status: response.status, body, durationMs: Date.now() - startTime })); return body; } diff --git a/src/internal/request-options.ts b/src/internal/request-options.ts index 2aabf9aa..a8558b20 100644 --- a/src/internal/request-options.ts +++ b/src/internal/request-options.ts @@ -76,10 +76,14 @@ export type RequestOptions = { defaultBaseURL?: string | undefined; __binaryResponse?: boolean | undefined; + }; export type EncodedContent = { bodyHeaders: HeadersLike; body: BodyInit }; -export type RequestEncoder = (request: { headers: NullableHeaders; body: unknown }) => EncodedContent; +export type RequestEncoder = (request: { + headers: NullableHeaders; + body: unknown; +}) => EncodedContent; export const FallbackEncoder: RequestEncoder = ({ headers, body }) => { return { diff --git a/src/internal/shim-types.ts b/src/internal/shim-types.ts index 8ddf7b0a..accbf576 100644 --- a/src/internal/shim-types.ts +++ b/src/internal/shim-types.ts @@ -19,8 +19,8 @@ type _ConditionalNodeReadableStream = typeof globalThis extends { ReadableStream: any } ? never : _NodeReadableStream; type _ReadableStream = NeverToAny< - | ([0] extends [1 & _DOMReadableStream] ? never : _DOMReadableStream) - | ([0] extends [1 & _ConditionalNodeReadableStream] ? never : _ConditionalNodeReadableStream) + ([0] extends [1 & _DOMReadableStream] ? never : _DOMReadableStream) | + ([0] extends [1 & _ConditionalNodeReadableStream] ? never : _ConditionalNodeReadableStream) >; export type { _ReadableStream as ReadableStream }; diff --git a/src/internal/shims.ts b/src/internal/shims.ts index e4dc7102..1d378b65 100644 --- a/src/internal/shims.ts +++ b/src/internal/shims.ts @@ -27,9 +27,7 @@ export function makeReadableStream(...args: ReadableStreamArgs): ReadableStream if (typeof ReadableStream === 'undefined') { // Note: All of the platforms / runtimes we officially support already define // `ReadableStream` as a global, so this should only ever be hit on unsupported runtimes. - throw new Error( - '`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`', - ); + throw new Error('`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`'); } return new ReadableStream(...args); diff --git a/src/internal/to-file.ts b/src/internal/to-file.ts index 30eada32..c72a2b41 100644 --- a/src/internal/to-file.ts +++ b/src/internal/to-file.ts @@ -1,4 +1,4 @@ -import { BlobPart, getName, makeFile, isAsyncIterable } from './uploads'; +import { BlobPart, getName, makeFile, isAsyncIterable } from "./uploads"; import type { FilePropertyBag } from './builtin-types'; import { checkFileSupport } from './uploads'; @@ -65,11 +65,8 @@ const isResponseLike = (value: any): value is ResponseLike => typeof value.url === 'string' && typeof value.blob === 'function'; -export type ToFileInput = - | FileLike - | ResponseLike - | Exclude - | AsyncIterable; +export type ToFileInput = FileLike | ResponseLike | Exclude | AsyncIterable; + /** * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats @@ -119,7 +116,9 @@ export async function toFile( return makeFile(parts, name, options); } -async function getBytes(value: BlobLikePart | AsyncIterable): Promise> { +async function getBytes( + value: BlobLikePart | AsyncIterable, +): Promise> { let parts: Array = []; if ( typeof value === 'string' || @@ -152,3 +151,4 @@ function propsForError(value: unknown): string { const props = Object.getOwnPropertyNames(value); return `; props: [${props.map((p) => `"${p}"`).join(', ')}]`; } + diff --git a/src/internal/types.ts b/src/internal/types.ts index b668dfc0..c45fee32 100644 --- a/src/internal/types.ts +++ b/src/internal/types.ts @@ -7,40 +7,34 @@ export type KeysEnum = { [P in keyof Required]: true }; export type FinalizedRequestInit = RequestInit & { headers: Headers }; -type NotAny = [0] extends [1 & T] ? never : T; +type NotAny = [0] extends [(1 & T)] ? never : T; /** * Some environments overload the global fetch function, and Parameters only gets the last signature. */ -type OverloadedParameters = - T extends ( - { +type OverloadedParameters = T extends { + (...args: infer A): unknown; + (...args: infer B): unknown; + (...args: infer C): unknown; + (...args: infer D): unknown; +} + ? A | B | C | D + : T extends { (...args: infer A): unknown; (...args: infer B): unknown; (...args: infer C): unknown; - (...args: infer D): unknown; } - ) ? - A | B | C | D - : T extends ( - { - (...args: infer A): unknown; - (...args: infer B): unknown; - (...args: infer C): unknown; - } - ) ? - A | B | C - : T extends ( - { + ? A | B | C + : T extends { (...args: infer A): unknown; (...args: infer B): unknown; } - ) ? - A | B - : T extends (...args: infer A) => unknown ? A + ? A | B + : T extends (...args: infer A) => unknown + ? A : never; -/* eslint-disable */ + /** * These imports attempt to get types from a parent package's dependencies. * Unresolved bare specifiers can trigger [automatic type acquisition][1] in some projects, which @@ -63,19 +57,19 @@ type OverloadedParameters = * * [1]: https://www.typescriptlang.org/tsconfig/#typeAcquisition */ -/** @ts-ignore For users with \@types/node */ +/** @ts-ignore For users with \@types/node */ /* prettier-ignore */ type UndiciTypesRequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users with undici */ +/** @ts-ignore For users with undici */ /* prettier-ignore */ type UndiciRequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users with \@types/bun */ +/** @ts-ignore For users with \@types/bun */ /* prettier-ignore */ type BunRequestInit = globalThis.FetchRequestInit; -/** @ts-ignore For users with node-fetch@2 */ +/** @ts-ignore For users with node-fetch@2 */ /* prettier-ignore */ type NodeFetch2RequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */ +/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */ /* prettier-ignore */ type NodeFetch3RequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users who use Deno */ +/** @ts-ignore For users who use Deno */ /* prettier-ignore */ type FetchRequestInit = NonNullable[1]>; -/* eslint-enable */ + type RequestInits = | NotAny diff --git a/src/internal/utils/log.ts b/src/internal/utils/log.ts index 7da41295..697d265a 100644 --- a/src/internal/utils/log.ts +++ b/src/internal/utils/log.ts @@ -4,7 +4,7 @@ import { hasOwn } from './values'; import { type ImageKit } from '../../client'; import { RequestOptions } from '../request-options'; -type LogFn = (message: string, ...rest: unknown[]) => void; +type LogFn = (message: string, ...rest: unknown[]) => void export type Logger = { error: LogFn; warn: LogFn; @@ -21,22 +21,14 @@ const levelNumbers = { debug: 500, }; -export const parseLogLevel = ( - maybeLevel: string | undefined, - sourceName: string, - client: ImageKit, -): LogLevel | undefined => { +export const parseLogLevel = (maybeLevel: string | undefined, sourceName: string, client: ImageKit): LogLevel | undefined => { if (!maybeLevel) { return undefined; } if (hasOwn(levelNumbers, maybeLevel)) { return maybeLevel; - } - loggerFor(client).warn( - `${sourceName} was set to ${JSON.stringify(maybeLevel)}, expected one of ${JSON.stringify( - Object.keys(levelNumbers), - )}`, - ); + }; + loggerFor(client).warn(`${sourceName} was set to ${JSON.stringify(maybeLevel)}, expected one of ${JSON.stringify(Object.keys(levelNumbers))}`); return undefined; }; @@ -97,24 +89,11 @@ export const formatRequestDetails = (details: { body?: unknown; }) => { if (details.options) { - details.options = { ...details.options }; + details.options = {...details.options}; delete details.options['headers']; // redundant + leaks internals } if (details.headers) { - details.headers = Object.fromEntries( - (details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map( - ([name, value]) => [ - name, - ( - name.toLowerCase() === 'authorization' || - name.toLowerCase() === 'cookie' || - name.toLowerCase() === 'set-cookie' - ) ? - '***' - : value, - ], - ), - ); + details.headers = Object.fromEntries((details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map(([name, value]) => [name, name.toLowerCase() === 'authorization' || name.toLowerCase() === 'cookie' || name.toLowerCase() === 'set-cookie' ? '***' : value])) } if ('retryOfRequestLogID' in details) { if (details.retryOfRequestLogID) { @@ -122,5 +101,5 @@ export const formatRequestDetails = (details: { } delete details.retryOfRequestLogID; } - return details; -}; + return details +} diff --git a/src/internal/utils/uuid.ts b/src/internal/utils/uuid.ts index b0e53aaf..53708ba6 100644 --- a/src/internal/utils/uuid.ts +++ b/src/internal/utils/uuid.ts @@ -10,8 +10,10 @@ export let uuid4 = function () { return crypto.randomUUID(); } const u8 = new Uint8Array(1); - const randomByte = crypto ? () => crypto.getRandomValues(u8)[0]! : () => (Math.random() * 0xff) & 0xff; - return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => + const randomByte = crypto + ? () => crypto.getRandomValues(u8)[0]! + : () => (Math.random() * 0xff) & 0xff; + return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) => (+c ^ (randomByte() & (15 >> (+c / 4)))).toString(16), ); -}; +} diff --git a/src/resource.ts b/src/resource.ts index 363e3516..57a27a94 100644 --- a/src/resource.ts +++ b/src/resource.ts @@ -1,2 +1,2 @@ /** @deprecated Import from ./core/resource instead */ -export * from './core/resource'; +export * from "./core/resource" \ No newline at end of file diff --git a/src/resources/accounts/accounts.ts b/src/resources/accounts/accounts.ts index 82d1b238..5f561627 100644 --- a/src/resources/accounts/accounts.ts +++ b/src/resources/accounts/accounts.ts @@ -2,23 +2,9 @@ import { APIResource } from '../../core/resource'; import * as OriginsAPI from './origins'; -import { - OriginCreateParams, - OriginListResponse, - OriginRequest, - OriginResponse, - OriginUpdateParams, - Origins, -} from './origins'; +import { OriginCreateParams, OriginListResponse, OriginRequest, OriginResponse, OriginUpdateParams, Origins } from './origins'; import * as URLEndpointsAPI from './url-endpoints'; -import { - URLEndpointCreateParams, - URLEndpointListResponse, - URLEndpointRequest, - URLEndpointResponse, - URLEndpointUpdateParams, - URLEndpoints, -} from './url-endpoints'; +import { URLEndpointCreateParams, URLEndpointListResponse, URLEndpointRequest, URLEndpointResponse, URLEndpointUpdateParams, URLEndpoints } from './url-endpoints'; import * as UsageAPI from './usage'; import { Usage, UsageGetParams, UsageGetResponse } from './usage'; @@ -33,7 +19,11 @@ Accounts.Origins = Origins; Accounts.URLEndpoints = URLEndpoints; export declare namespace Accounts { - export { Usage as Usage, type UsageGetResponse as UsageGetResponse, type UsageGetParams as UsageGetParams }; + export { + Usage as Usage, + type UsageGetResponse as UsageGetResponse, + type UsageGetParams as UsageGetParams + }; export { Origins as Origins, @@ -41,7 +31,7 @@ export declare namespace Accounts { type OriginResponse as OriginResponse, type OriginListResponse as OriginListResponse, type OriginCreateParams as OriginCreateParams, - type OriginUpdateParams as OriginUpdateParams, + type OriginUpdateParams as OriginUpdateParams }; export { @@ -50,6 +40,6 @@ export declare namespace Accounts { type URLEndpointResponse as URLEndpointResponse, type URLEndpointListResponse as URLEndpointListResponse, type URLEndpointCreateParams as URLEndpointCreateParams, - type URLEndpointUpdateParams as URLEndpointUpdateParams, + type URLEndpointUpdateParams as URLEndpointUpdateParams }; } diff --git a/src/resources/accounts/index.ts b/src/resources/accounts/index.ts index 34a0246d..fee9bfbf 100644 --- a/src/resources/accounts/index.ts +++ b/src/resources/accounts/index.ts @@ -1,20 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Accounts } from './accounts'; -export { - Origins, - type OriginRequest, - type OriginResponse, - type OriginListResponse, - type OriginCreateParams, - type OriginUpdateParams, -} from './origins'; -export { - URLEndpoints, - type URLEndpointRequest, - type URLEndpointResponse, - type URLEndpointListResponse, - type URLEndpointCreateParams, - type URLEndpointUpdateParams, -} from './url-endpoints'; -export { Usage, type UsageGetResponse, type UsageGetParams } from './usage'; +export { Accounts } from './accounts';; +export { Origins, type OriginRequest, type OriginResponse, type OriginListResponse, type OriginCreateParams, type OriginUpdateParams } from './origins';; +export { URLEndpoints, type URLEndpointRequest, type URLEndpointResponse, type URLEndpointListResponse, type URLEndpointCreateParams, type URLEndpointUpdateParams } from './url-endpoints';; +export { Usage, type UsageGetResponse, type UsageGetParams } from './usage';; diff --git a/src/resources/accounts/origins.ts b/src/resources/accounts/origins.ts index f59a468e..41b9fdbb 100644 --- a/src/resources/accounts/origins.ts +++ b/src/resources/accounts/origins.ts @@ -8,7 +8,7 @@ import { path } from '../../internal/utils/path'; export class Origins extends APIResource { /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Creates a new origin and returns the origin object. * * @example @@ -29,7 +29,7 @@ export class Origins extends APIResource { } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Updates the origin identified by `id` and returns the updated origin object. * * @example @@ -51,7 +51,7 @@ export class Origins extends APIResource { } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Returns an array of all configured origins for the current account. * * @example @@ -65,7 +65,7 @@ export class Origins extends APIResource { } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Permanently removes the origin identified by `id`. If the origin is in use by * any URL‑endpoints, the API will return an error. * @@ -75,14 +75,11 @@ export class Origins extends APIResource { * ``` */ delete(id: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/accounts/origins/${id}`, { - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + return this._client.delete(path`/v1/accounts/origins/${id}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Retrieves the origin identified by `id`. * * @example @@ -100,15 +97,7 @@ export class Origins extends APIResource { /** * Schema for origin request resources. */ -export type OriginRequest = - | OriginRequest.S3 - | OriginRequest.S3Compatible - | OriginRequest.CloudinaryBackup - | OriginRequest.WebFolder - | OriginRequest.WebProxy - | OriginRequest.Gcs - | OriginRequest.AzureBlob - | OriginRequest.AkeneoPim; +export type OriginRequest = OriginRequest.S3 | OriginRequest.S3Compatible | OriginRequest.CloudinaryBackup | OriginRequest.WebFolder | OriginRequest.WebProxy | OriginRequest.Gcs | OriginRequest.AzureBlob | OriginRequest.AkeneoPim export namespace OriginRequest { export interface S3 { @@ -388,15 +377,7 @@ export namespace OriginRequest { /** * Origin object as returned by the API (sensitive fields removed). */ -export type OriginResponse = - | OriginResponse.S3 - | OriginResponse.S3Compatible - | OriginResponse.CloudinaryBackup - | OriginResponse.WebFolder - | OriginResponse.WebProxy - | OriginResponse.Gcs - | OriginResponse.AzureBlob - | OriginResponse.AkeneoPim; +export type OriginResponse = OriginResponse.S3 | OriginResponse.S3Compatible | OriginResponse.CloudinaryBackup | OriginResponse.WebFolder | OriginResponse.WebProxy | OriginResponse.Gcs | OriginResponse.AzureBlob | OriginResponse.AkeneoPim export namespace OriginResponse { export interface S3 { @@ -667,17 +648,9 @@ export namespace OriginResponse { } } -export type OriginListResponse = Array; +export type OriginListResponse = Array -export type OriginCreateParams = - | OriginCreateParams.S3 - | OriginCreateParams.S3Compatible - | OriginCreateParams.CloudinaryBackup - | OriginCreateParams.WebFolder - | OriginCreateParams.WebProxy - | OriginCreateParams.GoogleCloudStorageGcs - | OriginCreateParams.AzureBlobStorage - | OriginCreateParams.AkeneoPim; +export type OriginCreateParams = OriginCreateParams.S3 | OriginCreateParams.S3Compatible | OriginCreateParams.CloudinaryBackup | OriginCreateParams.WebFolder | OriginCreateParams.WebProxy | OriginCreateParams.GoogleCloudStorageGcs | OriginCreateParams.AzureBlobStorage | OriginCreateParams.AkeneoPim export declare namespace OriginCreateParams { export interface S3 { @@ -954,15 +927,7 @@ export declare namespace OriginCreateParams { } } -export type OriginUpdateParams = - | OriginUpdateParams.S3 - | OriginUpdateParams.S3Compatible - | OriginUpdateParams.CloudinaryBackup - | OriginUpdateParams.WebFolder - | OriginUpdateParams.WebProxy - | OriginUpdateParams.GoogleCloudStorageGcs - | OriginUpdateParams.AzureBlobStorage - | OriginUpdateParams.AkeneoPim; +export type OriginUpdateParams = OriginUpdateParams.S3 | OriginUpdateParams.S3Compatible | OriginUpdateParams.CloudinaryBackup | OriginUpdateParams.WebFolder | OriginUpdateParams.WebProxy | OriginUpdateParams.GoogleCloudStorageGcs | OriginUpdateParams.AzureBlobStorage | OriginUpdateParams.AkeneoPim export declare namespace OriginUpdateParams { export interface S3 { @@ -1245,6 +1210,6 @@ export declare namespace Origins { type OriginResponse as OriginResponse, type OriginListResponse as OriginListResponse, type OriginCreateParams as OriginCreateParams, - type OriginUpdateParams as OriginUpdateParams, + type OriginUpdateParams as OriginUpdateParams }; } diff --git a/src/resources/accounts/url-endpoints.ts b/src/resources/accounts/url-endpoints.ts index 7bd424c4..9afa7e0a 100644 --- a/src/resources/accounts/url-endpoints.ts +++ b/src/resources/accounts/url-endpoints.ts @@ -8,7 +8,7 @@ import { path } from '../../internal/utils/path'; export class URLEndpoints extends APIResource { /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Creates a new URL‑endpoint and returns the resulting object. * * @example @@ -24,7 +24,7 @@ export class URLEndpoints extends APIResource { } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Updates the URL‑endpoint identified by `id` and returns the updated object. * * @example @@ -35,16 +35,12 @@ export class URLEndpoints extends APIResource { * }); * ``` */ - update( - id: string, - body: URLEndpointUpdateParams, - options?: RequestOptions, - ): APIPromise { + update(id: string, body: URLEndpointUpdateParams, options?: RequestOptions): APIPromise { return this._client.put(path`/v1/accounts/url-endpoints/${id}`, { body, ...options }); } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Returns an array of all URL‑endpoints configured including the default * URL-endpoint generated by ImageKit during account creation. * @@ -59,7 +55,7 @@ export class URLEndpoints extends APIResource { } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Deletes the URL‑endpoint identified by `id`. You cannot delete the default * URL‑endpoint created by ImageKit during account creation. * @@ -69,14 +65,11 @@ export class URLEndpoints extends APIResource { * ``` */ delete(id: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/accounts/url-endpoints/${id}`, { - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + return this._client.delete(path`/v1/accounts/url-endpoints/${id}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Retrieves the URL‑endpoint identified by `id`. * * @example @@ -191,7 +184,7 @@ export namespace URLEndpointResponse { } } -export type URLEndpointListResponse = Array; +export type URLEndpointListResponse = Array export interface URLEndpointCreateParams { /** @@ -215,10 +208,7 @@ export interface URLEndpointCreateParams { /** * Configuration for third-party URL rewriting. */ - urlRewriter?: - | URLEndpointCreateParams.Cloudinary - | URLEndpointCreateParams.Imgix - | URLEndpointCreateParams.Akamai; + urlRewriter?: URLEndpointCreateParams.Cloudinary | URLEndpointCreateParams.Imgix | URLEndpointCreateParams.Akamai; } export namespace URLEndpointCreateParams { @@ -262,10 +252,7 @@ export interface URLEndpointUpdateParams { /** * Configuration for third-party URL rewriting. */ - urlRewriter?: - | URLEndpointUpdateParams.Cloudinary - | URLEndpointUpdateParams.Imgix - | URLEndpointUpdateParams.Akamai; + urlRewriter?: URLEndpointUpdateParams.Cloudinary | URLEndpointUpdateParams.Imgix | URLEndpointUpdateParams.Akamai; } export namespace URLEndpointUpdateParams { @@ -293,6 +280,6 @@ export declare namespace URLEndpoints { type URLEndpointResponse as URLEndpointResponse, type URLEndpointListResponse as URLEndpointListResponse, type URLEndpointCreateParams as URLEndpointCreateParams, - type URLEndpointUpdateParams as URLEndpointUpdateParams, + type URLEndpointUpdateParams as URLEndpointUpdateParams }; } diff --git a/src/resources/accounts/usage.ts b/src/resources/accounts/usage.ts index 87e703a4..7c2f7f1d 100644 --- a/src/resources/accounts/usage.ts +++ b/src/resources/accounts/usage.ts @@ -66,5 +66,8 @@ export interface UsageGetParams { } export declare namespace Usage { - export { type UsageGetResponse as UsageGetResponse, type UsageGetParams as UsageGetParams }; + export { + type UsageGetResponse as UsageGetResponse, + type UsageGetParams as UsageGetParams + }; } diff --git a/src/resources/assets.ts b/src/resources/assets.ts index 19a35adb..79b2ca27 100644 --- a/src/resources/assets.ts +++ b/src/resources/assets.ts @@ -12,15 +12,12 @@ export class Assets extends APIResource { * by generating a query string in a Lucene-like syntax and provide this generated * string as the value of the `searchQuery`. */ - list( - query: AssetListParams | null | undefined = {}, - options?: RequestOptions, - ): APIPromise { + list(query: AssetListParams | null | undefined = {}, options?: RequestOptions): APIPromise { return this._client.get('/v1/files', { query, ...options }); } } -export type AssetListResponse = Array; +export type AssetListResponse = Array export interface AssetListParams { /** @@ -73,21 +70,7 @@ export interface AssetListParams { * Sort the results by one of the supported fields in ascending or descending * order. */ - sort?: - | 'ASC_NAME' - | 'DESC_NAME' - | 'ASC_CREATED' - | 'DESC_CREATED' - | 'ASC_UPDATED' - | 'DESC_UPDATED' - | 'ASC_HEIGHT' - | 'DESC_HEIGHT' - | 'ASC_WIDTH' - | 'DESC_WIDTH' - | 'ASC_SIZE' - | 'DESC_SIZE' - | 'ASC_RELEVANCE' - | 'DESC_RELEVANCE'; + sort?: 'ASC_NAME' | 'DESC_NAME' | 'ASC_CREATED' | 'DESC_CREATED' | 'ASC_UPDATED' | 'DESC_UPDATED' | 'ASC_HEIGHT' | 'DESC_HEIGHT' | 'ASC_WIDTH' | 'DESC_WIDTH' | 'ASC_SIZE' | 'DESC_SIZE' | 'ASC_RELEVANCE' | 'DESC_RELEVANCE'; /** * Filter results by asset type. @@ -101,5 +84,8 @@ export interface AssetListParams { } export declare namespace Assets { - export { type AssetListResponse as AssetListResponse, type AssetListParams as AssetListParams }; + export { + type AssetListResponse as AssetListResponse, + type AssetListParams as AssetListParams + }; } diff --git a/src/resources/beta/beta.ts b/src/resources/beta/beta.ts index f8fa04c2..a0bc3ef3 100644 --- a/src/resources/beta/beta.ts +++ b/src/resources/beta/beta.ts @@ -11,5 +11,7 @@ export class Beta extends APIResource { Beta.V2 = V2; export declare namespace Beta { - export { V2 as V2 }; + export { + V2 as V2 + }; } diff --git a/src/resources/beta/index.ts b/src/resources/beta/index.ts index 2b3a43ce..46a22248 100644 --- a/src/resources/beta/index.ts +++ b/src/resources/beta/index.ts @@ -1,4 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Beta } from './beta'; -export { V2 } from './v2/index'; +export { Beta } from './beta';; +export { V2 } from './v2/index';; diff --git a/src/resources/beta/v2/files.ts b/src/resources/beta/v2/files.ts index a3daea86..43538fa7 100644 --- a/src/resources/beta/v2/files.ts +++ b/src/resources/beta/v2/files.ts @@ -51,13 +51,7 @@ export class Files extends APIResource { upload(body: FileUploadParams, options?: RequestOptions): APIPromise { const serializedBody = serializeUploadOptions(body); - return this._client.post( - '/api/v2/files/upload', - multipartFormRequestOptions( - { body: serializedBody, defaultBaseURL: 'https://upload.imagekit.io', ...options }, - this._client, - ), - ); + return this._client.post('/api/v2/files/upload', multipartFormRequestOptions({ body: serializedBody, defaultBaseURL: 'https://upload.imagekit.io', ...options }, this._client)); } } @@ -472,16 +466,7 @@ export interface FileUploadParams { /** * Array of response field keys to include in the API response body. */ - responseFields?: Array< - | 'tags' - | 'customCoordinates' - | 'isPrivateFile' - | 'embeddedMetadata' - | 'isPublished' - | 'customMetadata' - | 'metadata' - | 'selectedFieldsSchema' - >; + responseFields?: Array<'tags' | 'customCoordinates' | 'isPrivateFile' | 'embeddedMetadata' | 'isPublished' | 'customMetadata' | 'metadata' | 'selectedFieldsSchema'>; /** * Set the tags while uploading the file. Provide an array of tag strings (e.g. @@ -494,11 +479,11 @@ export interface FileUploadParams { /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. * - * - `pre` — applied before the file is uploaded to the Media Library. + * - `pre` — applied before the file is uploaded to the Media Library. * Useful for reducing file size or applying basic optimizations upfront (e.g., * resize, compress). * - * - `post` — applied immediately after upload. + * - `post` — applied immediately after upload. * Ideal for generating transformed versions (like video encodes or thumbnails) * in advance, so they're ready for delivery without delay. * @@ -530,11 +515,11 @@ export namespace FileUploadParams { /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. * - * - `pre` — applied before the file is uploaded to the Media Library. + * - `pre` — applied before the file is uploaded to the Media Library. * Useful for reducing file size or applying basic optimizations upfront (e.g., * resize, compress). * - * - `post` — applied immediately after upload. + * - `post` — applied immediately after upload. * Ideal for generating transformed versions (like video encodes or thumbnails) * in advance, so they're ready for delivery without delay. * @@ -542,16 +527,11 @@ export namespace FileUploadParams { */ export interface Transformation { /** - * List of transformations to apply _after_ the file is uploaded. + * List of transformations to apply _after_ the file is uploaded. * Each item must match one of the following types: `transformation`, * `gif-to-video`, `thumbnail`, `abs`. */ - post?: Array< - | Transformation.Transformation - | Transformation.GifToVideo - | Transformation.Thumbnail - | Transformation.Abs - >; + post?: Array; /** * Transformation string to apply before uploading the file to the Media Library. @@ -568,7 +548,7 @@ export namespace FileUploadParams { type: 'transformation'; /** - * Transformation string (e.g. `w-200,h-200`). + * Transformation string (e.g. `w-200,h-200`). * Same syntax as ImageKit URL-based transformations. */ value: string; @@ -581,7 +561,7 @@ export namespace FileUploadParams { type: 'gif-to-video'; /** - * Optional transformation string to apply to the output video. + * Optional transformation string to apply to the output video. * **Example**: `q-80` */ value?: string; @@ -594,7 +574,7 @@ export namespace FileUploadParams { type: 'thumbnail'; /** - * Optional transformation string. + * Optional transformation string. * **Example**: `w-150,h-150` */ value?: string; @@ -620,5 +600,8 @@ export namespace FileUploadParams { } export declare namespace Files { - export { type FileUploadResponse as FileUploadResponse, type FileUploadParams as FileUploadParams }; + export { + type FileUploadResponse as FileUploadResponse, + type FileUploadParams as FileUploadParams + }; } diff --git a/src/resources/beta/v2/index.ts b/src/resources/beta/v2/index.ts index bffa32ec..e53ebe72 100644 --- a/src/resources/beta/v2/index.ts +++ b/src/resources/beta/v2/index.ts @@ -1,4 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Files, type FileUploadResponse, type FileUploadParams } from './files'; -export { V2 } from './v2'; +export { Files, type FileUploadResponse, type FileUploadParams } from './files';; +export { V2 } from './v2';; diff --git a/src/resources/beta/v2/v2.ts b/src/resources/beta/v2/v2.ts index 3a047920..211cace8 100644 --- a/src/resources/beta/v2/v2.ts +++ b/src/resources/beta/v2/v2.ts @@ -14,6 +14,6 @@ export declare namespace V2 { export { Files as Files, type FileUploadResponse as FileUploadResponse, - type FileUploadParams as FileUploadParams, + type FileUploadParams as FileUploadParams }; } diff --git a/src/resources/cache/cache.ts b/src/resources/cache/cache.ts index b959081c..a8a36d84 100644 --- a/src/resources/cache/cache.ts +++ b/src/resources/cache/cache.ts @@ -2,12 +2,7 @@ import { APIResource } from '../../core/resource'; import * as InvalidationAPI from './invalidation'; -import { - Invalidation, - InvalidationCreateParams, - InvalidationCreateResponse, - InvalidationGetResponse, -} from './invalidation'; +import { Invalidation, InvalidationCreateParams, InvalidationCreateResponse, InvalidationGetResponse } from './invalidation'; export class Cache extends APIResource { invalidation: InvalidationAPI.Invalidation = new InvalidationAPI.Invalidation(this._client); @@ -20,6 +15,6 @@ export declare namespace Cache { Invalidation as Invalidation, type InvalidationCreateResponse as InvalidationCreateResponse, type InvalidationGetResponse as InvalidationGetResponse, - type InvalidationCreateParams as InvalidationCreateParams, + type InvalidationCreateParams as InvalidationCreateParams }; } diff --git a/src/resources/cache/index.ts b/src/resources/cache/index.ts index 3c9f4fc7..8d9a7c47 100644 --- a/src/resources/cache/index.ts +++ b/src/resources/cache/index.ts @@ -1,9 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Cache } from './cache'; -export { - Invalidation, - type InvalidationCreateResponse, - type InvalidationGetResponse, - type InvalidationCreateParams, -} from './invalidation'; +export { Cache } from './cache';; +export { Invalidation, type InvalidationCreateResponse, type InvalidationGetResponse, type InvalidationCreateParams } from './invalidation';; diff --git a/src/resources/cache/invalidation.ts b/src/resources/cache/invalidation.ts index d06b2701..6c1b7d4e 100644 --- a/src/resources/cache/invalidation.ts +++ b/src/resources/cache/invalidation.ts @@ -65,6 +65,6 @@ export declare namespace Invalidation { export { type InvalidationCreateResponse as InvalidationCreateResponse, type InvalidationGetResponse as InvalidationGetResponse, - type InvalidationCreateParams as InvalidationCreateParams, + type InvalidationCreateParams as InvalidationCreateParams }; } diff --git a/src/resources/custom-metadata-fields.ts b/src/resources/custom-metadata-fields.ts index 81081924..32348358 100644 --- a/src/resources/custom-metadata-fields.ts +++ b/src/resources/custom-metadata-fields.ts @@ -42,11 +42,7 @@ export class CustomMetadataFields extends APIResource { * }); * ``` */ - update( - id: string, - body: CustomMetadataFieldUpdateParams | null | undefined = {}, - options?: RequestOptions, - ): APIPromise { + update(id: string, body: CustomMetadataFieldUpdateParams | null | undefined = {}, options?: RequestOptions): APIPromise { return this._client.patch(path`/v1/customMetadataFields/${id}`, { body, ...options }); } @@ -66,10 +62,7 @@ export class CustomMetadataFields extends APIResource { * await client.customMetadataFields.list(); * ``` */ - list( - query: CustomMetadataFieldListParams | null | undefined = {}, - options?: RequestOptions, - ): APIPromise { + list(query: CustomMetadataFieldListParams | null | undefined = {}, options?: RequestOptions): APIPromise { return this._client.get('/v1/customMetadataFields', { query, ...options }); } @@ -168,9 +161,10 @@ export namespace CustomMetadataField { } } -export type CustomMetadataFieldListResponse = Array; +export type CustomMetadataFieldListResponse = Array -export interface CustomMetadataFieldDeleteResponse {} +export interface CustomMetadataFieldDeleteResponse { +} export interface CustomMetadataFieldCreateParams { /** @@ -341,6 +335,6 @@ export declare namespace CustomMetadataFields { type CustomMetadataFieldDeleteResponse as CustomMetadataFieldDeleteResponse, type CustomMetadataFieldCreateParams as CustomMetadataFieldCreateParams, type CustomMetadataFieldUpdateParams as CustomMetadataFieldUpdateParams, - type CustomMetadataFieldListParams as CustomMetadataFieldListParams, + type CustomMetadataFieldListParams as CustomMetadataFieldListParams }; } diff --git a/src/resources/files/bulk.ts b/src/resources/files/bulk.ts index 35dec26f..e66e9c9e 100644 --- a/src/resources/files/bulk.ts +++ b/src/resources/files/bulk.ts @@ -166,6 +166,6 @@ export declare namespace Bulk { type BulkDeleteParams as BulkDeleteParams, type BulkAddTagsParams as BulkAddTagsParams, type BulkRemoveAITagsParams as BulkRemoveAITagsParams, - type BulkRemoveTagsParams as BulkRemoveTagsParams, + type BulkRemoveTagsParams as BulkRemoveTagsParams }; } diff --git a/src/resources/files/files.ts b/src/resources/files/files.ts index ccf97c30..f6a1e93e 100644 --- a/src/resources/files/files.ts +++ b/src/resources/files/files.ts @@ -3,28 +3,11 @@ import { APIResource } from '../../core/resource'; import * as Shared from '../shared'; import * as BulkAPI from './bulk'; -import { - Bulk, - BulkAddTagsParams, - BulkAddTagsResponse, - BulkDeleteParams, - BulkDeleteResponse, - BulkRemoveAITagsParams, - BulkRemoveAITagsResponse, - BulkRemoveTagsParams, - BulkRemoveTagsResponse, -} from './bulk'; +import { Bulk, BulkAddTagsParams, BulkAddTagsResponse, BulkDeleteParams, BulkDeleteResponse, BulkRemoveAITagsParams, BulkRemoveAITagsResponse, BulkRemoveTagsParams, BulkRemoveTagsResponse } from './bulk'; import * as MetadataAPI from './metadata'; import { MetadataGetFromURLParams } from './metadata'; import * as VersionsAPI from './versions'; -import { - VersionDeleteParams, - VersionDeleteResponse, - VersionGetParams, - VersionListResponse, - VersionRestoreParams, - Versions, -} from './versions'; +import { VersionDeleteParams, VersionDeleteResponse, VersionGetParams, VersionListResponse, VersionRestoreParams, Versions } from './versions'; import { APIPromise } from '../../core/api-promise'; import { type Uploadable } from '../../core/uploads'; import { buildHeaders } from '../../internal/headers'; @@ -65,10 +48,7 @@ export class Files extends APIResource { * ``` */ delete(fileID: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/files/${fileID}`, { - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + return this._client.delete(path`/v1/files/${fileID}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } /** @@ -181,13 +161,7 @@ export class Files extends APIResource { upload(body: FileUploadParams, options?: RequestOptions): APIPromise { const serializedBody = serializeUploadOptions(body); - return this._client.post( - '/api/v1/files/upload', - multipartFormRequestOptions( - { body: serializedBody, defaultBaseURL: 'https://upload.imagekit.io', ...options }, - this._client, - ), - ); + return this._client.post('/api/v1/files/upload', multipartFormRequestOptions({ body: serializedBody, defaultBaseURL: 'https://upload.imagekit.io', ...options }, this._client)); } } @@ -719,9 +693,7 @@ export namespace Metadata { /** * Schema for update file update request. */ -export type UpdateFileRequest = - | UpdateFileRequest.UpdateFileDetails - | UpdateFileRequest.ChangePublicationStatus; +export type UpdateFileRequest = UpdateFileRequest.UpdateFileDetails | UpdateFileRequest.ChangePublicationStatus export namespace UpdateFileRequest { export interface UpdateFileDetails { @@ -823,9 +795,11 @@ export namespace FileUpdateResponse { } } -export interface FileCopyResponse {} +export interface FileCopyResponse { +} -export interface FileMoveResponse {} +export interface FileMoveResponse { +} export interface FileRenameResponse { /** @@ -1120,7 +1094,7 @@ export namespace FileUploadResponse { } } -export type FileUpdateParams = FileUpdateParams.UpdateFileDetails | FileUpdateParams.ChangePublicationStatus; +export type FileUpdateParams = FileUpdateParams.UpdateFileDetails | FileUpdateParams.ChangePublicationStatus export declare namespace FileUpdateParams { export interface UpdateFileDetails { @@ -1415,16 +1389,7 @@ export interface FileUploadParams { /** * Array of response field keys to include in the API response body. */ - responseFields?: Array< - | 'tags' - | 'customCoordinates' - | 'isPrivateFile' - | 'embeddedMetadata' - | 'isPublished' - | 'customMetadata' - | 'metadata' - | 'selectedFieldsSchema' - >; + responseFields?: Array<'tags' | 'customCoordinates' | 'isPrivateFile' | 'embeddedMetadata' | 'isPublished' | 'customMetadata' | 'metadata' | 'selectedFieldsSchema'>; /** * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a @@ -1447,11 +1412,11 @@ export interface FileUploadParams { /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. * - * - `pre` — applied before the file is uploaded to the Media Library. + * - `pre` — applied before the file is uploaded to the Media Library. * Useful for reducing file size or applying basic optimizations upfront (e.g., * resize, compress). * - * - `post` — applied immediately after upload. + * - `post` — applied immediately after upload. * Ideal for generating transformed versions (like video encodes or thumbnails) * in advance, so they're ready for delivery without delay. * @@ -1483,11 +1448,11 @@ export namespace FileUploadParams { /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. * - * - `pre` — applied before the file is uploaded to the Media Library. + * - `pre` — applied before the file is uploaded to the Media Library. * Useful for reducing file size or applying basic optimizations upfront (e.g., * resize, compress). * - * - `post` — applied immediately after upload. + * - `post` — applied immediately after upload. * Ideal for generating transformed versions (like video encodes or thumbnails) * in advance, so they're ready for delivery without delay. * @@ -1495,16 +1460,11 @@ export namespace FileUploadParams { */ export interface Transformation { /** - * List of transformations to apply _after_ the file is uploaded. + * List of transformations to apply _after_ the file is uploaded. * Each item must match one of the following types: `transformation`, * `gif-to-video`, `thumbnail`, `abs`. */ - post?: Array< - | Transformation.Transformation - | Transformation.GifToVideo - | Transformation.Thumbnail - | Transformation.Abs - >; + post?: Array; /** * Transformation string to apply before uploading the file to the Media Library. @@ -1521,7 +1481,7 @@ export namespace FileUploadParams { type: 'transformation'; /** - * Transformation string (e.g. `w-200,h-200`). + * Transformation string (e.g. `w-200,h-200`). * Same syntax as ImageKit URL-based transformations. */ value: string; @@ -1534,7 +1494,7 @@ export namespace FileUploadParams { type: 'gif-to-video'; /** - * Optional transformation string to apply to the output video. + * Optional transformation string to apply to the output video. * **Example**: `q-80` */ value?: string; @@ -1547,7 +1507,7 @@ export namespace FileUploadParams { type: 'thumbnail'; /** - * Optional transformation string. + * Optional transformation string. * **Example**: `w-150,h-150` */ value?: string; @@ -1590,7 +1550,7 @@ export declare namespace Files { type FileCopyParams as FileCopyParams, type FileMoveParams as FileMoveParams, type FileRenameParams as FileRenameParams, - type FileUploadParams as FileUploadParams, + type FileUploadParams as FileUploadParams }; export { @@ -1602,7 +1562,7 @@ export declare namespace Files { type BulkDeleteParams as BulkDeleteParams, type BulkAddTagsParams as BulkAddTagsParams, type BulkRemoveAITagsParams as BulkRemoveAITagsParams, - type BulkRemoveTagsParams as BulkRemoveTagsParams, + type BulkRemoveTagsParams as BulkRemoveTagsParams }; export { @@ -1611,8 +1571,10 @@ export declare namespace Files { type VersionDeleteResponse as VersionDeleteResponse, type VersionDeleteParams as VersionDeleteParams, type VersionGetParams as VersionGetParams, - type VersionRestoreParams as VersionRestoreParams, + type VersionRestoreParams as VersionRestoreParams }; - export { type MetadataGetFromURLParams as MetadataGetFromURLParams }; + export { + type MetadataGetFromURLParams as MetadataGetFromURLParams + }; } diff --git a/src/resources/files/index.ts b/src/resources/files/index.ts index de6d1ad7..f0318ae4 100644 --- a/src/resources/files/index.ts +++ b/src/resources/files/index.ts @@ -1,39 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { - Bulk, - type BulkDeleteResponse, - type BulkAddTagsResponse, - type BulkRemoveAITagsResponse, - type BulkRemoveTagsResponse, - type BulkDeleteParams, - type BulkAddTagsParams, - type BulkRemoveAITagsParams, - type BulkRemoveTagsParams, -} from './bulk'; -export { - Files, - type File, - type Folder, - type Metadata, - type UpdateFileRequest, - type FileUpdateResponse, - type FileCopyResponse, - type FileMoveResponse, - type FileRenameResponse, - type FileUploadResponse, - type FileUpdateParams, - type FileCopyParams, - type FileMoveParams, - type FileRenameParams, - type FileUploadParams, -} from './files'; -export { - Versions, - type VersionListResponse, - type VersionDeleteResponse, - type VersionDeleteParams, - type VersionGetParams, - type VersionRestoreParams, -} from './versions'; -export { type MetadataGetFromURLParams } from './metadata'; +export { Bulk, type BulkDeleteResponse, type BulkAddTagsResponse, type BulkRemoveAITagsResponse, type BulkRemoveTagsResponse, type BulkDeleteParams, type BulkAddTagsParams, type BulkRemoveAITagsParams, type BulkRemoveTagsParams } from './bulk';; +export { Files, type File, type Folder, type Metadata, type UpdateFileRequest, type FileUpdateResponse, type FileCopyResponse, type FileMoveResponse, type FileRenameResponse, type FileUploadResponse, type FileUpdateParams, type FileCopyParams, type FileMoveParams, type FileRenameParams, type FileUploadParams } from './files';; +export { Versions, type VersionListResponse, type VersionDeleteResponse, type VersionDeleteParams, type VersionGetParams, type VersionRestoreParams } from './versions';; +export { type MetadataGetFromURLParams } from './metadata';; diff --git a/src/resources/files/metadata.ts b/src/resources/files/metadata.ts index 1aa79caf..6d850825 100644 --- a/src/resources/files/metadata.ts +++ b/src/resources/files/metadata.ts @@ -48,5 +48,7 @@ export interface MetadataGetFromURLParams { } export declare namespace Metadata { - export { type MetadataGetFromURLParams as MetadataGetFromURLParams }; + export { + type MetadataGetFromURLParams as MetadataGetFromURLParams + }; } diff --git a/src/resources/files/versions.ts b/src/resources/files/versions.ts index 4cd160bd..125eee61 100644 --- a/src/resources/files/versions.ts +++ b/src/resources/files/versions.ts @@ -33,12 +33,8 @@ export class Versions extends APIResource { * ); * ``` */ - delete( - versionID: string, - params: VersionDeleteParams, - options?: RequestOptions, - ): APIPromise { - const { fileId } = params; + delete(versionID: string, params: VersionDeleteParams, options?: RequestOptions): APIPromise { + const { fileId } = params return this._client.delete(path`/v1/files/${fileId}/versions/${versionID}`, options); } @@ -53,7 +49,7 @@ export class Versions extends APIResource { * ``` */ get(versionID: string, params: VersionGetParams, options?: RequestOptions): APIPromise { - const { fileId } = params; + const { fileId } = params return this._client.get(path`/v1/files/${fileId}/versions/${versionID}`, options); } @@ -68,19 +64,16 @@ export class Versions extends APIResource { * ); * ``` */ - restore( - versionID: string, - params: VersionRestoreParams, - options?: RequestOptions, - ): APIPromise { - const { fileId } = params; + restore(versionID: string, params: VersionRestoreParams, options?: RequestOptions): APIPromise { + const { fileId } = params return this._client.put(path`/v1/files/${fileId}/versions/${versionID}/restore`, options); } } -export type VersionListResponse = Array; +export type VersionListResponse = Array -export interface VersionDeleteResponse {} +export interface VersionDeleteResponse { +} export interface VersionDeleteParams { /** @@ -112,6 +105,6 @@ export declare namespace Versions { type VersionDeleteResponse as VersionDeleteResponse, type VersionDeleteParams as VersionDeleteParams, type VersionGetParams as VersionGetParams, - type VersionRestoreParams as VersionRestoreParams, + type VersionRestoreParams as VersionRestoreParams }; } diff --git a/src/resources/folders/folders.ts b/src/resources/folders/folders.ts index 916e3042..56175222 100644 --- a/src/resources/folders/folders.ts +++ b/src/resources/folders/folders.ts @@ -95,9 +95,11 @@ export class Folders extends APIResource { } } -export interface FolderCreateResponse {} +export interface FolderCreateResponse { +} -export interface FolderDeleteResponse {} +export interface FolderDeleteResponse { +} /** * Job submitted successfully. A `jobId` will be returned. @@ -242,8 +244,11 @@ export declare namespace Folders { type FolderDeleteParams as FolderDeleteParams, type FolderCopyParams as FolderCopyParams, type FolderMoveParams as FolderMoveParams, - type FolderRenameParams as FolderRenameParams, + type FolderRenameParams as FolderRenameParams }; - export { Job as Job, type JobGetResponse as JobGetResponse }; + export { + Job as Job, + type JobGetResponse as JobGetResponse + }; } diff --git a/src/resources/folders/index.ts b/src/resources/folders/index.ts index 7759a7d4..81d62189 100644 --- a/src/resources/folders/index.ts +++ b/src/resources/folders/index.ts @@ -1,16 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { - Folders, - type FolderCreateResponse, - type FolderDeleteResponse, - type FolderCopyResponse, - type FolderMoveResponse, - type FolderRenameResponse, - type FolderCreateParams, - type FolderDeleteParams, - type FolderCopyParams, - type FolderMoveParams, - type FolderRenameParams, -} from './folders'; -export { Job, type JobGetResponse } from './job'; +export { Folders, type FolderCreateResponse, type FolderDeleteResponse, type FolderCopyResponse, type FolderMoveResponse, type FolderRenameResponse, type FolderCreateParams, type FolderDeleteParams, type FolderCopyParams, type FolderMoveParams, type FolderRenameParams } from './folders';; +export { Job, type JobGetResponse } from './job';; diff --git a/src/resources/folders/job.ts b/src/resources/folders/job.ts index a9fc92b6..8a908073 100644 --- a/src/resources/folders/job.ts +++ b/src/resources/folders/job.ts @@ -43,5 +43,7 @@ export interface JobGetResponse { } export declare namespace Job { - export { type JobGetResponse as JobGetResponse }; + export { + type JobGetResponse as JobGetResponse + }; } diff --git a/src/resources/saved-extensions.ts b/src/resources/saved-extensions.ts index ff39d734..f117de0a 100644 --- a/src/resources/saved-extensions.ts +++ b/src/resources/saved-extensions.ts @@ -50,11 +50,7 @@ export class SavedExtensions extends APIResource { * ); * ``` */ - update( - id: string, - body: SavedExtensionUpdateParams, - options?: RequestOptions, - ): APIPromise { + update(id: string, body: SavedExtensionUpdateParams, options?: RequestOptions): APIPromise { return this._client.patch(path`/v1/saved-extensions/${id}`, { body, ...options }); } @@ -81,10 +77,7 @@ export class SavedExtensions extends APIResource { * ``` */ delete(id: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/saved-extensions/${id}`, { - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + return this._client.delete(path`/v1/saved-extensions/${id}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } /** @@ -102,7 +95,7 @@ export class SavedExtensions extends APIResource { } } -export type SavedExtensionListResponse = Array; +export type SavedExtensionListResponse = Array export interface SavedExtensionCreateParams { /** @@ -144,6 +137,6 @@ export declare namespace SavedExtensions { export { type SavedExtensionListResponse as SavedExtensionListResponse, type SavedExtensionCreateParams as SavedExtensionCreateParams, - type SavedExtensionUpdateParams as SavedExtensionUpdateParams, + type SavedExtensionUpdateParams as SavedExtensionUpdateParams }; } diff --git a/src/resources/shared.ts b/src/resources/shared.ts index fcd500ad..3b07fe08 100644 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -1,5 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + export interface BaseOverlay { /** * Controls how the layer blends with the base image or underlying content. Maps to @@ -43,11 +44,7 @@ export interface BaseOverlay { * Configuration object for an extension (base extensions only, not saved extension * references). */ -export type ExtensionConfig = - | ExtensionConfig.RemoveBg - | ExtensionConfig.AutoTaggingExtension - | ExtensionConfig.AIAutoDescription - | ExtensionConfig.AITasks; +export type ExtensionConfig = ExtensionConfig.RemoveBg | ExtensionConfig.AutoTaggingExtension | ExtensionConfig.AIAutoDescription | ExtensionConfig.AITasks export namespace ExtensionConfig { export interface RemoveBg { @@ -367,13 +364,7 @@ export namespace ExtensionConfig { * Array of extensions to be applied to the asset. Each extension can be configured * with specific parameters based on the extension type. */ -export type Extensions = Array< - | Extensions.RemoveBg - | Extensions.AutoTaggingExtension - | Extensions.AIAutoDescription - | Extensions.AITasks - | Extensions.SavedExtension ->; +export type Extensions = Array export namespace Extensions { export interface RemoveBg { @@ -788,7 +779,7 @@ export interface ImageOverlay extends BaseOverlay { * See * [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). */ -export type Overlay = TextOverlay | ImageOverlay | VideoOverlay | SubtitleOverlay | SolidColorOverlay; +export type Overlay = TextOverlay | ImageOverlay | VideoOverlay | SubtitleOverlay | SolidColorOverlay export interface OverlayPosition { /** @@ -796,32 +787,14 @@ export interface OverlayPosition { * calculated. The default value is `top_left`. Maps to `lap` in the URL. Can only * be used with one or more of `x`, `y`, `xCenter`, or `yCenter`. */ - anchorPoint?: - | 'top' - | 'left' - | 'right' - | 'bottom' - | 'top_left' - | 'top_right' - | 'bottom_left' - | 'bottom_right' - | 'center'; + anchorPoint?: 'top' | 'left' | 'right' | 'bottom' | 'top_left' | 'top_right' | 'bottom_left' | 'bottom_right' | 'center'; /** * Specifies the position of the overlay relative to the parent image or video. If * one or more of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this * parameter is ignored. Maps to `lfo` in the URL. */ - focus?: - | 'center' - | 'top' - | 'left' - | 'bottom' - | 'right' - | 'top_left' - | 'top_right' - | 'bottom_left' - | 'bottom_right'; + focus?: 'center' | 'top' | 'left' | 'bottom' | 'right' | 'top_left' | 'top_right' | 'bottom_left' | 'bottom_right'; /** * Specifies the x-coordinate of the top-left corner of the base asset where the @@ -1089,7 +1062,7 @@ export interface SrcOptions { * Available streaming resolutions for * [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) */ -export type StreamingResolution = '240' | '360' | '480' | '720' | '1080' | '1440' | '2160'; +export type StreamingResolution = '240' | '360' | '480' | '720' | '1080' | '1440' | '2160' export interface SubtitleOverlay extends BaseOverlay { /** @@ -1344,7 +1317,7 @@ export interface Transformation { /** * Uses AI to edit images based on a text prompt. Provide a text prompt or a * base64-encoded prompt, e.g., `prompt-snow road` or - * `prompte-[urlencoded_base64_encoded_text]`. Not supported inside overlay. + * `prompte-[urlencoded_base64_encoded_text]`. Not supported inside overlay. * See [AI Edit](https://imagekit.io/docs/ai-transformations#edit-image-e-edit). */ aiEdit?: string; @@ -1759,7 +1732,7 @@ export interface Transformation { * path of the URL, set this to `path`. Learn more in the * [Transformations guide](https://imagekit.io/docs/transformations). */ -export type TransformationPosition = 'path' | 'query'; +export type TransformationPosition = 'path' | 'query' export interface VideoOverlay extends BaseOverlay { /** diff --git a/src/resources/webhooks.ts b/src/resources/webhooks.ts index be299493..984ade65 100644 --- a/src/resources/webhooks.ts +++ b/src/resources/webhooks.ts @@ -10,10 +10,7 @@ export class Webhooks extends APIResource { return JSON.parse(body) as UnsafeUnwrapWebhookEvent; } - unwrap( - body: string, - { headers, key }: { headers: Record; key?: string }, - ): UnwrapWebhookEvent { + unwrap(body: string, { headers, key }: { headers: Record; key?: string }): UnwrapWebhookEvent { if (headers !== undefined) { const keyStr: string | null = key === undefined ? this._client.webhookSecret : key; if (keyStr === null) throw new Error('Webhook key must not be null in order to unwrap'); @@ -1153,38 +1150,14 @@ export namespace VideoTransformationReadyEvent { * This event confirms that ImageKit has received and queued your transformation * request. Use this for debugging and tracking transformation lifecycle. */ -export type UnsafeUnwrapWebhookEvent = - | VideoTransformationAcceptedEvent - | VideoTransformationReadyEvent - | VideoTransformationErrorEvent - | UploadPreTransformSuccessEvent - | UploadPreTransformErrorEvent - | UploadPostTransformSuccessEvent - | UploadPostTransformErrorEvent - | FileCreateEvent - | FileUpdateEvent - | FileDeleteEvent - | FileVersionCreateEvent - | FileVersionDeleteEvent; +export type UnsafeUnwrapWebhookEvent = VideoTransformationAcceptedEvent | VideoTransformationReadyEvent | VideoTransformationErrorEvent | UploadPreTransformSuccessEvent | UploadPreTransformErrorEvent | UploadPostTransformSuccessEvent | UploadPostTransformErrorEvent | FileCreateEvent | FileUpdateEvent | FileDeleteEvent | FileVersionCreateEvent | FileVersionDeleteEvent /** * Triggered when a new video transformation request is accepted for processing. * This event confirms that ImageKit has received and queued your transformation * request. Use this for debugging and tracking transformation lifecycle. */ -export type UnwrapWebhookEvent = - | VideoTransformationAcceptedEvent - | VideoTransformationReadyEvent - | VideoTransformationErrorEvent - | UploadPreTransformSuccessEvent - | UploadPreTransformErrorEvent - | UploadPostTransformSuccessEvent - | UploadPostTransformErrorEvent - | FileCreateEvent - | FileUpdateEvent - | FileDeleteEvent - | FileVersionCreateEvent - | FileVersionDeleteEvent; +export type UnwrapWebhookEvent = VideoTransformationAcceptedEvent | VideoTransformationReadyEvent | VideoTransformationErrorEvent | UploadPreTransformSuccessEvent | UploadPreTransformErrorEvent | UploadPostTransformSuccessEvent | UploadPostTransformErrorEvent | FileCreateEvent | FileUpdateEvent | FileDeleteEvent | FileVersionCreateEvent | FileVersionDeleteEvent export declare namespace Webhooks { export { @@ -1202,6 +1175,6 @@ export declare namespace Webhooks { type VideoTransformationErrorEvent as VideoTransformationErrorEvent, type VideoTransformationReadyEvent as VideoTransformationReadyEvent, type UnsafeUnwrapWebhookEvent as UnsafeUnwrapWebhookEvent, - type UnwrapWebhookEvent as UnwrapWebhookEvent, + type UnwrapWebhookEvent as UnwrapWebhookEvent }; } diff --git a/src/uploads.ts b/src/uploads.ts index b2ef6471..d5437085 100644 --- a/src/uploads.ts +++ b/src/uploads.ts @@ -1,2 +1,2 @@ /** @deprecated Import from ./core/uploads instead */ -export * from './core/uploads'; +export * from "./core/uploads" \ No newline at end of file diff --git a/src/version.ts b/src/version.ts index 662d85ef..508ca0a4 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '7.5.0'; // x-release-please-version +export const VERSION = '7.5.0';// x-release-please-version diff --git a/tests/api-resources/accounts/origins.test.ts b/tests/api-resources/accounts/origins.test.ts index 2be57f09..bbca9168 100644 --- a/tests/api-resources/accounts/origins.test.ts +++ b/tests/api-resources/accounts/origins.test.ts @@ -5,19 +5,19 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource origins', () => { // Mock server tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.accounts.origins.create({ - accessKey: 'AKIAIOSFODNN7EXAMPLE', - bucket: 'product-images', - name: 'US S3 Storage', - secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', - type: 'S3', - }); + accessKey: 'AKIAIOSFODNN7EXAMPLE', + bucket: 'product-images', + name: 'US S3 Storage', + secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', + type: 'S3', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -30,26 +30,26 @@ describe('resource origins', () => { // Mock server tests are disabled test.skip('create: required and optional params', async () => { const response = await client.accounts.origins.create({ - accessKey: 'AKIAIOSFODNN7EXAMPLE', - bucket: 'product-images', - name: 'US S3 Storage', - secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', - type: 'S3', - baseUrlForCanonicalHeader: 'https://cdn.example.com', - includeCanonicalHeader: false, - prefix: 'raw-assets', - }); + accessKey: 'AKIAIOSFODNN7EXAMPLE', + bucket: 'product-images', + name: 'US S3 Storage', + secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', + type: 'S3', + baseUrlForCanonicalHeader: 'https://cdn.example.com', + includeCanonicalHeader: false, + prefix: 'raw-assets', + }); }); // Mock server tests are disabled test.skip('update: only required params', async () => { const responsePromise = client.accounts.origins.update('id', { - accessKey: 'AKIAIOSFODNN7EXAMPLE', - bucket: 'product-images', - name: 'US S3 Storage', - secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', - type: 'S3', - }); + accessKey: 'AKIAIOSFODNN7EXAMPLE', + bucket: 'product-images', + name: 'US S3 Storage', + secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', + type: 'S3', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -62,15 +62,15 @@ describe('resource origins', () => { // Mock server tests are disabled test.skip('update: required and optional params', async () => { const response = await client.accounts.origins.update('id', { - accessKey: 'AKIAIOSFODNN7EXAMPLE', - bucket: 'product-images', - name: 'US S3 Storage', - secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', - type: 'S3', - baseUrlForCanonicalHeader: 'https://cdn.example.com', - includeCanonicalHeader: false, - prefix: 'raw-assets', - }); + accessKey: 'AKIAIOSFODNN7EXAMPLE', + bucket: 'product-images', + name: 'US S3 Storage', + secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', + type: 'S3', + baseUrlForCanonicalHeader: 'https://cdn.example.com', + includeCanonicalHeader: false, + prefix: 'raw-assets', + }); }); // Mock server tests are disabled diff --git a/tests/api-resources/accounts/url-endpoints.test.ts b/tests/api-resources/accounts/url-endpoints.test.ts index b53af030..fe281d50 100644 --- a/tests/api-resources/accounts/url-endpoints.test.ts +++ b/tests/api-resources/accounts/url-endpoints.test.ts @@ -5,7 +5,7 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource urlEndpoints', () => { @@ -24,18 +24,16 @@ describe('resource urlEndpoints', () => { // Mock server tests are disabled test.skip('create: required and optional params', async () => { const response = await client.accounts.urlEndpoints.create({ - description: 'My custom URL endpoint', - origins: ['origin-id-1'], - urlPrefix: 'product-images', - urlRewriter: { type: 'CLOUDINARY', preserveAssetDeliveryTypes: true }, - }); + description: 'My custom URL endpoint', + origins: ['origin-id-1'], + urlPrefix: 'product-images', + urlRewriter: { type: 'CLOUDINARY', preserveAssetDeliveryTypes: true }, + }); }); // Mock server tests are disabled test.skip('update: only required params', async () => { - const responsePromise = client.accounts.urlEndpoints.update('id', { - description: 'My custom URL endpoint', - }); + const responsePromise = client.accounts.urlEndpoints.update('id', { description: 'My custom URL endpoint' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -48,11 +46,11 @@ describe('resource urlEndpoints', () => { // Mock server tests are disabled test.skip('update: required and optional params', async () => { const response = await client.accounts.urlEndpoints.update('id', { - description: 'My custom URL endpoint', - origins: ['origin-id-1'], - urlPrefix: 'product-images', - urlRewriter: { type: 'CLOUDINARY', preserveAssetDeliveryTypes: true }, - }); + description: 'My custom URL endpoint', + origins: ['origin-id-1'], + urlPrefix: 'product-images', + urlRewriter: { type: 'CLOUDINARY', preserveAssetDeliveryTypes: true }, + }); }); // Mock server tests are disabled diff --git a/tests/api-resources/accounts/usage.test.ts b/tests/api-resources/accounts/usage.test.ts index 161cdc71..fd5300c7 100644 --- a/tests/api-resources/accounts/usage.test.ts +++ b/tests/api-resources/accounts/usage.test.ts @@ -5,7 +5,7 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource usage', () => { diff --git a/tests/api-resources/assets.test.ts b/tests/api-resources/assets.test.ts index bf41276e..cd78ff5e 100644 --- a/tests/api-resources/assets.test.ts +++ b/tests/api-resources/assets.test.ts @@ -5,7 +5,7 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource assets', () => { @@ -24,19 +24,16 @@ describe('resource assets', () => { // Mock server tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.assets.list( - { - fileType: 'all', - limit: 1, - path: 'path', - searchQuery: 'searchQuery', - skip: 0, - sort: 'ASC_NAME', - type: 'file', - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(ImageKit.NotFoundError); + await expect(client.assets.list({ + fileType: 'all', + limit: 1, + path: 'path', + searchQuery: 'searchQuery', + skip: 0, + sort: 'ASC_NAME', + type: 'file', + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(ImageKit.NotFoundError); }); }); diff --git a/tests/api-resources/beta/v2/files.test.ts b/tests/api-resources/beta/v2/files.test.ts index 69af3768..dbfe3bf3 100644 --- a/tests/api-resources/beta/v2/files.test.ts +++ b/tests/api-resources/beta/v2/files.test.ts @@ -5,16 +5,13 @@ import ImageKit, { toFile } from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource files', () => { // Mock server tests are disabled test.skip('upload: only required params', async () => { - const responsePromise = client.beta.v2.files.upload({ - file: await toFile(Buffer.from('Example data'), 'README.md'), - fileName: 'fileName', - }); + const responsePromise = client.beta.v2.files.upload({ file: await toFile(Buffer.from('Example data'), 'README.md'), fileName: 'fileName' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -27,87 +24,69 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('upload: required and optional params', async () => { const response = await client.beta.v2.files.upload({ - file: await toFile(Buffer.from('Example data'), 'README.md'), - fileName: 'fileName', - token: 'token', - checks: '"request.folder" : "marketing/"\n', - customCoordinates: 'customCoordinates', - customMetadata: { brand: 'bar', color: 'bar' }, - description: 'Running shoes', - extensions: [ - { - name: 'remove-bg', - options: { - add_shadow: true, - bg_color: 'bg_color', - bg_image_url: 'bg_image_url', - semitransparency: true, - }, - }, - { - maxTags: 5, - minConfidence: 95, - name: 'google-auto-tagging', - }, - { name: 'ai-auto-description' }, - { - name: 'ai-tasks', - tasks: [ - { - instruction: 'What types of clothing items are visible in this image?', - type: 'select_tags', - max_selections: 1, - min_selections: 0, - vocabulary: ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'], - }, - { - instruction: 'Is this a luxury or high-end fashion item?', - type: 'yes_no', - on_no: { - add_tags: ['luxury', 'premium'], - remove_tags: ['budget', 'affordable'], - set_metadata: [{ field: 'price_range', value: 'premium' }], - unset_metadata: [{ field: 'price_range' }], - }, - on_unknown: { - add_tags: ['luxury', 'premium'], - remove_tags: ['budget', 'affordable'], - set_metadata: [{ field: 'price_range', value: 'premium' }], - unset_metadata: [{ field: 'price_range' }], - }, - on_yes: { - add_tags: ['luxury', 'premium'], - remove_tags: ['budget', 'affordable'], - set_metadata: [{ field: 'price_range', value: 'premium' }], - unset_metadata: [{ field: 'price_range' }], - }, - }, - ], - }, - { id: 'ext_abc123', name: 'saved-extension' }, - ], - folder: 'folder', - isPrivateFile: true, - isPublished: true, - overwriteAITags: true, - overwriteCustomMetadata: true, - overwriteFile: true, - overwriteTags: true, - responseFields: ['tags', 'customCoordinates', 'isPrivateFile'], - tags: ['t-shirt', 'round-neck', 'men'], - transformation: { - post: [ - { type: 'thumbnail', value: 'w-150,h-150' }, - { - protocol: 'dash', - type: 'abs', - value: 'sr-240_360_480_720_1080', - }, - ], - pre: 'w-300,h-300,q-80', - }, - useUniqueFileName: true, - webhookUrl: 'https://example.com', - }); + file: await toFile(Buffer.from('Example data'), 'README.md'), + fileName: 'fileName', + token: 'token', + checks: '"request.folder" : "marketing/"\n', + customCoordinates: 'customCoordinates', + customMetadata: { brand: 'bar', color: 'bar' }, + description: 'Running shoes', + extensions: [{ + name: 'remove-bg', + options: { + add_shadow: true, + bg_color: 'bg_color', + bg_image_url: 'bg_image_url', + semitransparency: true, + }, + }, { + maxTags: 5, + minConfidence: 95, + name: 'google-auto-tagging', + }, { name: 'ai-auto-description' }, { name: 'ai-tasks', tasks: [{ + instruction: 'What types of clothing items are visible in this image?', + type: 'select_tags', + max_selections: 1, + min_selections: 0, + vocabulary: ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'], + }, { + instruction: 'Is this a luxury or high-end fashion item?', + type: 'yes_no', + on_no: { + add_tags: ['luxury', 'premium'], + remove_tags: ['budget', 'affordable'], + set_metadata: [{ field: 'price_range', value: 'premium' }], + unset_metadata: [{ field: 'price_range' }], + }, + on_unknown: { + add_tags: ['luxury', 'premium'], + remove_tags: ['budget', 'affordable'], + set_metadata: [{ field: 'price_range', value: 'premium' }], + unset_metadata: [{ field: 'price_range' }], + }, + on_yes: { + add_tags: ['luxury', 'premium'], + remove_tags: ['budget', 'affordable'], + set_metadata: [{ field: 'price_range', value: 'premium' }], + unset_metadata: [{ field: 'price_range' }], + }, + }] }, { id: 'ext_abc123', name: 'saved-extension' }], + folder: 'folder', + isPrivateFile: true, + isPublished: true, + overwriteAITags: true, + overwriteCustomMetadata: true, + overwriteFile: true, + overwriteTags: true, + responseFields: ['tags', 'customCoordinates', 'isPrivateFile'], + tags: ['t-shirt', 'round-neck', 'men'], + transformation: { post: [{ type: 'thumbnail', value: 'w-150,h-150' }, { + protocol: 'dash', + type: 'abs', + value: 'sr-240_360_480_720_1080', + }], pre: 'w-300,h-300,q-80' }, + useUniqueFileName: true, + webhookUrl: 'https://example.com', + }); }); }); diff --git a/tests/api-resources/cache/invalidation.test.ts b/tests/api-resources/cache/invalidation.test.ts index d804f743..9f791c8a 100644 --- a/tests/api-resources/cache/invalidation.test.ts +++ b/tests/api-resources/cache/invalidation.test.ts @@ -5,15 +5,13 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource invalidation', () => { // Mock server tests are disabled test.skip('create: only required params', async () => { - const responsePromise = client.cache.invalidation.create({ - url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg', - }); + const responsePromise = client.cache.invalidation.create({ url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -25,9 +23,7 @@ describe('resource invalidation', () => { // Mock server tests are disabled test.skip('create: required and optional params', async () => { - const response = await client.cache.invalidation.create({ - url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg', - }); + const response = await client.cache.invalidation.create({ url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg' }); }); // Mock server tests are disabled diff --git a/tests/api-resources/custom-metadata-fields.test.ts b/tests/api-resources/custom-metadata-fields.test.ts index 52e39794..9abb46d1 100644 --- a/tests/api-resources/custom-metadata-fields.test.ts +++ b/tests/api-resources/custom-metadata-fields.test.ts @@ -5,17 +5,17 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource customMetadataFields', () => { // Mock server tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.customMetadataFields.create({ - label: 'price', - name: 'price', - schema: { type: 'Number' }, - }); + label: 'price', + name: 'price', + schema: { type: 'Number' }, + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -28,19 +28,19 @@ describe('resource customMetadataFields', () => { // Mock server tests are disabled test.skip('create: required and optional params', async () => { const response = await client.customMetadataFields.create({ - label: 'price', - name: 'price', - schema: { - type: 'Number', - defaultValue: [true, 10, 'Hello'], - isValueRequired: true, - maxLength: 0, - maxValue: 3000, - minLength: 0, - minValue: 1000, - selectOptions: ['small', 'medium', 'large', 30, 40, true], - }, - }); + label: 'price', + name: 'price', + schema: { + type: 'Number', + defaultValue: [true, 10, 'Hello'], + isValueRequired: true, + maxLength: 0, + maxValue: 3000, + minLength: 0, + minValue: 1000, + selectOptions: ['small', 'medium', 'large', 30, 40, true], + }, + }); }); // Mock server tests are disabled @@ -58,24 +58,20 @@ describe('resource customMetadataFields', () => { // Mock server tests are disabled test.skip('update: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.customMetadataFields.update( - 'id', - { - label: 'price', - schema: { - defaultValue: [true, 10, 'Hello'], - isValueRequired: true, - maxLength: 0, - maxValue: 3000, - minLength: 0, - minValue: 1000, - selectOptions: ['small', 'medium', 'large', 30, 40, true], - }, - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(ImageKit.NotFoundError); + await expect(client.customMetadataFields.update('id', { + label: 'price', + schema: { + defaultValue: [true, 10, 'Hello'], + isValueRequired: true, + maxLength: 0, + maxValue: 3000, + minLength: 0, + minValue: 1000, + selectOptions: ['small', 'medium', 'large', 30, 40, true], + }, + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(ImageKit.NotFoundError); }); // Mock server tests are disabled @@ -93,12 +89,9 @@ describe('resource customMetadataFields', () => { // Mock server tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.customMetadataFields.list( - { folderPath: 'folderPath', includeDeleted: true }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(ImageKit.NotFoundError); + await expect(client.customMetadataFields.list({ folderPath: 'folderPath', includeDeleted: true }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(ImageKit.NotFoundError); }); // Mock server tests are disabled diff --git a/tests/api-resources/files/bulk.test.ts b/tests/api-resources/files/bulk.test.ts index 1c417b90..4b7a3129 100644 --- a/tests/api-resources/files/bulk.test.ts +++ b/tests/api-resources/files/bulk.test.ts @@ -5,15 +5,13 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource bulk', () => { // Mock server tests are disabled test.skip('delete: only required params', async () => { - const responsePromise = client.files.bulk.delete({ - fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], - }); + const responsePromise = client.files.bulk.delete({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -25,17 +23,12 @@ describe('resource bulk', () => { // Mock server tests are disabled test.skip('delete: required and optional params', async () => { - const response = await client.files.bulk.delete({ - fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], - }); + const response = await client.files.bulk.delete({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] }); }); // Mock server tests are disabled test.skip('addTags: only required params', async () => { - const responsePromise = client.files.bulk.addTags({ - fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], - tags: ['t-shirt', 'round-neck', 'sale2019'], - }); + const responsePromise = client.files.bulk.addTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -47,18 +40,12 @@ describe('resource bulk', () => { // Mock server tests are disabled test.skip('addTags: required and optional params', async () => { - const response = await client.files.bulk.addTags({ - fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], - tags: ['t-shirt', 'round-neck', 'sale2019'], - }); + const response = await client.files.bulk.addTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] }); }); // Mock server tests are disabled test.skip('removeAITags: only required params', async () => { - const responsePromise = client.files.bulk.removeAITags({ - AITags: ['t-shirt', 'round-neck', 'sale2019'], - fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], - }); + const responsePromise = client.files.bulk.removeAITags({ AITags: ['t-shirt', 'round-neck', 'sale2019'], fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -70,18 +57,12 @@ describe('resource bulk', () => { // Mock server tests are disabled test.skip('removeAITags: required and optional params', async () => { - const response = await client.files.bulk.removeAITags({ - AITags: ['t-shirt', 'round-neck', 'sale2019'], - fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], - }); + const response = await client.files.bulk.removeAITags({ AITags: ['t-shirt', 'round-neck', 'sale2019'], fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] }); }); // Mock server tests are disabled test.skip('removeTags: only required params', async () => { - const responsePromise = client.files.bulk.removeTags({ - fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], - tags: ['t-shirt', 'round-neck', 'sale2019'], - }); + const responsePromise = client.files.bulk.removeTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -93,9 +74,6 @@ describe('resource bulk', () => { // Mock server tests are disabled test.skip('removeTags: required and optional params', async () => { - const response = await client.files.bulk.removeTags({ - fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], - tags: ['t-shirt', 'round-neck', 'sale2019'], - }); + const response = await client.files.bulk.removeTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] }); }); }); diff --git a/tests/api-resources/files/files.test.ts b/tests/api-resources/files/files.test.ts index aeb90697..4a7a05de 100644 --- a/tests/api-resources/files/files.test.ts +++ b/tests/api-resources/files/files.test.ts @@ -5,7 +5,7 @@ import ImageKit, { toFile } from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource files', () => { @@ -35,10 +35,7 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('copy: only required params', async () => { - const responsePromise = client.files.copy({ - destinationPath: '/folder/to/copy/into/', - sourceFilePath: '/path/to/file.jpg', - }); + const responsePromise = client.files.copy({ destinationPath: '/folder/to/copy/into/', sourceFilePath: '/path/to/file.jpg' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -51,10 +48,10 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('copy: required and optional params', async () => { const response = await client.files.copy({ - destinationPath: '/folder/to/copy/into/', - sourceFilePath: '/path/to/file.jpg', - includeFileVersions: false, - }); + destinationPath: '/folder/to/copy/into/', + sourceFilePath: '/path/to/file.jpg', + includeFileVersions: false, + }); }); // Mock server tests are disabled @@ -71,10 +68,7 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('move: only required params', async () => { - const responsePromise = client.files.move({ - destinationPath: '/folder/to/move/into/', - sourceFilePath: '/path/to/file.jpg', - }); + const responsePromise = client.files.move({ destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -86,18 +80,12 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('move: required and optional params', async () => { - const response = await client.files.move({ - destinationPath: '/folder/to/move/into/', - sourceFilePath: '/path/to/file.jpg', - }); + const response = await client.files.move({ destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg' }); }); // Mock server tests are disabled test.skip('rename: only required params', async () => { - const responsePromise = client.files.rename({ - filePath: '/path/to/file.jpg', - newFileName: 'newFileName.jpg', - }); + const responsePromise = client.files.rename({ filePath: '/path/to/file.jpg', newFileName: 'newFileName.jpg' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -110,18 +98,15 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('rename: required and optional params', async () => { const response = await client.files.rename({ - filePath: '/path/to/file.jpg', - newFileName: 'newFileName.jpg', - purgeCache: true, - }); + filePath: '/path/to/file.jpg', + newFileName: 'newFileName.jpg', + purgeCache: true, + }); }); // Mock server tests are disabled test.skip('upload: only required params', async () => { - const responsePromise = client.files.upload({ - file: await toFile(Buffer.from('Example data'), 'README.md'), - fileName: 'fileName', - }); + const responsePromise = client.files.upload({ file: await toFile(Buffer.from('Example data'), 'README.md'), fileName: 'fileName' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -134,90 +119,72 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('upload: required and optional params', async () => { const response = await client.files.upload({ - file: await toFile(Buffer.from('Example data'), 'README.md'), - fileName: 'fileName', - token: 'token', - checks: '"request.folder" : "marketing/"\n', - customCoordinates: 'customCoordinates', - customMetadata: { brand: 'bar', color: 'bar' }, - description: 'Running shoes', - expire: 0, - extensions: [ - { - name: 'remove-bg', - options: { - add_shadow: true, - bg_color: 'bg_color', - bg_image_url: 'bg_image_url', - semitransparency: true, - }, - }, - { - maxTags: 5, - minConfidence: 95, - name: 'google-auto-tagging', - }, - { name: 'ai-auto-description' }, - { - name: 'ai-tasks', - tasks: [ - { - instruction: 'What types of clothing items are visible in this image?', - type: 'select_tags', - max_selections: 1, - min_selections: 0, - vocabulary: ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'], - }, - { - instruction: 'Is this a luxury or high-end fashion item?', - type: 'yes_no', - on_no: { - add_tags: ['luxury', 'premium'], - remove_tags: ['budget', 'affordable'], - set_metadata: [{ field: 'price_range', value: 'premium' }], - unset_metadata: [{ field: 'price_range' }], - }, - on_unknown: { - add_tags: ['luxury', 'premium'], - remove_tags: ['budget', 'affordable'], - set_metadata: [{ field: 'price_range', value: 'premium' }], - unset_metadata: [{ field: 'price_range' }], - }, - on_yes: { - add_tags: ['luxury', 'premium'], - remove_tags: ['budget', 'affordable'], - set_metadata: [{ field: 'price_range', value: 'premium' }], - unset_metadata: [{ field: 'price_range' }], - }, - }, - ], - }, - { id: 'ext_abc123', name: 'saved-extension' }, - ], - folder: 'folder', - isPrivateFile: true, - isPublished: true, - overwriteAITags: true, - overwriteCustomMetadata: true, - overwriteFile: true, - overwriteTags: true, - publicKey: 'publicKey', - responseFields: ['tags', 'customCoordinates', 'isPrivateFile'], - signature: 'signature', - tags: ['t-shirt', 'round-neck', 'men'], - transformation: { - post: [ - { type: 'thumbnail', value: 'w-150,h-150' }, - { - protocol: 'dash', - type: 'abs', - value: 'sr-240_360_480_720_1080', - }, - ], - pre: 'w-300,h-300,q-80', - }, - useUniqueFileName: true, - webhookUrl: 'https://example.com', - }); + file: await toFile(Buffer.from('Example data'), 'README.md'), + fileName: 'fileName', + token: 'token', + checks: '"request.folder" : "marketing/"\n', + customCoordinates: 'customCoordinates', + customMetadata: { brand: 'bar', color: 'bar' }, + description: 'Running shoes', + expire: 0, + extensions: [{ + name: 'remove-bg', + options: { + add_shadow: true, + bg_color: 'bg_color', + bg_image_url: 'bg_image_url', + semitransparency: true, + }, + }, { + maxTags: 5, + minConfidence: 95, + name: 'google-auto-tagging', + }, { name: 'ai-auto-description' }, { name: 'ai-tasks', tasks: [{ + instruction: 'What types of clothing items are visible in this image?', + type: 'select_tags', + max_selections: 1, + min_selections: 0, + vocabulary: ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'], + }, { + instruction: 'Is this a luxury or high-end fashion item?', + type: 'yes_no', + on_no: { + add_tags: ['luxury', 'premium'], + remove_tags: ['budget', 'affordable'], + set_metadata: [{ field: 'price_range', value: 'premium' }], + unset_metadata: [{ field: 'price_range' }], + }, + on_unknown: { + add_tags: ['luxury', 'premium'], + remove_tags: ['budget', 'affordable'], + set_metadata: [{ field: 'price_range', value: 'premium' }], + unset_metadata: [{ field: 'price_range' }], + }, + on_yes: { + add_tags: ['luxury', 'premium'], + remove_tags: ['budget', 'affordable'], + set_metadata: [{ field: 'price_range', value: 'premium' }], + unset_metadata: [{ field: 'price_range' }], + }, + }] }, { id: 'ext_abc123', name: 'saved-extension' }], + folder: 'folder', + isPrivateFile: true, + isPublished: true, + overwriteAITags: true, + overwriteCustomMetadata: true, + overwriteFile: true, + overwriteTags: true, + publicKey: 'publicKey', + responseFields: ['tags', 'customCoordinates', 'isPrivateFile'], + signature: 'signature', + tags: ['t-shirt', 'round-neck', 'men'], + transformation: { post: [{ type: 'thumbnail', value: 'w-150,h-150' }, { + protocol: 'dash', + type: 'abs', + value: 'sr-240_360_480_720_1080', + }], pre: 'w-300,h-300,q-80' }, + useUniqueFileName: true, + webhookUrl: 'https://example.com', + }); }); }); diff --git a/tests/api-resources/files/metadata.test.ts b/tests/api-resources/files/metadata.test.ts index fd318072..a4645b9b 100644 --- a/tests/api-resources/files/metadata.test.ts +++ b/tests/api-resources/files/metadata.test.ts @@ -5,7 +5,7 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource metadata', () => { diff --git a/tests/api-resources/files/versions.test.ts b/tests/api-resources/files/versions.test.ts index 873ec8cc..13d68039 100644 --- a/tests/api-resources/files/versions.test.ts +++ b/tests/api-resources/files/versions.test.ts @@ -5,7 +5,7 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource versions', () => { diff --git a/tests/api-resources/folders/folders.test.ts b/tests/api-resources/folders/folders.test.ts index c4672ba4..cc72c8b8 100644 --- a/tests/api-resources/folders/folders.test.ts +++ b/tests/api-resources/folders/folders.test.ts @@ -5,16 +5,13 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource folders', () => { // Mock server tests are disabled test.skip('create: only required params', async () => { - const responsePromise = client.folders.create({ - folderName: 'summer', - parentFolderPath: '/product/images/', - }); + const responsePromise = client.folders.create({ folderName: 'summer', parentFolderPath: '/product/images/' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -26,10 +23,7 @@ describe('resource folders', () => { // Mock server tests are disabled test.skip('create: required and optional params', async () => { - const response = await client.folders.create({ - folderName: 'summer', - parentFolderPath: '/product/images/', - }); + const response = await client.folders.create({ folderName: 'summer', parentFolderPath: '/product/images/' }); }); // Mock server tests are disabled @@ -51,10 +45,7 @@ describe('resource folders', () => { // Mock server tests are disabled test.skip('copy: only required params', async () => { - const responsePromise = client.folders.copy({ - destinationPath: '/path/of/destination/folder', - sourceFolderPath: '/path/of/source/folder', - }); + const responsePromise = client.folders.copy({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -67,18 +58,15 @@ describe('resource folders', () => { // Mock server tests are disabled test.skip('copy: required and optional params', async () => { const response = await client.folders.copy({ - destinationPath: '/path/of/destination/folder', - sourceFolderPath: '/path/of/source/folder', - includeVersions: true, - }); + destinationPath: '/path/of/destination/folder', + sourceFolderPath: '/path/of/source/folder', + includeVersions: true, + }); }); // Mock server tests are disabled test.skip('move: only required params', async () => { - const responsePromise = client.folders.move({ - destinationPath: '/path/of/destination/folder', - sourceFolderPath: '/path/of/source/folder', - }); + const responsePromise = client.folders.move({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -90,18 +78,12 @@ describe('resource folders', () => { // Mock server tests are disabled test.skip('move: required and optional params', async () => { - const response = await client.folders.move({ - destinationPath: '/path/of/destination/folder', - sourceFolderPath: '/path/of/source/folder', - }); + const response = await client.folders.move({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' }); }); // Mock server tests are disabled test.skip('rename: only required params', async () => { - const responsePromise = client.folders.rename({ - folderPath: '/path/of/folder', - newFolderName: 'new-folder-name', - }); + const responsePromise = client.folders.rename({ folderPath: '/path/of/folder', newFolderName: 'new-folder-name' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -114,9 +96,9 @@ describe('resource folders', () => { // Mock server tests are disabled test.skip('rename: required and optional params', async () => { const response = await client.folders.rename({ - folderPath: '/path/of/folder', - newFolderName: 'new-folder-name', - purgeCache: true, - }); + folderPath: '/path/of/folder', + newFolderName: 'new-folder-name', + purgeCache: true, + }); }); }); diff --git a/tests/api-resources/folders/job.test.ts b/tests/api-resources/folders/job.test.ts index 7ab1e5ac..b52ab727 100644 --- a/tests/api-resources/folders/job.test.ts +++ b/tests/api-resources/folders/job.test.ts @@ -5,7 +5,7 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource job', () => { diff --git a/tests/api-resources/saved-extensions.test.ts b/tests/api-resources/saved-extensions.test.ts index 5b4a731e..44796d45 100644 --- a/tests/api-resources/saved-extensions.test.ts +++ b/tests/api-resources/saved-extensions.test.ts @@ -5,17 +5,17 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource savedExtensions', () => { // Mock server tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.savedExtensions.create({ - config: { name: 'remove-bg' }, - description: 'Analyzes vehicle images for type, condition, and quality assessment', - name: 'Car Quality Analysis', - }); + config: { name: 'remove-bg' }, + description: 'Analyzes vehicle images for type, condition, and quality assessment', + name: 'Car Quality Analysis', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -28,18 +28,18 @@ describe('resource savedExtensions', () => { // Mock server tests are disabled test.skip('create: required and optional params', async () => { const response = await client.savedExtensions.create({ - config: { - name: 'remove-bg', - options: { - add_shadow: true, - bg_color: 'bg_color', - bg_image_url: 'bg_image_url', - semitransparency: true, - }, - }, - description: 'Analyzes vehicle images for type, condition, and quality assessment', - name: 'Car Quality Analysis', - }); + config: { + name: 'remove-bg', + options: { + add_shadow: true, + bg_color: 'bg_color', + bg_image_url: 'bg_image_url', + semitransparency: true, + }, + }, + description: 'Analyzes vehicle images for type, condition, and quality assessment', + name: 'Car Quality Analysis', + }); }); // Mock server tests are disabled diff --git a/tests/api-resources/webhooks.test.ts b/tests/api-resources/webhooks.test.ts index e5547f28..55002698 100644 --- a/tests/api-resources/webhooks.test.ts +++ b/tests/api-resources/webhooks.test.ts @@ -7,14 +7,13 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', }); describe('resource webhooks', () => { test.skip('unwrap', () => { const key = 'whsec_c2VjcmV0Cg=='; - const payload = - '{"id":"id","type":"video.transformation.accepted","created_at":"2019-12-27T18:11:19.117Z","data":{"asset":{"url":"https://example.com"},"transformation":{"type":"video-transformation","options":{"audio_codec":"aac","auto_rotate":true,"format":"mp4","quality":0,"stream_protocol":"HLS","variants":["string"],"video_codec":"h264"}}},"request":{"url":"https://example.com","x_request_id":"x_request_id","user_agent":"user_agent"}}'; + const payload = '{"id":"id","type":"video.transformation.accepted","created_at":"2019-12-27T18:11:19.117Z","data":{"asset":{"url":"https://example.com"},"transformation":{"type":"video-transformation","options":{"audio_codec":"aac","auto_rotate":true,"format":"mp4","quality":0,"stream_protocol":"HLS","variants":["string"],"video_codec":"h264"}}},"request":{"url":"https://example.com","x_request_id":"x_request_id","user_agent":"user_agent"}}'; const msgID = '1'; const timestamp = new Date(); const wh = new Webhook('whsec_c2VjcmV0Cg=='); @@ -22,44 +21,38 @@ describe('resource webhooks', () => { const headers: Record = { 'webhook-signature': signature, 'webhook-id': msgID, - 'webhook-timestamp': String(Math.floor(timestamp.getTime() / 1000)), + 'webhook-timestamp': String(Math.floor(timestamp.getTime()/1000)), }; - client.webhooks.unwrap(payload, { headers, key }); - client.withOptions({ webhookSecret: key }).webhooks.unwrap(payload, { headers }); - client.withOptions({ webhookSecret: 'whsec_aaaaaaaaaa==' }).webhooks.unwrap(payload, { headers, key }); + client.webhooks.unwrap(payload, { headers, key }) + client.withOptions({webhookSecret: key}).webhooks.unwrap(payload, { headers }) + client.withOptions({webhookSecret: 'whsec_aaaaaaaaaa=='}).webhooks.unwrap(payload, { headers, key }) expect(() => { const wrongKey = 'whsec_aaaaaaaaaa=='; - client.webhooks.unwrap(payload, { headers, key: wrongKey }); + client.webhooks.unwrap(payload, { headers, key: wrongKey }) }).toThrow('No matching signature found'); expect(() => { const wrongKey = 'whsec_aaaaaaaaaa=='; - client.withOptions({ webhookSecret: wrongKey }).webhooks.unwrap(payload, { headers }); + client.withOptions({webhookSecret: wrongKey}).webhooks.unwrap(payload, { headers }) }).toThrow('No matching signature found'); expect(() => { const badSig = wh.sign(msgID, timestamp, 'some other payload'); - client.webhooks.unwrap(payload, { headers: { ...headers, 'webhook-signature': badSig }, key }); + client.webhooks.unwrap(payload, { headers: {...headers, 'webhook-signature': badSig }, key}) }).toThrow('No matching signature found'); expect(() => { const badSig = wh.sign(msgID, timestamp, 'some other payload'); - client - .withOptions({ webhookSecret: key }) - .webhooks.unwrap(payload, { headers: { ...headers, 'webhook-signature': badSig } }); + client.withOptions({webhookSecret: key}).webhooks.unwrap(payload, { headers: {...headers, 'webhook-signature': badSig }}) }).toThrow('No matching signature found'); expect(() => { - client.webhooks.unwrap(payload, { headers: { ...headers, 'webhook-timestamp': '5' }, key }); + client.webhooks.unwrap(payload, { headers: {...headers, 'webhook-timestamp': '5' }, key}) }).toThrow('Message timestamp too old'); expect(() => { - client - .withOptions({ webhookSecret: key }) - .webhooks.unwrap(payload, { headers: { ...headers, 'webhook-timestamp': '5' } }); + client.withOptions({webhookSecret: key}).webhooks.unwrap(payload, { headers: {...headers, 'webhook-timestamp': '5' }}) }).toThrow('Message timestamp too old'); expect(() => { - client.webhooks.unwrap(payload, { headers: { ...headers, 'webhook-id': 'wrong' }, key }); + client.webhooks.unwrap(payload, { headers: {...headers, 'webhook-id': 'wrong' }, key}) }).toThrow('No matching signature found'); expect(() => { - client - .withOptions({ webhookSecret: key }) - .webhooks.unwrap(payload, { headers: { ...headers, 'webhook-id': 'wrong' } }); + client.withOptions({webhookSecret: key}).webhooks.unwrap(payload, { headers: {...headers, 'webhook-id': 'wrong' }}) }).toThrow('No matching signature found'); }); }); diff --git a/tests/index.test.ts b/tests/index.test.ts index 32f31df0..28d1dddf 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -21,11 +21,11 @@ describe('instantiate client', () => { describe('defaultHeaders', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - defaultHeaders: { 'X-My-Default-Header': '2' }, - privateKey: 'My Private Key', - password: 'My Password', - }); + baseURL: 'http://localhost:5000/', + defaultHeaders: { 'X-My-Default-Header': '2' }, + privateKey: 'My Private Key', + password: 'My Password', +}) test('they are used in the request', async () => { const { req } = await client.buildRequest({ path: '/foo', method: 'post' }); @@ -50,209 +50,207 @@ describe('instantiate client', () => { expect(req.headers.has('x-my-default-header')).toBe(false); }); }); - describe('logging', () => { - const env = process.env; +describe('logging', () => { + const env = process.env; - beforeEach(() => { - process.env = { ...env }; - process.env['IMAGE_KIT_LOG'] = undefined; - }); + beforeEach(() => { + process.env = { ...env }; + process.env['IMAGE_KIT_LOG'] = undefined; + }); - afterEach(() => { - process.env = env; - }); + afterEach(() => { + process.env = env; + }); - const forceAPIResponseForClient = async (client: ImageKit) => { - await new APIPromise( - client, - Promise.resolve({ - response: new Response(), - controller: new AbortController(), - requestLogID: 'log_000000', - retryOfRequestLogID: undefined, - startTime: Date.now(), - options: { - method: 'get', - path: '/', - }, - }), - ); + const forceAPIResponseForClient = async (client: ImageKit) => { + await new APIPromise( + client, + Promise.resolve({ + response: new Response(), + controller: new AbortController(), + requestLogID: 'log_000000', + retryOfRequestLogID: undefined, + startTime: Date.now(), + options: { + method: 'get', + path: '/', + }, + }), + ); + }; + + test('debug logs when log level is debug', async () => { + const debugMock = jest.fn(); + const logger = { + debug: debugMock, + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), }; - test('debug logs when log level is debug', async () => { - const debugMock = jest.fn(); - const logger = { - debug: debugMock, - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - }; - - const client = new ImageKit({ - logger: logger, - logLevel: 'debug', - privateKey: 'My Private Key', - password: 'My Password', - }); + const client = new ImageKit({ + logger: logger, + logLevel: 'debug', + privateKey: 'My Private Key', + password: 'My Password', +}); - await forceAPIResponseForClient(client); - expect(debugMock).toHaveBeenCalled(); - }); + await forceAPIResponseForClient(client); + expect(debugMock).toHaveBeenCalled(); + }); - test('default logLevel is warn', async () => { - const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password' }); - expect(client.logLevel).toBe('warn'); - }); + test('default logLevel is warn', async () => { + const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password' }); + expect(client.logLevel).toBe('warn'); + }); - test('debug logs are skipped when log level is info', async () => { - const debugMock = jest.fn(); - const logger = { - debug: debugMock, - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - }; + test('debug logs are skipped when log level is info', async () => { + const debugMock = jest.fn(); + const logger = { + debug: debugMock, + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), + }; - const client = new ImageKit({ - logger: logger, - logLevel: 'info', - privateKey: 'My Private Key', - password: 'My Password', - }); + const client = new ImageKit({ + logger: logger, + logLevel: 'info', + privateKey: 'My Private Key', + password: 'My Password', +}); - await forceAPIResponseForClient(client); - expect(debugMock).not.toHaveBeenCalled(); - }); + await forceAPIResponseForClient(client); + expect(debugMock).not.toHaveBeenCalled(); + }); - test('debug logs happen with debug env var', async () => { - const debugMock = jest.fn(); - const logger = { - debug: debugMock, - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - }; + test('debug logs happen with debug env var', async () => { + const debugMock = jest.fn(); + const logger = { + debug: debugMock, + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), + }; - process.env['IMAGE_KIT_LOG'] = 'debug'; - const client = new ImageKit({ - logger: logger, - privateKey: 'My Private Key', - password: 'My Password', - }); - expect(client.logLevel).toBe('debug'); + process.env['IMAGE_KIT_LOG'] = 'debug'; + const client = new ImageKit({ + logger: logger, + privateKey: 'My Private Key', + password: 'My Password', +}); + expect(client.logLevel).toBe('debug'); - await forceAPIResponseForClient(client); - expect(debugMock).toHaveBeenCalled(); - }); + await forceAPIResponseForClient(client); + expect(debugMock).toHaveBeenCalled(); + }); - test('warn when env var level is invalid', async () => { - const warnMock = jest.fn(); - const logger = { - debug: jest.fn(), - info: jest.fn(), - warn: warnMock, - error: jest.fn(), - }; + test('warn when env var level is invalid', async () => { + const warnMock = jest.fn(); + const logger = { + debug: jest.fn(), + info: jest.fn(), + warn: warnMock, + error: jest.fn(), + }; - process.env['IMAGE_KIT_LOG'] = 'not a log level'; - const client = new ImageKit({ - logger: logger, - privateKey: 'My Private Key', - password: 'My Password', - }); - expect(client.logLevel).toBe('warn'); - expect(warnMock).toHaveBeenCalledWith( - 'process.env[\'IMAGE_KIT_LOG\'] was set to "not a log level", expected one of ["off","error","warn","info","debug"]', - ); - }); + process.env['IMAGE_KIT_LOG'] = 'not a log level'; + const client = new ImageKit({ + logger: logger, + privateKey: 'My Private Key', + password: 'My Password', +}); + expect(client.logLevel).toBe('warn'); + expect(warnMock).toHaveBeenCalledWith('process.env[\'IMAGE_KIT_LOG\'] was set to "not a log level", expected one of ["off","error","warn","info","debug"]'); + }); - test('client log level overrides env var', async () => { - const debugMock = jest.fn(); - const logger = { - debug: debugMock, - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - }; + test('client log level overrides env var', async () => { + const debugMock = jest.fn(); + const logger = { + debug: debugMock, + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), + }; - process.env['IMAGE_KIT_LOG'] = 'debug'; - const client = new ImageKit({ - logger: logger, - logLevel: 'off', - privateKey: 'My Private Key', - password: 'My Password', - }); + process.env['IMAGE_KIT_LOG'] = 'debug'; + const client = new ImageKit({ + logger: logger, + logLevel: 'off', + privateKey: 'My Private Key', + password: 'My Password', +}); - await forceAPIResponseForClient(client); - expect(debugMock).not.toHaveBeenCalled(); - }); + await forceAPIResponseForClient(client); + expect(debugMock).not.toHaveBeenCalled(); + }); - test('no warning logged for invalid env var level + valid client level', async () => { - const warnMock = jest.fn(); - const logger = { - debug: jest.fn(), - info: jest.fn(), - warn: warnMock, - error: jest.fn(), - }; + test('no warning logged for invalid env var level + valid client level', async () => { + const warnMock = jest.fn(); + const logger = { + debug: jest.fn(), + info: jest.fn(), + warn: warnMock, + error: jest.fn(), + }; - process.env['IMAGE_KIT_LOG'] = 'not a log level'; - const client = new ImageKit({ - logger: logger, - logLevel: 'debug', - privateKey: 'My Private Key', - password: 'My Password', - }); - expect(client.logLevel).toBe('debug'); - expect(warnMock).not.toHaveBeenCalled(); - }); + process.env['IMAGE_KIT_LOG'] = 'not a log level'; + const client = new ImageKit({ + logger: logger, + logLevel: 'debug', + privateKey: 'My Private Key', + password: 'My Password', +}); + expect(client.logLevel).toBe('debug'); + expect(warnMock).not.toHaveBeenCalled(); }); +}); describe('defaultQuery', () => { test('with null query params given', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - defaultQuery: { apiVersion: 'foo' }, - privateKey: 'My Private Key', - password: 'My Password', - }); + baseURL: 'http://localhost:5000/', + defaultQuery: { apiVersion: 'foo' }, + privateKey: 'My Private Key', + password: 'My Password', +}); expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/foo?apiVersion=foo'); }); test('multiple default query params', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - defaultQuery: { apiVersion: 'foo', hello: 'world' }, - privateKey: 'My Private Key', - password: 'My Password', - }); + baseURL: 'http://localhost:5000/', + defaultQuery: { apiVersion: 'foo', hello: 'world' }, + privateKey: 'My Private Key', + password: 'My Password', +}); expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/foo?apiVersion=foo&hello=world'); }); test('overriding with `undefined`', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - defaultQuery: { hello: 'world' }, - privateKey: 'My Private Key', - password: 'My Password', - }); + baseURL: 'http://localhost:5000/', + defaultQuery: { hello: 'world' }, + privateKey: 'My Private Key', + password: 'My Password', +}) expect(client.buildURL('/foo', { hello: undefined })).toEqual('http://localhost:5000/foo'); }); }); test('custom fetch', async () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - privateKey: 'My Private Key', - password: 'My Password', - fetch: (url) => { - return Promise.resolve( - new Response(JSON.stringify({ url, custom: true }), { - headers: { 'Content-Type': 'application/json' }, - }), - ); - }, - }); + baseURL: 'http://localhost:5000/', + privateKey: 'My Private Key', + password: 'My Password', + fetch: (url) => { + return Promise.resolve( + new Response(JSON.stringify({ url, custom: true }), { + headers: { 'Content-Type': 'application/json' }, + }), + ); +}, +}); const response = await client.get('/foo'); expect(response).toEqual({ url: 'http://localhost:5000/foo', custom: true }); @@ -261,37 +259,39 @@ describe('instantiate client', () => { test('explicit global fetch', async () => { // make sure the global fetch type is assignable to our Fetch type const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - privateKey: 'My Private Key', - password: 'My Password', - fetch: defaultFetch, - }); + baseURL: 'http://localhost:5000/', + privateKey: 'My Private Key', + password: 'My Password', + fetch: defaultFetch, +}); }); test('custom signal', async () => { const client = new ImageKit({ - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', - privateKey: 'My Private Key', - password: 'My Password', - fetch: (...args) => { - return new Promise((resolve, reject) => - setTimeout( - () => - defaultFetch(...args) - .then(resolve) - .catch(reject), - 300, - ), - ); - }, - }); + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + privateKey: 'My Private Key', + password: 'My Password', + fetch: (...args) => { + return new Promise((resolve, reject) => + setTimeout( + () => + defaultFetch(...args) + .then(resolve) + .catch(reject), + 300, + ), + ); +}, +}); const controller = new AbortController(); setTimeout(() => controller.abort(), 200); const spy = jest.spyOn(client, 'request'); - await expect(client.get('/foo', { signal: controller.signal })).rejects.toThrowError(APIUserAbortError); + await expect(client.get('/foo', { signal: controller.signal })).rejects.toThrowError( + APIUserAbortError, + ); expect(spy).toHaveBeenCalledTimes(1); }); @@ -303,11 +303,11 @@ describe('instantiate client', () => { }; const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, - }); + baseURL: 'http://localhost:5000/', + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, +}); await client.patch('/foo'); expect(capturedRequest?.method).toEqual('PATCH'); @@ -316,19 +316,19 @@ describe('instantiate client', () => { describe('baseUrl', () => { test('trailing slash', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/custom/path/', - privateKey: 'My Private Key', - password: 'My Password', - }); + baseURL: 'http://localhost:5000/custom/path/', + privateKey: 'My Private Key', + password: 'My Password', +}); expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/custom/path/foo'); }); test('no trailing slash', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/custom/path', - privateKey: 'My Private Key', - password: 'My Password', - }); + baseURL: 'http://localhost:5000/custom/path', + privateKey: 'My Private Key', + password: 'My Password', +}); expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/custom/path/foo'); }); @@ -338,10 +338,10 @@ describe('instantiate client', () => { test('explicit option', () => { const client = new ImageKit({ - baseURL: 'https://example.com', - privateKey: 'My Private Key', - password: 'My Password', - }); + baseURL: 'https://example.com', + privateKey: 'My Private Key', + password: 'My Password', +}); expect(client.baseURL).toEqual('https://example.com'); }); @@ -354,48 +354,42 @@ describe('instantiate client', () => { test('empty env variable', () => { process.env['IMAGE_KIT_BASE_URL'] = ''; // empty const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password' }); - expect(client.baseURL).toEqual('https://api.imagekit.io'); + expect(client.baseURL).toEqual('https://api.imagekit.io') }); test('blank env variable', () => { process.env['IMAGE_KIT_BASE_URL'] = ' '; // blank const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password' }); - expect(client.baseURL).toEqual('https://api.imagekit.io'); + expect(client.baseURL).toEqual('https://api.imagekit.io') }); test('in request options', () => { const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password' }); - expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( - 'http://localhost:5000/option/foo', - ); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual('http://localhost:5000/option/foo'); }); test('in request options overridden by client options', () => { const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - baseURL: 'http://localhost:5000/client', - }); - expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( - 'http://localhost:5000/client/foo', - ); + privateKey: 'My Private Key', + password: 'My Password', + baseURL: 'http://localhost:5000/client', + }); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual('http://localhost:5000/client/foo'); }); test('in request options overridden by env variable', () => { process.env['IMAGE_KIT_BASE_URL'] = 'http://localhost:5000/env'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password' }); - expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( - 'http://localhost:5000/env/foo', - ); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual('http://localhost:5000/env/foo'); }); }); test('maxRetries option is correctly set', () => { const client = new ImageKit({ - maxRetries: 4, - privateKey: 'My Private Key', - password: 'My Password', - }); + maxRetries: 4, + privateKey: 'My Private Key', + password: 'My Password', +}); expect(client.maxRetries).toEqual(4); // default @@ -406,11 +400,11 @@ describe('instantiate client', () => { describe('withOptions', () => { test('creates a new client with overridden options', async () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - maxRetries: 3, - privateKey: 'My Private Key', - password: 'My Password', - }); + baseURL: 'http://localhost:5000/', + maxRetries: 3, + privateKey: 'My Private Key', + password: 'My Password', + }); const newClient = client.withOptions({ maxRetries: 5, @@ -432,12 +426,12 @@ describe('instantiate client', () => { test('inherits options from the parent client', async () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - defaultHeaders: { 'X-Test-Header': 'test-value' }, - defaultQuery: { 'test-param': 'test-value' }, - privateKey: 'My Private Key', - password: 'My Password', - }); + baseURL: 'http://localhost:5000/', + defaultHeaders: { 'X-Test-Header': 'test-value' }, + defaultQuery: { 'test-param': 'test-value' }, + privateKey: 'My Private Key', + password: 'My Password', + }); const newClient = client.withOptions({ baseURL: 'http://localhost:5001/', @@ -452,11 +446,11 @@ describe('instantiate client', () => { test('respects runtime property changes when creating new client', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - timeout: 1000, - privateKey: 'My Private Key', - password: 'My Password', - }); + baseURL: 'http://localhost:5000/', + timeout: 1000, + privateKey: 'My Private Key', + password: 'My Password', + }); // Modify the client properties directly after creation client.baseURL = 'http://localhost:6000/'; @@ -506,18 +500,13 @@ describe('request building', () => { describe('custom headers', () => { test('handles undefined', async () => { - const { req } = await client.buildRequest({ - path: '/foo', - method: 'post', - body: { value: 'hello' }, - headers: { 'X-Foo': 'baz', 'x-foo': 'bar', 'x-Foo': undefined, 'x-baz': 'bam', 'X-Baz': null }, - }); + const { req } = await client.buildRequest({ path: '/foo', method: 'post', body: { value: 'hello' }, headers: { 'X-Foo': 'baz', 'x-foo': 'bar', 'x-Foo': undefined, 'x-baz': 'bam', 'X-Baz': null } }); expect(req.headers.get('x-foo')).toEqual('bar'); expect(req.headers.get('x-Foo')).toEqual('bar'); expect(req.headers.get('X-Foo')).toEqual('bar'); expect(req.headers.get('x-baz')).toEqual(null); }); - }); + }) }); describe('default encoder', () => { @@ -594,41 +583,38 @@ describe('default encoder', () => { describe('retries', () => { test('retry on timeout', async () => { let count = 0; - const testFetch = async ( - url: string | URL | Request, - { signal }: RequestInit = {}, - ): Promise => { - if (count++ === 0) { - return new Promise( - (resolve, reject) => signal?.addEventListener('abort', () => reject(new Error('timed out'))), - ); - } - return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); - }; - - const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - timeout: 10, - fetch: testFetch, - }); + const testFetch = async (url: string | URL | Request, { signal }: RequestInit = {}): Promise => { + if (count++ === 0) { + return new Promise((resolve, reject) => + signal?.addEventListener('abort', () => reject(new Error('timed out'))), + ); + } + return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); + }; - expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); - expect(count).toEqual(2); - expect( - await client - .request({ path: '/foo', method: 'get' }) - .asResponse() - .then((r) => r.text()), - ).toEqual(JSON.stringify({ a: 1 })); - expect(count).toEqual(3); + const client = new ImageKit({ + privateKey: 'My Private Key', + password: 'My Password', + timeout: 10, + fetch: testFetch, }); + expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); + expect(count).toEqual(2); + expect( + await client + .request({ path: '/foo', method: 'get' }) + .asResponse() + .then((r) => r.text()), + ).toEqual(JSON.stringify({ a: 1 })); + expect(count).toEqual(3); + }); + test('retry count header', async () => { let count = 0; let capturedRequest: RequestInit | undefined; const testFetch = async (url: string | URL | Request, init: RequestInit = {}): Promise => { - count++; + count++ if (count <= 2) { return new Response(undefined, { status: 429, @@ -642,11 +628,11 @@ describe('retries', () => { }; const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, - maxRetries: 4, - }); + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, + maxRetries: 4, + }); expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); @@ -658,7 +644,7 @@ describe('retries', () => { let count = 0; let capturedRequest: RequestInit | undefined; const testFetch = async (url: string | URL | Request, init: RequestInit = {}): Promise => { - count++; + count++ if (count <= 2) { return new Response(undefined, { status: 429, @@ -671,11 +657,11 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, - maxRetries: 4, - }); + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, + maxRetries: 4, + }); expect( await client.request({ @@ -692,7 +678,7 @@ describe('retries', () => { let count = 0; let capturedRequest: RequestInit | undefined; const testFetch = async (url: string | URL | Request, init: RequestInit = {}): Promise => { - count++; + count++ if (count <= 2) { return new Response(undefined, { status: 429, @@ -705,12 +691,12 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, - maxRetries: 4, - defaultHeaders: { 'X-Stainless-Retry-Count': null }, - }); + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, + maxRetries: 4, + defaultHeaders: { 'X-Stainless-Retry-Count': null }, + }); expect( await client.request({ @@ -726,7 +712,7 @@ describe('retries', () => { let count = 0; let capturedRequest: RequestInit | undefined; const testFetch = async (url: string | URL | Request, init: RequestInit = {}): Promise => { - count++; + count++ if (count <= 2) { return new Response(undefined, { status: 429, @@ -739,11 +725,11 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, - maxRetries: 4, - }); + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, + maxRetries: 4, + }); expect( await client.request({ @@ -758,10 +744,7 @@ describe('retries', () => { test('retry on 429 with retry-after', async () => { let count = 0; - const testFetch = async ( - url: string | URL | Request, - { signal }: RequestInit = {}, - ): Promise => { + const testFetch = async (url: string | URL | Request, { signal }: RequestInit = {}): Promise => { if (count++ === 0) { return new Response(undefined, { status: 429, @@ -774,10 +757,10 @@ describe('retries', () => { }; const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, - }); + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, + }); expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); expect(count).toEqual(2); @@ -792,10 +775,7 @@ describe('retries', () => { test('retry on 429 with retry-after-ms', async () => { let count = 0; - const testFetch = async ( - url: string | URL | Request, - { signal }: RequestInit = {}, - ): Promise => { + const testFetch = async (url: string | URL | Request, { signal }: RequestInit = {}): Promise => { if (count++ === 0) { return new Response(undefined, { status: 429, @@ -808,10 +788,10 @@ describe('retries', () => { }; const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, - }); + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, + }); expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); expect(count).toEqual(2); diff --git a/tests/stringifyQuery.test.ts b/tests/stringifyQuery.test.ts index 4fa1d747..4bef7207 100644 --- a/tests/stringifyQuery.test.ts +++ b/tests/stringifyQuery.test.ts @@ -2,26 +2,24 @@ import { stringifyQuery } from '@imagekit/nodejs/internal/utils/query'; -describe(stringifyQuery, () => { - for (const [input, expected] of [ - [{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'], - [{ a: null, b: false, c: undefined }, 'a=&b=false'], - [{ 'a/b': 1.28341 }, `${encodeURIComponent('a/b')}=1.28341`], - [ - { 'a/b': 'c/d', 'e=f': 'g&h' }, - `${encodeURIComponent('a/b')}=${encodeURIComponent('c/d')}&${encodeURIComponent( - 'e=f', - )}=${encodeURIComponent('g&h')}`, - ], - ] as const) { - it(`${JSON.stringify(input)} -> ${expected}`, () => { - expect(stringifyQuery(input)).toEqual(expected); - }); - } +describe(stringifyQuery, () => { for (const [input, expected] of [ + [{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'], + [{ a: null, b: false, c: undefined }, 'a=&b=false'], + [{ 'a/b': 1.28341 }, `${encodeURIComponent('a/b')}=1.28341`], + [ + { 'a/b': 'c/d', 'e=f': 'g&h' }, + `${encodeURIComponent('a/b')}=${encodeURIComponent('c/d')}&${encodeURIComponent( + 'e=f', + )}=${encodeURIComponent('g&h')}`, + ], +] as const) { + it(`${JSON.stringify(input)} -> ${expected}`, () => { + expect(stringifyQuery(input)).toEqual(expected); + }); +} - for (const value of [[], {}, new Date()]) { - it(`${JSON.stringify(value)} -> `, () => { - expect(() => stringifyQuery({ value })).toThrow(`Cannot stringify type ${typeof value}`); - }); - } -}); +for (const value of [[], {}, new Date()]) { + it(`${JSON.stringify(value)} -> `, () => { + expect(() => stringifyQuery({ value })).toThrow(`Cannot stringify type ${typeof value}`); + }); +} }) diff --git a/yarn.lock b/yarn.lock index a41ae84e..9a878fe6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -709,11 +709,6 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@pkgr/core@^0.2.4": - version "0.2.4" - resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.2.4.tgz#d897170a2b0ba51f78a099edccd968f7b103387c" - integrity sha512-ROFF39F6ZrnzSUEmQQZUar0Jt4xVoP9WnDRdWwF4NNcXs3xBTLgBUDoOwW141y1jP+S8nahIbdxbFC7IShw9Iw== - "@sinclair/typebox@^0.27.8": version "0.27.8" resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" @@ -1520,14 +1515,6 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -eslint-plugin-prettier@^5.4.1: - version "5.4.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.4.1.tgz#99b55d7dd70047886b2222fdd853665f180b36af" - integrity sha512-9dF+KuU/Ilkq27A8idRP7N2DH8iUR6qXcjF3FR2wETY21PZdBrIjwCau8oboyGj9b7etWmTGEeM8e7oOed6ZWg== - dependencies: - prettier-linter-helpers "^1.0.0" - synckit "^0.11.7" - eslint-plugin-unused-imports@^4.1.4: version "4.1.4" resolved "https://registry.yarnpkg.com/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-4.1.4.tgz#62ddc7446ccbf9aa7b6f1f0b00a980423cda2738" @@ -1679,11 +1666,6 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-diff@^1.1.2: - version "1.3.0" - resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0" - integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw== - fast-glob@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" @@ -2851,13 +2833,6 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -prettier-linter-helpers@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" - integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== - dependencies: - fast-diff "^1.1.2" - prettier@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.1.tgz#6ba9f23165d690b6cbdaa88cb0807278f7019848" @@ -3162,13 +3137,6 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== -synckit@^0.11.7: - version "0.11.8" - resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.11.8.tgz#b2aaae998a4ef47ded60773ad06e7cb821f55457" - integrity sha512-+XZ+r1XGIJGeQk3VvXhT6xx/VpbHsRzsTkGgF6E5RX9TTXD0118l87puaEBZ566FhqblC6U0d4XnubznJDm30A== - dependencies: - "@pkgr/core" "^0.2.4" - test-exclude@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e" From 21fe6eeadfc0376dffb409f78dadc3c3b32194da Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 Apr 2026 20:28:18 +0000 Subject: [PATCH 18/36] chore(internal): codegen related update --- .prettierignore | 1 - eslint.config.mjs | 3 + package.json | 1 + .../worker-configuration.d.ts | 4 +- packages/mcp-server/jest.config.ts | 4 +- packages/mcp-server/src/auth.ts | 56 +- packages/mcp-server/src/code-tool-types.ts | 2 +- packages/mcp-server/src/code-tool-worker.ts | 116 +- packages/mcp-server/src/code-tool.ts | 145 +- packages/mcp-server/src/docs-search-tool.ts | 55 +- packages/mcp-server/src/http.ts | 68 +- packages/mcp-server/src/index.ts | 2 +- packages/mcp-server/src/instructions.ts | 20 +- packages/mcp-server/src/local-docs-search.ts | 5821 +++++++++-------- packages/mcp-server/src/methods.ts | 548 +- packages/mcp-server/src/options.ts | 47 +- packages/mcp-server/src/server.ts | 104 +- packages/mcp-server/src/types.ts | 80 +- scripts/fast-format | 6 +- scripts/format | 3 +- scripts/lint | 3 - scripts/utils/postprocess-files.cjs | 9 +- src/api-promise.ts | 2 +- src/client.ts | 455 +- src/core/api-promise.ts | 9 +- src/core/error.ts | 46 +- src/error.ts | 2 +- src/index.ts | 16 +- src/internal/builtin-types.ts | 23 +- src/internal/detect-platform.ts | 6 +- src/internal/errors.ts | 14 +- src/internal/headers.ts | 4 +- src/internal/parse.ts | 12 +- src/internal/request-options.ts | 6 +- src/internal/shim-types.ts | 4 +- src/internal/shims.ts | 4 +- src/internal/to-file.ts | 14 +- src/internal/types.ts | 50 +- src/internal/utils/log.ts | 37 +- src/internal/utils/uuid.ts | 8 +- src/resource.ts | 2 +- src/resources/accounts/accounts.ts | 28 +- src/resources/accounts/index.ts | 22 +- src/resources/accounts/origins.ts | 59 +- src/resources/accounts/url-endpoints.ts | 35 +- src/resources/accounts/usage.ts | 5 +- src/resources/assets.ts | 28 +- src/resources/beta/beta.ts | 4 +- src/resources/beta/index.ts | 4 +- src/resources/beta/v2/files.ts | 47 +- src/resources/beta/v2/index.ts | 4 +- src/resources/beta/v2/v2.ts | 2 +- src/resources/cache/cache.ts | 9 +- src/resources/cache/index.ts | 9 +- src/resources/cache/invalidation.ts | 2 +- src/resources/custom-metadata-fields.ts | 18 +- src/resources/files/bulk.ts | 2 +- src/resources/files/files.ts | 90 +- src/resources/files/index.ts | 41 +- src/resources/files/metadata.ts | 4 +- src/resources/files/versions.ts | 25 +- src/resources/folders/folders.ts | 13 +- src/resources/folders/index.ts | 16 +- src/resources/folders/job.ts | 4 +- src/resources/saved-extensions.ts | 15 +- src/resources/shared.ts | 45 +- src/resources/webhooks.ts | 35 +- src/uploads.ts | 2 +- src/version.ts | 2 +- tests/api-resources/accounts/origins.test.ts | 62 +- .../accounts/url-endpoints.test.ts | 26 +- tests/api-resources/accounts/usage.test.ts | 2 +- tests/api-resources/assets.test.ts | 27 +- tests/api-resources/beta/v2/files.test.ts | 153 +- .../api-resources/cache/invalidation.test.ts | 10 +- .../custom-metadata-fields.test.ts | 77 +- tests/api-resources/files/bulk.test.ts | 40 +- tests/api-resources/files/files.test.ts | 195 +- tests/api-resources/files/metadata.test.ts | 2 +- tests/api-resources/files/versions.test.ts | 2 +- tests/api-resources/folders/folders.test.ts | 48 +- tests/api-resources/folders/job.test.ts | 2 +- tests/api-resources/saved-extensions.test.ts | 34 +- tests/api-resources/webhooks.test.ts | 35 +- tests/index.test.ts | 610 +- tests/stringifyQuery.test.ts | 42 +- yarn.lock | 32 + 87 files changed, 5523 insertions(+), 4258 deletions(-) diff --git a/.prettierignore b/.prettierignore index 6e7fb359..7cc13dd1 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,7 +2,6 @@ CHANGELOG.md /ecosystem-tests/*/** /node_modules /deno -/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts # don't format tsc output, will break source maps dist diff --git a/eslint.config.mjs b/eslint.config.mjs index 42741bdb..c1a01a62 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,6 +1,7 @@ // @ts-check import tseslint from 'typescript-eslint'; import unusedImports from 'eslint-plugin-unused-imports'; +import prettier from 'eslint-plugin-prettier'; export default tseslint.config( { @@ -13,9 +14,11 @@ export default tseslint.config( plugins: { '@typescript-eslint': tseslint.plugin, 'unused-imports': unusedImports, + prettier, }, rules: { 'no-unused-vars': 'off', + 'prettier/prettier': 'error', 'unused-imports/no-unused-imports': 'error', 'no-restricted-imports': [ 'error', diff --git a/package.json b/package.json index b1c22e58..10029643 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "@typescript-eslint/eslint-plugin": "8.31.1", "@typescript-eslint/parser": "8.31.1", "eslint": "^9.39.1", + "eslint-plugin-prettier": "^5.4.1", "eslint-plugin-unused-imports": "^4.1.4", "iconv-lite": "^0.6.3", "jest": "^29.4.0", diff --git a/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts b/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts index 32da9a90..432fe3e0 100644 --- a/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts +++ b/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts @@ -1,4 +1,4 @@ - +/* eslint-disable */ // Generated by Wrangler by running `wrangler types` (hash: fc286f4a60f8eb63b1e0d82ea1f34233) // Runtime types generated with workerd@1.20260124.0 2025-03-10 nodejs_compat declare namespace Cloudflare { @@ -29,7 +29,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ - +/* eslint-disable */ // noinspection JSUnusedGlobalSymbols declare var onmessage: never; /** diff --git a/packages/mcp-server/jest.config.ts b/packages/mcp-server/jest.config.ts index 6c1213f2..c1a41722 100644 --- a/packages/mcp-server/jest.config.ts +++ b/packages/mcp-server/jest.config.ts @@ -10,9 +10,7 @@ const config: JestConfigWithTsJest = { '^@imagekit/api-mcp$': '/src/index.ts', '^@imagekit/api-mcp/(.*)$': '/src/$1', }, - modulePathIgnorePatterns: [ - '/dist/', - ], + modulePathIgnorePatterns: ['/dist/'], testPathIgnorePatterns: ['scripts'], }; diff --git a/packages/mcp-server/src/auth.ts b/packages/mcp-server/src/auth.ts index f3c8810a..085cac43 100644 --- a/packages/mcp-server/src/auth.ts +++ b/packages/mcp-server/src/auth.ts @@ -1,36 +1,50 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { IncomingMessage } from 'node:http' -import { ClientOptions } from '@imagekit/nodejs' +import { IncomingMessage } from 'node:http'; +import { ClientOptions } from '@imagekit/nodejs'; import { McpOptions } from './options'; -export const parseClientAuthHeaders = (req: IncomingMessage, required?: boolean): Partial => { if (req.headers.authorization) { - const scheme = req.headers.authorization.split(" ")[0]!; - const value = req.headers.authorization.slice(scheme.length + 1); - switch (scheme) { - case 'Basic': - const rawValue = Buffer.from(value, 'base64').toString(); - return { privateKey: rawValue.slice(0, rawValue.search(':')), password: rawValue.slice(rawValue.search(':') + 1) } - default: - throw new Error('Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Basic).'); +export const parseClientAuthHeaders = (req: IncomingMessage, required?: boolean): Partial => { + if (req.headers.authorization) { + const scheme = req.headers.authorization.split(' ')[0]!; + const value = req.headers.authorization.slice(scheme.length + 1); + switch (scheme) { + case 'Basic': + const rawValue = Buffer.from(value, 'base64').toString(); + return { + privateKey: rawValue.slice(0, rawValue.search(':')), + password: rawValue.slice(rawValue.search(':') + 1), + }; + default: + throw new Error( + 'Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Basic).', + ); + } + } else if (required) { + throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.'); } -} else if (required) { - throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.'); -} -const privateKey = Array.isArray(req.headers['x-imagekit-private-key']) ? req.headers['x-imagekit-private-key'][0] : req.headers['x-imagekit-private-key'] -const password = Array.isArray(req.headers['x-optional-imagekit-ignores-this']) ? req.headers['x-optional-imagekit-ignores-this'][0] : req.headers['x-optional-imagekit-ignores-this'] -return {privateKey, password}; } + const privateKey = + Array.isArray(req.headers['x-imagekit-private-key']) ? + req.headers['x-imagekit-private-key'][0] + : req.headers['x-imagekit-private-key']; + const password = + Array.isArray(req.headers['x-optional-imagekit-ignores-this']) ? + req.headers['x-optional-imagekit-ignores-this'][0] + : req.headers['x-optional-imagekit-ignores-this']; + return { privateKey, password }; +}; export const getStainlessApiKey = (req: IncomingMessage, mcpOptions: McpOptions): string | undefined => { // Try to get the key from the x-stainless-api-key header - const headerKey = Array.isArray(req.headers['x-stainless-api-key']) ? - req.headers['x-stainless-api-key'][0] - : req.headers['x-stainless-api-key']; + const headerKey = + Array.isArray(req.headers['x-stainless-api-key']) ? + req.headers['x-stainless-api-key'][0] + : req.headers['x-stainless-api-key']; if (headerKey && typeof headerKey === 'string') { return headerKey; } // Fall back to value set in the mcpOptions (e.g. from environment variable), if provided return mcpOptions.stainlessApiKey; -} +}; diff --git a/packages/mcp-server/src/code-tool-types.ts b/packages/mcp-server/src/code-tool-types.ts index 40acf26b..c29cbd38 100644 --- a/packages/mcp-server/src/code-tool-types.ts +++ b/packages/mcp-server/src/code-tool-types.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { ClientOptions } from '@imagekit/nodejs' +import { ClientOptions } from '@imagekit/nodejs'; export type WorkerInput = { project_name: string; diff --git a/packages/mcp-server/src/code-tool-worker.ts b/packages/mcp-server/src/code-tool-worker.ts index bb3ca749..07b79f57 100644 --- a/packages/mcp-server/src/code-tool-worker.ts +++ b/packages/mcp-server/src/code-tool-worker.ts @@ -59,8 +59,8 @@ function getTSDiagnostics(code: string): string[] { const codeWithImport = [ 'import { ImageKit } from "@imagekit/nodejs";', functionSource.type === 'declaration' ? - `async function run(${functionSource.client}: ImageKit)` : - `const run: (${functionSource.client}: ImageKit) => Promise =`, + `async function run(${functionSource.client}: ImageKit)` + : `const run: (${functionSource.client}: ImageKit) => Promise =`, functionSource.code, ].join('\n'); const sourcePath = path.resolve('code.ts'); @@ -108,55 +108,55 @@ function getTSDiagnostics(code: string): string[] { const fuse = new Fuse( [ - "client.customMetadataFields.create", - "client.customMetadataFields.delete", - "client.customMetadataFields.list", - "client.customMetadataFields.update", - "client.files.copy", - "client.files.delete", - "client.files.get", - "client.files.move", - "client.files.rename", - "client.files.update", - "client.files.upload", - "client.files.bulk.addTags", - "client.files.bulk.delete", - "client.files.bulk.removeAITags", - "client.files.bulk.removeTags", - "client.files.versions.delete", - "client.files.versions.get", - "client.files.versions.list", - "client.files.versions.restore", - "client.files.metadata.get", - "client.files.metadata.getFromURL", - "client.savedExtensions.create", - "client.savedExtensions.delete", - "client.savedExtensions.get", - "client.savedExtensions.list", - "client.savedExtensions.update", - "client.assets.list", - "client.cache.invalidation.create", - "client.cache.invalidation.get", - "client.folders.copy", - "client.folders.create", - "client.folders.delete", - "client.folders.move", - "client.folders.rename", - "client.folders.job.get", - "client.accounts.usage.get", - "client.accounts.origins.create", - "client.accounts.origins.delete", - "client.accounts.origins.get", - "client.accounts.origins.list", - "client.accounts.origins.update", - "client.accounts.urlEndpoints.create", - "client.accounts.urlEndpoints.delete", - "client.accounts.urlEndpoints.get", - "client.accounts.urlEndpoints.list", - "client.accounts.urlEndpoints.update", - "client.beta.v2.files.upload", - "client.webhooks.unsafeUnwrap", - "client.webhooks.unwrap" + 'client.customMetadataFields.create', + 'client.customMetadataFields.delete', + 'client.customMetadataFields.list', + 'client.customMetadataFields.update', + 'client.files.copy', + 'client.files.delete', + 'client.files.get', + 'client.files.move', + 'client.files.rename', + 'client.files.update', + 'client.files.upload', + 'client.files.bulk.addTags', + 'client.files.bulk.delete', + 'client.files.bulk.removeAITags', + 'client.files.bulk.removeTags', + 'client.files.versions.delete', + 'client.files.versions.get', + 'client.files.versions.list', + 'client.files.versions.restore', + 'client.files.metadata.get', + 'client.files.metadata.getFromURL', + 'client.savedExtensions.create', + 'client.savedExtensions.delete', + 'client.savedExtensions.get', + 'client.savedExtensions.list', + 'client.savedExtensions.update', + 'client.assets.list', + 'client.cache.invalidation.create', + 'client.cache.invalidation.get', + 'client.folders.copy', + 'client.folders.create', + 'client.folders.delete', + 'client.folders.move', + 'client.folders.rename', + 'client.folders.job.get', + 'client.accounts.usage.get', + 'client.accounts.origins.create', + 'client.accounts.origins.delete', + 'client.accounts.origins.get', + 'client.accounts.origins.list', + 'client.accounts.origins.update', + 'client.accounts.urlEndpoints.create', + 'client.accounts.urlEndpoints.delete', + 'client.accounts.urlEndpoints.get', + 'client.accounts.urlEndpoints.list', + 'client.accounts.urlEndpoints.update', + 'client.beta.v2.files.upload', + 'client.webhooks.unsafeUnwrap', + 'client.webhooks.unwrap', ], { threshold: 1, shouldSort: true }, ); @@ -239,7 +239,12 @@ function parseError(code: string, error: unknown): string | undefined { // Deno uses V8; the first ":LINE:COLUMN" is the top of stack. const lineNumber = error.stack?.match(/:([0-9]+):[0-9]+/)?.[1]; // -1 for the zero-based indexing - const line = lineNumber && code.split('\n').at(parseInt(lineNumber, 10) - 1)?.trim(); + const line = + lineNumber && + code + .split('\n') + .at(parseInt(lineNumber, 10) - 1) + ?.trim(); return line ? `${message}\n at line ${lineNumber}\n ${line}` : message; } catch { return message; @@ -251,8 +256,9 @@ const fetch = async (req: Request): Promise => { const runFunctionSource = code ? getRunFunctionSource(code) : null; if (!runFunctionSource) { - const message = code - ? 'The code is missing a top-level `run` function.' + const message = + code ? + 'The code is missing a top-level `run` function.' : 'The code argument is missing. Provide one containing a top-level `run` function.'; return Response.json( { @@ -297,7 +303,7 @@ const fetch = async (req: Request): Promise => { try { let run_ = async (client: any) => {}; run_ = (await tseval(`${code}\nexport default run;`)).default; - const result = await run_(makeSdkProxy(client, { path: ["client"] })); + const result = await run_(makeSdkProxy(client, { path: ['client'] })); return Response.json({ is_error: false, result, diff --git a/packages/mcp-server/src/code-tool.ts b/packages/mcp-server/src/code-tool.ts index e52ddc4d..0d5a3ac3 100644 --- a/packages/mcp-server/src/code-tool.ts +++ b/packages/mcp-server/src/code-tool.ts @@ -1,8 +1,16 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { ContentBlock, McpRequestContext, McpTool, Metadata, ToolCallResult, asErrorResult, asTextContentResult } from './types'; +import { + ContentBlock, + McpRequestContext, + McpTool, + Metadata, + ToolCallResult, + asErrorResult, + asTextContentResult, +} from './types'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; -import { readEnv, requireValue } from "./util"; +import { readEnv, requireValue } from './util'; import { WorkerInput, WorkerOutput } from './code-tool-types'; import { getLogger } from './logger'; import { SdkMethod } from './methods'; @@ -44,10 +52,13 @@ Always type dynamic key-value stores explicitly as Record * @param codeExecutionMode - Whether to execute code in a local Deno environment or in a remote * sandbox environment hosted by Stainless. */ -export function codeTool( - {blockedMethods, codeExecutionMode}: - {blockedMethods: SdkMethod[] | undefined, codeExecutionMode: McpCodeExecutionMode}, -): McpTool { +export function codeTool({ + blockedMethods, + codeExecutionMode, +}: { + blockedMethods: SdkMethod[] | undefined; + codeExecutionMode: McpCodeExecutionMode; +}): McpTool { const metadata: Metadata = { resource: 'all', operation: 'write', tags: [] }; const tool: Tool = { name: 'execute', @@ -70,10 +81,13 @@ export function codeTool( const logger = getLogger(); - const handler = async ( - {reqContext, args}: - {reqContext: McpRequestContext, args: any}, - ): Promise => { + const handler = async ({ + reqContext, + args, + }: { + reqContext: McpRequestContext; + args: any; + }): Promise => { const code = args.code as string; // Do very basic blocking of code that includes forbidden method names. // @@ -83,7 +97,11 @@ export function codeTool( if (blockedMethods) { const blockedMatches = blockedMethods.filter((method) => code.includes(method.fullyQualifiedName)); if (blockedMatches.length > 0) { - return asErrorResult(`The following methods have been blocked by the MCP server and cannot be used in code execution: ${blockedMatches.map((m) => m.fullyQualifiedName).join(', ')}`); + return asErrorResult( + `The following methods have been blocked by the MCP server and cannot be used in code execution: ${blockedMatches + .map((m) => m.fullyQualifiedName) + .join(', ')}`, + ); } } @@ -108,40 +126,46 @@ export function codeTool( 'Got code tool execution result', ); return result; - } + }; return { metadata, tool, handler }; } -const remoteStainlessHandler = async ( - {reqContext, args}: - {reqContext: McpRequestContext, args: any}, -): Promise => { +const remoteStainlessHandler = async ({ + reqContext, + args, +}: { + reqContext: McpRequestContext; + args: any; +}): Promise => { const code = args.code as string; const intent = args.intent as string | undefined; const client = reqContext.client; - const codeModeEndpoint = readEnv("CODE_MODE_ENDPOINT_URL") ?? "https://api.stainless.com/api/ai/code-tool"; + const codeModeEndpoint = readEnv('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool'; const localClientEnvs = { - IMAGEKIT_PRIVATE_KEY: requireValue(readEnv('IMAGEKIT_PRIVATE_KEY') ?? client.privateKey, 'set IMAGEKIT_PRIVATE_KEY environment variable or provide privateKey client option'), - OPTIONAL_IMAGEKIT_IGNORES_THIS: readEnv('OPTIONAL_IMAGEKIT_IGNORES_THIS') ?? client.password ?? undefined, - IMAGEKIT_WEBHOOK_SECRET: readEnv('IMAGEKIT_WEBHOOK_SECRET') ?? client.webhookSecret ?? undefined, - IMAGE_KIT_BASE_URL: readEnv('IMAGE_KIT_BASE_URL') ?? client.baseURL ?? undefined, -}; + IMAGEKIT_PRIVATE_KEY: requireValue( + readEnv('IMAGEKIT_PRIVATE_KEY') ?? client.privateKey, + 'set IMAGEKIT_PRIVATE_KEY environment variable or provide privateKey client option', + ), + OPTIONAL_IMAGEKIT_IGNORES_THIS: readEnv('OPTIONAL_IMAGEKIT_IGNORES_THIS') ?? client.password ?? undefined, + IMAGEKIT_WEBHOOK_SECRET: readEnv('IMAGEKIT_WEBHOOK_SECRET') ?? client.webhookSecret ?? undefined, + IMAGE_KIT_BASE_URL: readEnv('IMAGE_KIT_BASE_URL') ?? client.baseURL ?? undefined, + }; // Merge any upstream client envs from the request header, with upstream values taking precedence. const mergedClientEnvs = { ...localClientEnvs, ...reqContext.upstreamClientEnvs }; // Setting a Stainless API key authenticates requests to the code tool endpoint. const res = await fetch(codeModeEndpoint, { - method: "POST", + method: 'POST', headers: { - ...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey, }), - "Content-Type": "application/json", - "x-stainless-mcp-client-envs": JSON.stringify(mergedClientEnvs), + ...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }), + 'Content-Type': 'application/json', + 'x-stainless-mcp-client-envs': JSON.stringify(mergedClientEnvs), }, body: JSON.stringify({ - project_name: "imagekit", + project_name: 'imagekit', code, intent, client_opts: {}, @@ -150,12 +174,18 @@ const remoteStainlessHandler = async ( if (!res.ok) { if (res.status === 404 && !reqContext.stainlessApiKey) { - throw new Error('Could not access code tool for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.'); + throw new Error( + 'Could not access code tool for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.', + ); } - throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`); + throw new Error( + `${res.status}: ${ + res.statusText + } error when trying to contact Code Tool server. Details: ${await res.text()}`, + ); } - const { is_error, result, log_lines, err_lines } = await res.json() as WorkerOutput; + const { is_error, result, log_lines, err_lines } = (await res.json()) as WorkerOutput; const hasLogs = log_lines.length > 0 || err_lines.length > 0; const output = { result, @@ -163,17 +193,18 @@ const remoteStainlessHandler = async ( ...(err_lines.length > 0 && { err_lines }), }; if (is_error) { - return asErrorResult( - typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2), - ); + return asErrorResult(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2)); } return asTextContentResult(output); }; -const localDenoHandler = async ( - {reqContext, args} : - {reqContext: McpRequestContext, args: unknown}, -): Promise => { +const localDenoHandler = async ({ + reqContext, + args, +}: { + reqContext: McpRequestContext; + args: unknown; +}): Promise => { const fs = await import('node:fs'); const path = await import('node:path'); const url = await import('node:url'); @@ -198,24 +229,20 @@ const localDenoHandler = async ( } catch { try { // Use deno binary in node_modules if it's found - const denoNodeModulesPath = path.resolve( - packageNodeModulesPath, - 'deno', - 'bin.cjs', - ); + const denoNodeModulesPath = path.resolve(packageNodeModulesPath, 'deno', 'bin.cjs'); await fs.promises.access(denoNodeModulesPath, fs.constants.X_OK); denoPath = denoNodeModulesPath; } catch { return asErrorResult( 'Deno is required for code execution but was not found. ' + - 'Install it from https://deno.land or run: npm install deno', + 'Install it from https://deno.land or run: npm install deno', ); } } const allowReadPaths = [ 'code-tool-worker.mjs', - `${workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, "$1")}/`, + `${workerPath.replace(/([\/\\]node_modules)[\/\\].+$/, '$1')}/`, packageRoot, ]; @@ -249,7 +276,7 @@ const localDenoHandler = async ( // Merge any upstream client envs into the Deno subprocess environment, // with the upstream env vars taking precedence. env: { ...process.env, ...reqContext.upstreamClientEnvs }, - } + }, }); try { @@ -261,13 +288,13 @@ const localDenoHandler = async ( // Strip null/undefined values so that the worker SDK client can fall back to // reading from environment variables (including any upstreamClientEnvs). const opts = { - ...(client.baseURL != null ? { baseURL: client.baseURL } : undefined), - ...(client.privateKey != null ? { privateKey: client.privateKey } : undefined), - ...(client.password != null ? { password: client.password } : undefined), - ...(client.webhookSecret != null ? { webhookSecret: client.webhookSecret } : undefined), - defaultHeaders: { - 'X-Stainless-MCP': 'true', - }, + ...(client.baseURL != null ? { baseURL: client.baseURL } : undefined), + ...(client.privateKey != null ? { privateKey: client.privateKey } : undefined), + ...(client.password != null ? { password: client.password } : undefined), + ...(client.webhookSecret != null ? { webhookSecret: client.webhookSecret } : undefined), + defaultHeaders: { + 'X-Stainless-MCP': 'true', + }, } satisfies Partial as ClientOptions; const req = worker.request( @@ -314,11 +341,12 @@ const localDenoHandler = async ( if (resp.status === 200) { const { result, log_lines, err_lines } = (await resp.json()) as WorkerOutput; const returnOutput: ContentBlock | null = - result == null ? null - : { + result == null ? null : ( + { type: 'text', text: typeof result === 'string' ? result : JSON.stringify(result), - }; + } + ); const logOutput: ContentBlock | null = log_lines.length === 0 ? null @@ -339,11 +367,12 @@ const localDenoHandler = async ( } else { const { result, log_lines, err_lines } = (await resp.json()) as WorkerOutput; const messageOutput: ContentBlock | null = - result == null ? null - : { + result == null ? null : ( + { type: 'text', text: typeof result === 'string' ? result : JSON.stringify(result), - }; + } + ); const logOutput: ContentBlock | null = log_lines.length === 0 ? null diff --git a/packages/mcp-server/src/docs-search-tool.ts b/packages/mcp-server/src/docs-search-tool.ts index 8e9ff4e6..25c9c7ea 100644 --- a/packages/mcp-server/src/docs-search-tool.ts +++ b/packages/mcp-server/src/docs-search-tool.ts @@ -14,7 +14,8 @@ export const metadata: Metadata = { export const tool: Tool = { name: 'search_docs', - description: 'Search SDK documentation to find methods, parameters, and usage examples for interacting with the API. Use this before writing code when you need to discover the right approach.', + description: + 'Search SDK documentation to find methods, parameters, and usage examples for interacting with the API. Use this before writing code when you need to discover the right approach.', inputSchema: { type: 'object', properties: { @@ -31,7 +32,7 @@ export const tool: Tool = { type: 'string', description: 'The amount of detail to return.', enum: ['default', 'verbose'], - } + }, }, required: ['query', 'language'], }, @@ -40,7 +41,8 @@ export const tool: Tool = { }, }; -const docsSearchURL = process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/imagekit/docs/search' +const docsSearchURL = + process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/imagekit/docs/search'; let _localSearch: LocalDocsSearch | undefined; @@ -65,30 +67,27 @@ async function searchLocal(args: Record): Promise { }).results; } -async function searchRemote( - args: Record, - reqContext: McpRequestContext, -): Promise { +async function searchRemote(args: Record, reqContext: McpRequestContext): Promise { const body = args as any; const query = new URLSearchParams(body).toString(); const startTime = Date.now(); - const result = await fetch( - `${docsSearchURL}?${query}`, - { - headers: { - ...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }), - ...(reqContext.mcpSessionId && { 'x-stainless-mcp-session-id': reqContext.mcpSessionId }), - ...(reqContext.mcpClientInfo && { 'x-stainless-mcp-client-info': JSON.stringify(reqContext.mcpClientInfo) }), - }, + const result = await fetch(`${docsSearchURL}?${query}`, { + headers: { + ...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }), + ...(reqContext.mcpSessionId && { 'x-stainless-mcp-session-id': reqContext.mcpSessionId }), + ...(reqContext.mcpClientInfo && { + 'x-stainless-mcp-client-info': JSON.stringify(reqContext.mcpClientInfo), + }), }, - ); + }); const logger = getLogger(); if (!result.ok) { const errorText = await result.text(); - logger.warn({ + logger.warn( + { durationMs: Date.now() - startTime, query: body.query, status: result.status, @@ -99,14 +98,19 @@ async function searchRemote( ); if (result.status === 404 && !reqContext.stainlessApiKey) { - throw new Error('Could not find docs for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.'); + throw new Error( + 'Could not find docs for this project. You may need to provide a Stainless API key via the STAINLESS_API_KEY environment variable, the --stainless-api-key flag, or the x-stainless-api-key HTTP header.', + ); } - throw new Error(`${result.status}: ${result.statusText} when using doc search tool. Details: ${errorText}`); + throw new Error( + `${result.status}: ${result.statusText} when using doc search tool. Details: ${errorText}`, + ); } const resultBody = await result.json(); - logger.info({ + logger.info( + { durationMs: Date.now() - startTime, query: body.query, }, @@ -115,10 +119,13 @@ async function searchRemote( return resultBody; } -export const handler = async ( - { reqContext, args }: - { reqContext: McpRequestContext; args: Record | undefined }, -) => { +export const handler = async ({ + reqContext, + args, +}: { + reqContext: McpRequestContext; + args: Record | undefined; +}) => { const body = args ?? {}; if (_localSearch) { diff --git a/packages/mcp-server/src/http.ts b/packages/mcp-server/src/http.ts index f1db5047..08c31bed 100644 --- a/packages/mcp-server/src/http.ts +++ b/packages/mcp-server/src/http.ts @@ -1,7 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { McpServer } from '@modelcontextprotocol/sdk/server/mcp'; -import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js' +import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'; import { ClientOptions } from '@imagekit/nodejs'; import express from 'express'; import pino from 'pino'; @@ -24,7 +24,7 @@ const newServer = async ({ }): Promise => { const stainlessApiKey = getStainlessApiKey(req, mcpOptions); const customInstructionsPath = mcpOptions.customInstructionsPath; - const server = await newMcpServer({stainlessApiKey, customInstructionsPath}); + const server = await newMcpServer({ stainlessApiKey, customInstructionsPath }); const authOptions = parseClientAuthHeaders(req, false); @@ -65,15 +65,13 @@ const newServer = async ({ ); } } catch (error) { - getLogger().warn( - { error }, - 'Failed to parse x-stainless-mcp-client-permissions header', - ); + getLogger().warn({ error }, 'Failed to parse x-stainless-mcp-client-permissions header'); } } - const mcpClientInfo = typeof req.body?.params?.clientInfo?.name === 'string' - ? { name: req.body.params.clientInfo.name, version: String(req.body.params.clientInfo.version ?? '') } + const mcpClientInfo = + typeof req.body?.params?.clientInfo?.name === 'string' ? + { name: req.body.params.clientInfo.name, version: String(req.body.params.clientInfo.version ?? '') } : undefined; await initMcpServer({ @@ -90,10 +88,7 @@ const newServer = async ({ }); if (mcpClientInfo) { - getLogger().info( - { mcpSessionId: (req as any).mcpSessionId, mcpClientInfo }, - 'MCP client connected', - ); + getLogger().info({ mcpSessionId: (req as any).mcpSessionId, mcpClientInfo }, 'MCP client connected'); } return server; @@ -133,7 +128,7 @@ const del = async (req: express.Request, res: express.Response) => { const redactHeaders = (headers: Record) => { const hiddenHeaders = /auth|cookie|key|token|x-stainless-mcp-client-envs/i; const filtered = { ...headers }; - Object.keys(filtered).forEach(key => { + Object.keys(filtered).forEach((key) => { if (hiddenHeaders.test(key)) { filtered[key] = '[REDACTED]'; } @@ -186,17 +181,17 @@ export const streamableHTTPApp = ({ req: pino.stdSerializers.wrapRequestSerializer((req) => { return { ...req, - headers: redactHeaders(req.raw.headers) + headers: redactHeaders(req.raw.headers), }; }), res: pino.stdSerializers.wrapResponseSerializer((res) => { return { ...res, - headers: redactHeaders(res.headers) + headers: redactHeaders(res.headers), }; }), - } - }) + }, + }), ); app.get('/health', async (req: express.Request, res: express.Response) => { @@ -209,23 +204,24 @@ export const streamableHTTPApp = ({ return app; }; -export const launchStreamableHTTPServer = async( - {mcpOptions, port}: { - mcpOptions: McpOptions, - port: number | string | undefined, - } -) => { - const app = streamableHTTPApp({ mcpOptions }); - const server = app.listen(port); - const address = server.address(); - - const logger = getLogger(); - - if (typeof address === 'string') { - logger.info(`MCP Server running on streamable HTTP at ${address}`); - } else if (address !== null) { - logger.info(`MCP Server running on streamable HTTP on port ${address.port}`); - } else { - logger.info(`MCP Server running on streamable HTTP on port ${port}`); - } +export const launchStreamableHTTPServer = async ({ + mcpOptions, + port, +}: { + mcpOptions: McpOptions; + port: number | string | undefined; +}) => { + const app = streamableHTTPApp({ mcpOptions }); + const server = app.listen(port); + const address = server.address(); + + const logger = getLogger(); + + if (typeof address === 'string') { + logger.info(`MCP Server running on streamable HTTP at ${address}`); + } else if (address !== null) { + logger.info(`MCP Server running on streamable HTTP on port ${address.port}`); + } else { + logger.info(`MCP Server running on streamable HTTP on port ${port}`); } +}; diff --git a/packages/mcp-server/src/index.ts b/packages/mcp-server/src/index.ts index 6306dc26..5bca4a60 100644 --- a/packages/mcp-server/src/index.ts +++ b/packages/mcp-server/src/index.ts @@ -17,7 +17,7 @@ async function main() { const selectedTools = await selectToolsOrError(options); getLogger().info( - {tools: selectedTools.map((e) => e.tool.name)}, + { tools: selectedTools.map((e) => e.tool.name) }, `MCP Server starting with ${selectedTools.length} tools`, ); diff --git a/packages/mcp-server/src/instructions.ts b/packages/mcp-server/src/instructions.ts index 523a7b5d..ffe655a0 100644 --- a/packages/mcp-server/src/instructions.ts +++ b/packages/mcp-server/src/instructions.ts @@ -60,24 +60,24 @@ async function fetchLatestInstructionsFromApi(stainlessApiKey: string | undefine // Setting the stainless API key is optional, but may be required // to authenticate requests to the Stainless API. const response = await fetch( - readEnv("CODE_MODE_INSTRUCTIONS_URL") ?? - 'https://api.stainless.com/api/ai/instructions/imagekit', + readEnv('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/imagekit', { - method: "GET", - headers: { ...( stainlessApiKey && { Authorization: stainlessApiKey } ) } - } - ) + method: 'GET', + headers: { ...(stainlessApiKey && { Authorization: stainlessApiKey }) }, + }, + ); let instructions: string | undefined; if (!response.ok) { getLogger().warn( - "Warning: failed to retrieve MCP server instructions. Proceeding with default instructions..." - ) + 'Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...', + ); - instructions = "\n This is the imagekit MCP server.\n\n Available tools:\n - search_docs: Search SDK documentation to find the right methods and parameters.\n - execute: Run TypeScript code against a pre-authenticated SDK client. Define an async run(client) function.\n\n Workflow:\n - If unsure about the API, call search_docs first.\n - Write complete solutions in a single execute call when possible. For large datasets, use API filters to narrow results or paginate within a single execute block.\n - If execute returns an error, read the error and fix your code rather than retrying the same approach.\n - Variables do not persist between execute calls. Return or log all data you need.\n - Individual HTTP requests to the API have a 30-second timeout. If a request times out, try a smaller query or add filters.\n - Code execution has a total timeout of approximately 5 minutes. If your code times out, simplify it or break it into smaller steps.\n "; + instructions = + '\n This is the imagekit MCP server.\n\n Available tools:\n - search_docs: Search SDK documentation to find the right methods and parameters.\n - execute: Run TypeScript code against a pre-authenticated SDK client. Define an async run(client) function.\n\n Workflow:\n - If unsure about the API, call search_docs first.\n - Write complete solutions in a single execute call when possible. For large datasets, use API filters to narrow results or paginate within a single execute block.\n - If execute returns an error, read the error and fix your code rather than retrying the same approach.\n - Variables do not persist between execute calls. Return or log all data you need.\n - Individual HTTP requests to the API have a 30-second timeout. If a request times out, try a smaller query or add filters.\n - Code execution has a total timeout of approximately 5 minutes. If your code times out, simplify it or break it into smaller steps.\n '; } - instructions ??= (await response.json() as { instructions: string }).instructions; + instructions ??= ((await response.json()) as { instructions: string }).instructions; return instructions; } diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 1df6d6ad..828a0523 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -51,2787 +51,3305 @@ type SearchResult = { const EMBEDDED_METHODS: MethodEntry[] = [ { - "name": "create", - "endpoint": "/v1/customMetadataFields", - "httpMethod": "post", - "summary": "Create new field", - "description": "This API creates a new custom metadata field. Once a custom metadata field is created either through this API or using the dashboard UI, its value can be set on the assets. The value of a field for an asset can be set using the media library UI or programmatically through upload or update assets API.\n", - "stainlessPath": "(resource) customMetadataFields > (method) create", - "qualified": "client.customMetadataFields.create", - "params": [ - "label: string;", - "name: string;", - "schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; };" + name: 'create', + endpoint: '/v1/customMetadataFields', + httpMethod: 'post', + summary: 'Create new field', + description: + 'This API creates a new custom metadata field. Once a custom metadata field is created either through this API or using the dashboard UI, its value can be set on the assets. The value of a field for an asset can be set using the media library UI or programmatically through upload or update assets API.\n', + stainlessPath: '(resource) customMetadataFields > (method) create', + qualified: 'client.customMetadataFields.create', + params: [ + 'label: string;', + 'name: string;', + "schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; };", ], - "response": "{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }", - "markdown": "## create\n\n`client.customMetadataFields.create(label: string, name: string, schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }): { id: string; label: string; name: string; schema: object; }`\n\n**post** `/v1/customMetadataFields`\n\nThis API creates a new custom metadata field. Once a custom metadata field is created either through this API or using the dashboard UI, its value can be set on the assets. The value of a field for an asset can be set using the media library UI or programmatically through upload or update assets API.\n\n\n### Parameters\n\n- `label: string`\n Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI.\n\n- `name: string`\n API name of the custom metadata field. This should be unique across all (including deleted) custom metadata fields.\n\n- `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n - `type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'`\n Type of the custom metadata field.\n - `defaultValue?: string | number | boolean | string | number | boolean[]`\n The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field.\n\n - `isValueRequired?: boolean`\n Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body.\n\n - `maxLength?: number`\n Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `maxValue?: string | number`\n Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `minLength?: number`\n Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `minValue?: string | number`\n Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `selectOptions?: string | number | boolean[]`\n An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }`\n Object containing details of a custom metadata field.\n\n - `id: string`\n - `label: string`\n - `name: string`\n - `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.create({\n label: 'price',\n name: 'price',\n schema: { type: 'Number' },\n});\n\nconsole.log(customMetadataField);\n```", - "perLanguage": { - "typescript": { - "method": "client.customMetadataFields.create", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.create({\n label: 'price',\n name: 'price',\n schema: {\n type: 'Number',\n minValue: 1000,\n maxValue: 3000,\n },\n});\n\nconsole.log(customMetadataField.id);" - }, - "python": { - "method": "custom_metadata_fields.create", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.create(\n label=\"price\",\n name=\"price\",\n schema={\n \"type\": \"Number\",\n \"min_value\": 1000,\n \"max_value\": 3000,\n },\n)\nprint(custom_metadata_field.id)" - }, - "java": { - "method": "customMetadataFields().create", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder()\n .label(\"price\")\n .name(\"price\")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build();\n CustomMetadataField customMetadataField = client.customMetadataFields().create(params);\n }\n}" - }, - "kotlin": { - "method": "customMetadataFields().create", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: CustomMetadataFieldCreateParams = CustomMetadataFieldCreateParams.builder()\n .label(\"price\")\n .name(\"price\")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build()\n val customMetadataField: CustomMetadataField = client.customMetadataFields().create(params)\n}" - }, - "go": { - "method": "client.CustomMetadataFields.New", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.New(context.TODO(), imagekit.CustomMetadataFieldNewParams{\n\t\tLabel: \"price\",\n\t\tName: \"price\",\n\t\tSchema: imagekit.CustomMetadataFieldNewParamsSchema{\n\t\t\tType: \"Number\",\n\t\t\tMinValue: imagekit.CustomMetadataFieldNewParamsSchemaMinValueUnion{\n\t\t\t\tOfFloat: imagekit.Float(1000),\n\t\t\t},\n\t\t\tMaxValue: imagekit.CustomMetadataFieldNewParamsSchemaMaxValueUnion{\n\t\t\t\tOfFloat: imagekit.Float(3000),\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", customMetadataField.ID)\n}\n" - }, - "ruby": { - "method": "custom_metadata_fields.create", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.create(label: \"price\", name: \"price\", schema: {type: :Number})\n\nputs(custom_metadata_field)" - }, - "cli": { - "method": "customMetadataFields create", - "example": "imagekit custom-metadata-fields create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --label price \\\n --name price \\\n --schema '{type: Number}'" - }, - "php": { - "method": "customMetadataFields->create", - "example": "customMetadataFields->create(\n label: 'price',\n name: 'price',\n schema: [\n 'type' => 'Number',\n 'defaultValue' => [true, 10, 'Hello'],\n 'isValueRequired' => true,\n 'maxLength' => 0,\n 'maxValue' => 3000,\n 'minLength' => 0,\n 'minValue' => 1000,\n 'selectOptions' => ['small', 'medium', 'large', 30, 40, true],\n ],\n);\n\nvar_dump($customMetadataField);" - }, - "csharp": { - "method": "CustomMetadataFields.Create", - "example": "CustomMetadataFieldCreateParams parameters = new()\n{\n Label = \"price\",\n Name = \"price\",\n Schema = new()\n {\n Type = Type.Number,\n DefaultValue = new(\n\n [\n new DefaultValueItem(true),\n new DefaultValueItem(10),\n new DefaultValueItem(\"Hello\"),\n ]\n ),\n IsValueRequired = true,\n MaxLength = 0,\n MaxValue = 3000,\n MinLength = 0,\n MinValue = 1000,\n SelectOptions =\n [\n \"small\", \"medium\", \"large\", 30, 40, true\n ],\n },\n};\n\nvar customMetadataField = await client.CustomMetadataFields.Create(parameters);\n\nConsole.WriteLine(customMetadataField);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/customMetadataFields \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"label\": \"price\",\n \"name\": \"price\",\n \"schema\": {\n \"type\": \"Number\",\n \"maxValue\": 3000,\n \"minValue\": 1000\n }\n }'" - } - } + response: + "{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }", + markdown: + "## create\n\n`client.customMetadataFields.create(label: string, name: string, schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }): { id: string; label: string; name: string; schema: object; }`\n\n**post** `/v1/customMetadataFields`\n\nThis API creates a new custom metadata field. Once a custom metadata field is created either through this API or using the dashboard UI, its value can be set on the assets. The value of a field for an asset can be set using the media library UI or programmatically through upload or update assets API.\n\n\n### Parameters\n\n- `label: string`\n Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI.\n\n- `name: string`\n API name of the custom metadata field. This should be unique across all (including deleted) custom metadata fields.\n\n- `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n - `type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'`\n Type of the custom metadata field.\n - `defaultValue?: string | number | boolean | string | number | boolean[]`\n The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field.\n\n - `isValueRequired?: boolean`\n Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body.\n\n - `maxLength?: number`\n Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `maxValue?: string | number`\n Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `minLength?: number`\n Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `minValue?: string | number`\n Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `selectOptions?: string | number | boolean[]`\n An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }`\n Object containing details of a custom metadata field.\n\n - `id: string`\n - `label: string`\n - `name: string`\n - `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.create({\n label: 'price',\n name: 'price',\n schema: { type: 'Number' },\n});\n\nconsole.log(customMetadataField);\n```", + perLanguage: { + typescript: { + method: 'client.customMetadataFields.create', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.create({\n label: 'price',\n name: 'price',\n schema: {\n type: 'Number',\n minValue: 1000,\n maxValue: 3000,\n },\n});\n\nconsole.log(customMetadataField.id);", + }, + python: { + method: 'custom_metadata_fields.create', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.create(\n label="price",\n name="price",\n schema={\n "type": "Number",\n "min_value": 1000,\n "max_value": 3000,\n },\n)\nprint(custom_metadata_field.id)', + }, + java: { + method: 'customMetadataFields().create', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build();\n CustomMetadataField customMetadataField = client.customMetadataFields().create(params);\n }\n}', + }, + kotlin: { + method: 'customMetadataFields().create', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: CustomMetadataFieldCreateParams = CustomMetadataFieldCreateParams.builder()\n .label("price")\n .name("price")\n .schema(CustomMetadataFieldCreateParams.Schema.builder()\n .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER)\n .build())\n .build()\n val customMetadataField: CustomMetadataField = client.customMetadataFields().create(params)\n}', + }, + go: { + method: 'client.CustomMetadataFields.New', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.New(context.TODO(), imagekit.CustomMetadataFieldNewParams{\n\t\tLabel: "price",\n\t\tName: "price",\n\t\tSchema: imagekit.CustomMetadataFieldNewParamsSchema{\n\t\t\tType: "Number",\n\t\t\tMinValue: imagekit.CustomMetadataFieldNewParamsSchemaMinValueUnion{\n\t\t\t\tOfFloat: imagekit.Float(1000),\n\t\t\t},\n\t\t\tMaxValue: imagekit.CustomMetadataFieldNewParamsSchemaMaxValueUnion{\n\t\t\t\tOfFloat: imagekit.Float(3000),\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataField.ID)\n}\n', + }, + ruby: { + method: 'custom_metadata_fields.create', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.create(label: "price", name: "price", schema: {type: :Number})\n\nputs(custom_metadata_field)', + }, + cli: { + method: 'customMetadataFields create', + example: + "imagekit custom-metadata-fields create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --label price \\\n --name price \\\n --schema '{type: Number}'", + }, + php: { + method: 'customMetadataFields->create', + example: + "customMetadataFields->create(\n label: 'price',\n name: 'price',\n schema: [\n 'type' => 'Number',\n 'defaultValue' => [true, 10, 'Hello'],\n 'isValueRequired' => true,\n 'maxLength' => 0,\n 'maxValue' => 3000,\n 'minLength' => 0,\n 'minValue' => 1000,\n 'selectOptions' => ['small', 'medium', 'large', 30, 40, true],\n ],\n);\n\nvar_dump($customMetadataField);", + }, + csharp: { + method: 'CustomMetadataFields.Create', + example: + 'CustomMetadataFieldCreateParams parameters = new()\n{\n Label = "price",\n Name = "price",\n Schema = new()\n {\n Type = Type.Number,\n DefaultValue = new(\n\n [\n new DefaultValueItem(true),\n new DefaultValueItem(10),\n new DefaultValueItem("Hello"),\n ]\n ),\n IsValueRequired = true,\n MaxLength = 0,\n MaxValue = 3000,\n MinLength = 0,\n MinValue = 1000,\n SelectOptions =\n [\n "small", "medium", "large", 30, 40, true\n ],\n },\n};\n\nvar customMetadataField = await client.CustomMetadataFields.Create(parameters);\n\nConsole.WriteLine(customMetadataField);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/customMetadataFields \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "label": "price",\n "name": "price",\n "schema": {\n "type": "Number",\n "maxValue": 3000,\n "minValue": 1000\n }\n }\'', + }, + }, }, { - "name": "list", - "endpoint": "/v1/customMetadataFields", - "httpMethod": "get", - "summary": "List all fields", - "description": "This API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response.\n\nYou can also filter results by a specific folder path to retrieve custom metadata fields applicable at that location. This path-specific filtering is useful when using the **Path policy** feature to determine which custom metadata fields are selected for a given path.\n", - "stainlessPath": "(resource) customMetadataFields > (method) list", - "qualified": "client.customMetadataFields.list", - "params": [ - "folderPath?: string;", - "includeDeleted?: boolean;" - ], - "response": "{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }[]", - "markdown": "## list\n\n`client.customMetadataFields.list(folderPath?: string, includeDeleted?: boolean): object[]`\n\n**get** `/v1/customMetadataFields`\n\nThis API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response.\n\nYou can also filter results by a specific folder path to retrieve custom metadata fields applicable at that location. This path-specific filtering is useful when using the **Path policy** feature to determine which custom metadata fields are selected for a given path.\n\n\n### Parameters\n\n- `folderPath?: string`\n The folder path (e.g., `/path/to/folder`) for which to retrieve applicable custom metadata fields. Useful for determining path-specific field selections when the [Path policy](https://imagekit.io/docs/dam/path-policy) feature is in use.\n\n\n- `includeDeleted?: boolean`\n Set it to `true` to include deleted field objects in the API response.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataFields = await client.customMetadataFields.list();\n\nconsole.log(customMetadataFields);\n```", - "perLanguage": { - "typescript": { - "method": "client.customMetadataFields.list", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataFields = await client.customMetadataFields.list();\n\nconsole.log(customMetadataFields);" - }, - "python": { - "method": "custom_metadata_fields.list", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\ncustom_metadata_fields = client.custom_metadata_fields.list()\nprint(custom_metadata_fields)" - }, - "java": { - "method": "customMetadataFields().list", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List customMetadataFields = client.customMetadataFields().list();\n }\n}" - }, - "kotlin": { - "method": "customMetadataFields().list", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataFields: List = client.customMetadataFields().list()\n}" - }, - "go": { - "method": "client.CustomMetadataFields.List", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tcustomMetadataFields, err := client.CustomMetadataFields.List(context.TODO(), imagekit.CustomMetadataFieldListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", customMetadataFields)\n}\n" - }, - "ruby": { - "method": "custom_metadata_fields.list", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\ncustom_metadata_fields = image_kit.custom_metadata_fields.list\n\nputs(custom_metadata_fields)" - }, - "cli": { - "method": "customMetadataFields list", - "example": "imagekit custom-metadata-fields list \\\n --private-key 'My Private Key' \\\n --password 'My Password'" - }, - "php": { - "method": "customMetadataFields->list", - "example": "customMetadataFields->list(\n folderPath: 'folderPath', includeDeleted: true\n);\n\nvar_dump($customMetadataFields);" - }, - "csharp": { - "method": "CustomMetadataFields.List", - "example": "CustomMetadataFieldListParams parameters = new();\n\nvar customMetadataFields = await client.CustomMetadataFields.List(parameters);\n\nConsole.WriteLine(customMetadataFields);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/customMetadataFields \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'list', + endpoint: '/v1/customMetadataFields', + httpMethod: 'get', + summary: 'List all fields', + description: + 'This API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response.\n\nYou can also filter results by a specific folder path to retrieve custom metadata fields applicable at that location. This path-specific filtering is useful when using the **Path policy** feature to determine which custom metadata fields are selected for a given path.\n', + stainlessPath: '(resource) customMetadataFields > (method) list', + qualified: 'client.customMetadataFields.list', + params: ['folderPath?: string;', 'includeDeleted?: boolean;'], + response: + "{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }[]", + markdown: + "## list\n\n`client.customMetadataFields.list(folderPath?: string, includeDeleted?: boolean): object[]`\n\n**get** `/v1/customMetadataFields`\n\nThis API returns the array of created custom metadata field objects. By default the API returns only non deleted field objects, but you can include deleted fields in the API response.\n\nYou can also filter results by a specific folder path to retrieve custom metadata fields applicable at that location. This path-specific filtering is useful when using the **Path policy** feature to determine which custom metadata fields are selected for a given path.\n\n\n### Parameters\n\n- `folderPath?: string`\n The folder path (e.g., `/path/to/folder`) for which to retrieve applicable custom metadata fields. Useful for determining path-specific field selections when the [Path policy](https://imagekit.io/docs/dam/path-policy) feature is in use.\n\n\n- `includeDeleted?: boolean`\n Set it to `true` to include deleted field objects in the API response.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataFields = await client.customMetadataFields.list();\n\nconsole.log(customMetadataFields);\n```", + perLanguage: { + typescript: { + method: 'client.customMetadataFields.list', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataFields = await client.customMetadataFields.list();\n\nconsole.log(customMetadataFields);", + }, + python: { + method: 'custom_metadata_fields.list', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_fields = client.custom_metadata_fields.list()\nprint(custom_metadata_fields)', + }, + java: { + method: 'customMetadataFields().list', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List customMetadataFields = client.customMetadataFields().list();\n }\n}', + }, + kotlin: { + method: 'customMetadataFields().list', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataFields: List = client.customMetadataFields().list()\n}', + }, + go: { + method: 'client.CustomMetadataFields.List', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataFields, err := client.CustomMetadataFields.List(context.TODO(), imagekit.CustomMetadataFieldListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataFields)\n}\n', + }, + ruby: { + method: 'custom_metadata_fields.list', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ncustom_metadata_fields = image_kit.custom_metadata_fields.list\n\nputs(custom_metadata_fields)', + }, + cli: { + method: 'customMetadataFields list', + example: + "imagekit custom-metadata-fields list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'customMetadataFields->list', + example: + "customMetadataFields->list(\n folderPath: 'folderPath', includeDeleted: true\n);\n\nvar_dump($customMetadataFields);", + }, + csharp: { + method: 'CustomMetadataFields.List', + example: + 'CustomMetadataFieldListParams parameters = new();\n\nvar customMetadataFields = await client.CustomMetadataFields.List(parameters);\n\nConsole.WriteLine(customMetadataFields);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/customMetadataFields \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "update", - "endpoint": "/v1/customMetadataFields/{id}", - "httpMethod": "patch", - "summary": "Update existing field", - "description": "This API updates the label or schema of an existing custom metadata field.\n", - "stainlessPath": "(resource) customMetadataFields > (method) update", - "qualified": "client.customMetadataFields.update", - "params": [ - "id: string;", - "label?: string;", - "schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; };" + name: 'update', + endpoint: '/v1/customMetadataFields/{id}', + httpMethod: 'patch', + summary: 'Update existing field', + description: 'This API updates the label or schema of an existing custom metadata field.\n', + stainlessPath: '(resource) customMetadataFields > (method) update', + qualified: 'client.customMetadataFields.update', + params: [ + 'id: string;', + 'label?: string;', + 'schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; };', ], - "response": "{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }", - "markdown": "## update\n\n`client.customMetadataFields.update(id: string, label?: string, schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }): { id: string; label: string; name: string; schema: object; }`\n\n**patch** `/v1/customMetadataFields/{id}`\n\nThis API updates the label or schema of an existing custom metadata field.\n\n\n### Parameters\n\n- `id: string`\n\n- `label?: string`\n Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI. This parameter is required if `schema` is not provided.\n\n- `schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n An object that describes the rules for the custom metadata key. This parameter is required if `label` is not provided. Note: `type` cannot be updated and will be ignored if sent with the `schema`. The schema will be validated as per the existing `type`.\n\n - `defaultValue?: string | number | boolean | string | number | boolean[]`\n The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field.\n\n - `isValueRequired?: boolean`\n Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body.\n\n - `maxLength?: number`\n Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `maxValue?: string | number`\n Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `minLength?: number`\n Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `minValue?: string | number`\n Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `selectOptions?: string | number | boolean[]`\n An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }`\n Object containing details of a custom metadata field.\n\n - `id: string`\n - `label: string`\n - `name: string`\n - `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.update('id');\n\nconsole.log(customMetadataField);\n```", - "perLanguage": { - "typescript": { - "method": "client.customMetadataFields.update", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.update('id', {\n label: 'price',\n schema: { minValue: 1000, maxValue: 3000 },\n});\n\nconsole.log(customMetadataField.id);" - }, - "python": { - "method": "custom_metadata_fields.update", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.update(\n id=\"id\",\n label=\"price\",\n schema={\n \"min_value\": 1000,\n \"max_value\": 3000,\n },\n)\nprint(custom_metadata_field.id)" - }, - "java": { - "method": "customMetadataFields().update", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataField customMetadataField = client.customMetadataFields().update(\"id\");\n }\n}" - }, - "kotlin": { - "method": "customMetadataFields().update", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataField: CustomMetadataField = client.customMetadataFields().update(\"id\")\n}" - }, - "go": { - "method": "client.CustomMetadataFields.Update", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.Update(\n\t\tcontext.TODO(),\n\t\t\"id\",\n\t\timagekit.CustomMetadataFieldUpdateParams{\n\t\t\tLabel: imagekit.String(\"price\"),\n\t\t\tSchema: imagekit.CustomMetadataFieldUpdateParamsSchema{\n\t\t\t\tMinValue: imagekit.CustomMetadataFieldUpdateParamsSchemaMinValueUnion{\n\t\t\t\t\tOfFloat: imagekit.Float(1000),\n\t\t\t\t},\n\t\t\t\tMaxValue: imagekit.CustomMetadataFieldUpdateParamsSchemaMaxValueUnion{\n\t\t\t\t\tOfFloat: imagekit.Float(3000),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", customMetadataField.ID)\n}\n" - }, - "ruby": { - "method": "custom_metadata_fields.update", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.update(\"id\")\n\nputs(custom_metadata_field)" - }, - "cli": { - "method": "customMetadataFields update", - "example": "imagekit custom-metadata-fields update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" - }, - "php": { - "method": "customMetadataFields->update", - "example": "customMetadataFields->update(\n 'id',\n label: 'price',\n schema: [\n 'defaultValue' => [true, 10, 'Hello'],\n 'isValueRequired' => true,\n 'maxLength' => 0,\n 'maxValue' => 3000,\n 'minLength' => 0,\n 'minValue' => 1000,\n 'selectOptions' => ['small', 'medium', 'large', 30, 40, true],\n ],\n);\n\nvar_dump($customMetadataField);" - }, - "csharp": { - "method": "CustomMetadataFields.Update", - "example": "CustomMetadataFieldUpdateParams parameters = new() { ID = \"id\" };\n\nvar customMetadataField = await client.CustomMetadataFields.Update(parameters);\n\nConsole.WriteLine(customMetadataField);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/customMetadataFields/$ID \\\n -X PATCH \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + response: + "{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }", + markdown: + "## update\n\n`client.customMetadataFields.update(id: string, label?: string, schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }): { id: string; label: string; name: string; schema: object; }`\n\n**patch** `/v1/customMetadataFields/{id}`\n\nThis API updates the label or schema of an existing custom metadata field.\n\n\n### Parameters\n\n- `id: string`\n\n- `label?: string`\n Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI. This parameter is required if `schema` is not provided.\n\n- `schema?: { defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n An object that describes the rules for the custom metadata key. This parameter is required if `label` is not provided. Note: `type` cannot be updated and will be ignored if sent with the `schema`. The schema will be validated as per the existing `type`.\n\n - `defaultValue?: string | number | boolean | string | number | boolean[]`\n The default value for this custom metadata field. This property is only required if `isValueRequired` property is set to `true`. The value should match the `type` of custom metadata field.\n\n - `isValueRequired?: boolean`\n Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body.\n\n - `maxLength?: number`\n Maximum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `maxValue?: string | number`\n Maximum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `minLength?: number`\n Minimum length of string. Only set this property if `type` is set to `Text` or `Textarea`.\n\n - `minValue?: string | number`\n Minimum value of the field. Only set this property if field type is `Date` or `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type field, set the minimum numeric value.\n\n - `selectOptions?: string | number | boolean[]`\n An array of allowed values. This property is only required if `type` property is set to `SingleSelect` or `MultiSelect`.\n\n\n### Returns\n\n- `{ id: string; label: string; name: string; schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }; }`\n Object containing details of a custom metadata field.\n\n - `id: string`\n - `label: string`\n - `name: string`\n - `schema: { type: 'Text' | 'Textarea' | 'Number' | 'Date' | 'Boolean' | 'SingleSelect' | 'MultiSelect'; defaultValue?: string | number | boolean | string | number | boolean[]; isValueRequired?: boolean; maxLength?: number; maxValue?: string | number; minLength?: number; minValue?: string | number; selectOptions?: string | number | boolean[]; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.update('id');\n\nconsole.log(customMetadataField);\n```", + perLanguage: { + typescript: { + method: 'client.customMetadataFields.update', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.update('id', {\n label: 'price',\n schema: { minValue: 1000, maxValue: 3000 },\n});\n\nconsole.log(customMetadataField.id);", + }, + python: { + method: 'custom_metadata_fields.update', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.update(\n id="id",\n label="price",\n schema={\n "min_value": 1000,\n "max_value": 3000,\n },\n)\nprint(custom_metadata_field.id)', + }, + java: { + method: 'customMetadataFields().update', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataField;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataField customMetadataField = client.customMetadataFields().update("id");\n }\n}', + }, + kotlin: { + method: 'customMetadataFields().update', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataField\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataField: CustomMetadataField = client.customMetadataFields().update("id")\n}', + }, + go: { + method: 'client.CustomMetadataFields.Update', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.CustomMetadataFieldUpdateParams{\n\t\t\tLabel: imagekit.String("price"),\n\t\t\tSchema: imagekit.CustomMetadataFieldUpdateParamsSchema{\n\t\t\t\tMinValue: imagekit.CustomMetadataFieldUpdateParamsSchemaMinValueUnion{\n\t\t\t\t\tOfFloat: imagekit.Float(1000),\n\t\t\t\t},\n\t\t\t\tMaxValue: imagekit.CustomMetadataFieldUpdateParamsSchemaMaxValueUnion{\n\t\t\t\t\tOfFloat: imagekit.Float(3000),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataField.ID)\n}\n', + }, + ruby: { + method: 'custom_metadata_fields.update', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.update("id")\n\nputs(custom_metadata_field)', + }, + cli: { + method: 'customMetadataFields update', + example: + "imagekit custom-metadata-fields update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'customMetadataFields->update', + example: + "customMetadataFields->update(\n 'id',\n label: 'price',\n schema: [\n 'defaultValue' => [true, 10, 'Hello'],\n 'isValueRequired' => true,\n 'maxLength' => 0,\n 'maxValue' => 3000,\n 'minLength' => 0,\n 'minValue' => 1000,\n 'selectOptions' => ['small', 'medium', 'large', 30, 40, true],\n ],\n);\n\nvar_dump($customMetadataField);", + }, + csharp: { + method: 'CustomMetadataFields.Update', + example: + 'CustomMetadataFieldUpdateParams parameters = new() { ID = "id" };\n\nvar customMetadataField = await client.CustomMetadataFields.Update(parameters);\n\nConsole.WriteLine(customMetadataField);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/customMetadataFields/$ID \\\n -X PATCH \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "delete", - "endpoint": "/v1/customMetadataFields/{id}", - "httpMethod": "delete", - "summary": "Delete a field", - "description": "This API deletes a custom metadata field. Even after deleting a custom metadata field, you cannot create any new custom metadata field with the same name.\n", - "stainlessPath": "(resource) customMetadataFields > (method) delete", - "qualified": "client.customMetadataFields.delete", - "params": [ - "id: string;" - ], - "response": "{ }", - "markdown": "## delete\n\n`client.customMetadataFields.delete(id: string): { }`\n\n**delete** `/v1/customMetadataFields/{id}`\n\nThis API deletes a custom metadata field. Even after deleting a custom metadata field, you cannot create any new custom metadata field with the same name.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.delete('id');\n\nconsole.log(customMetadataField);\n```", - "perLanguage": { - "typescript": { - "method": "client.customMetadataFields.delete", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.delete('id');\n\nconsole.log(customMetadataField);" - }, - "python": { - "method": "custom_metadata_fields.delete", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.delete(\n \"id\",\n)\nprint(custom_metadata_field)" - }, - "java": { - "method": "customMetadataFields().delete", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteParams;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldDeleteResponse customMetadataField = client.customMetadataFields().delete(\"id\");\n }\n}" - }, - "kotlin": { - "method": "customMetadataFields().delete", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataField: CustomMetadataFieldDeleteResponse = client.customMetadataFields().delete(\"id\")\n}" - }, - "go": { - "method": "client.CustomMetadataFields.Delete", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.Delete(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", customMetadataField)\n}\n" - }, - "ruby": { - "method": "custom_metadata_fields.delete", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.delete(\"id\")\n\nputs(custom_metadata_field)" - }, - "cli": { - "method": "customMetadataFields delete", - "example": "imagekit custom-metadata-fields delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" - }, - "php": { - "method": "customMetadataFields->delete", - "example": "customMetadataFields->delete('id');\n\nvar_dump($customMetadataField);" - }, - "csharp": { - "method": "CustomMetadataFields.Delete", - "example": "CustomMetadataFieldDeleteParams parameters = new() { ID = \"id\" };\n\nvar customMetadataField = await client.CustomMetadataFields.Delete(parameters);\n\nConsole.WriteLine(customMetadataField);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/customMetadataFields/$ID \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'delete', + endpoint: '/v1/customMetadataFields/{id}', + httpMethod: 'delete', + summary: 'Delete a field', + description: + 'This API deletes a custom metadata field. Even after deleting a custom metadata field, you cannot create any new custom metadata field with the same name.\n', + stainlessPath: '(resource) customMetadataFields > (method) delete', + qualified: 'client.customMetadataFields.delete', + params: ['id: string;'], + response: '{ }', + markdown: + "## delete\n\n`client.customMetadataFields.delete(id: string): { }`\n\n**delete** `/v1/customMetadataFields/{id}`\n\nThis API deletes a custom metadata field. Even after deleting a custom metadata field, you cannot create any new custom metadata field with the same name.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst customMetadataField = await client.customMetadataFields.delete('id');\n\nconsole.log(customMetadataField);\n```", + perLanguage: { + typescript: { + method: 'client.customMetadataFields.delete', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst customMetadataField = await client.customMetadataFields.delete('id');\n\nconsole.log(customMetadataField);", + }, + python: { + method: 'custom_metadata_fields.delete', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ncustom_metadata_field = client.custom_metadata_fields.delete(\n "id",\n)\nprint(custom_metadata_field)', + }, + java: { + method: 'customMetadataFields().delete', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteParams;\nimport io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n CustomMetadataFieldDeleteResponse customMetadataField = client.customMetadataFields().delete("id");\n }\n}', + }, + kotlin: { + method: 'customMetadataFields().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams\nimport com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val customMetadataField: CustomMetadataFieldDeleteResponse = client.customMetadataFields().delete("id")\n}', + }, + go: { + method: 'client.CustomMetadataFields.Delete', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tcustomMetadataField, err := client.CustomMetadataFields.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customMetadataField)\n}\n', + }, + ruby: { + method: 'custom_metadata_fields.delete', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ncustom_metadata_field = image_kit.custom_metadata_fields.delete("id")\n\nputs(custom_metadata_field)', + }, + cli: { + method: 'customMetadataFields delete', + example: + "imagekit custom-metadata-fields delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'customMetadataFields->delete', + example: + "customMetadataFields->delete('id');\n\nvar_dump($customMetadataField);", + }, + csharp: { + method: 'CustomMetadataFields.Delete', + example: + 'CustomMetadataFieldDeleteParams parameters = new() { ID = "id" };\n\nvar customMetadataField = await client.CustomMetadataFields.Delete(parameters);\n\nConsole.WriteLine(customMetadataField);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/customMetadataFields/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "upload", - "endpoint": "/api/v1/files/upload", - "httpMethod": "post", - "summary": "Upload file V1", - "description": "ImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token`, `signature`, and `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) about how to implement client-side file upload.\n\nThe [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the entire payload using JWT.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n", - "stainlessPath": "(resource) files > (method) upload", - "qualified": "client.files.upload", - "params": [ - "file: string;", - "fileName: string;", - "token?: string;", - "checks?: string;", - "customCoordinates?: string;", - "customMetadata?: object;", - "description?: string;", - "expire?: number;", + name: 'upload', + endpoint: '/api/v1/files/upload', + httpMethod: 'post', + summary: 'Upload file V1', + description: + 'ImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token`, `signature`, and `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) about how to implement client-side file upload.\n\nThe [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the entire payload using JWT.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n', + stainlessPath: '(resource) files > (method) upload', + qualified: 'client.files.upload', + params: [ + 'file: string;', + 'fileName: string;', + 'token?: string;', + 'checks?: string;', + 'customCoordinates?: string;', + 'customMetadata?: object;', + 'description?: string;', + 'expire?: number;', "extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[];", - "folder?: string;", - "isPrivateFile?: boolean;", - "isPublished?: boolean;", - "overwriteAITags?: boolean;", - "overwriteCustomMetadata?: boolean;", - "overwriteFile?: boolean;", - "overwriteTags?: boolean;", - "publicKey?: string;", - "responseFields?: string[];", - "signature?: string;", - "tags?: string[];", + 'folder?: string;', + 'isPrivateFile?: boolean;', + 'isPublished?: boolean;', + 'overwriteAITags?: boolean;', + 'overwriteCustomMetadata?: boolean;', + 'overwriteFile?: boolean;', + 'overwriteTags?: boolean;', + 'publicKey?: string;', + 'responseFields?: string[];', + 'signature?: string;', + 'tags?: string[];', "transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; };", - "useUniqueFileName?: boolean;", - "webhookUrl?: string;" + 'useUniqueFileName?: boolean;', + 'webhookUrl?: string;', ], - "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", - "markdown": "## upload\n\n`client.files.upload(file: string, fileName: string, token?: string, checks?: string, customCoordinates?: string, customMetadata?: object, description?: string, expire?: number, extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[], folder?: string, isPrivateFile?: boolean, isPublished?: boolean, overwriteAITags?: boolean, overwriteCustomMetadata?: boolean, overwriteFile?: boolean, overwriteTags?: boolean, publicKey?: string, responseFields?: string[], signature?: string, tags?: string[], transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }, useUniqueFileName?: boolean, webhookUrl?: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: object; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: metadata; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**post** `/api/v1/files/upload`\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token`, `signature`, and `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) about how to implement client-side file upload.\n\nThe [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the entire payload using JWT.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n\n\n### Parameters\n\n- `file: string`\n The API accepts any of the following:\n\n- **Binary data** – send the raw bytes as `multipart/form-data`.\n- **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.\n- **Base64 string** – the file encoded as a Base64 data URI or plain Base64.\n\nWhen supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.\n\n\n- `fileName: string`\n The name with which the file has to be uploaded.\nThe file name can contain:\n\n - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`.\n - Special Characters: `.`, `-`\n\nAny other character including space will be replaced by `_`\n\n\n- `token?: string`\n A unique value that the ImageKit.io server will use to recognize and prevent subsequent retries for the same request. We suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. This field is only required for authentication when uploading a file from the client side.\n\n**Note**: Sending a value that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new value for this field.\n\n\n- `checks?: string`\n Server-side checks to run on the asset.\nRead more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks).\n\n\n- `customCoordinates?: string`\n Define an important area in the image. This is only relevant for image type files.\n\n - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100`\n - Can be used with fo-customtransformation.\n - If this field is not specified and the file is overwritten, then customCoordinates will be removed.\n\n\n- `customMetadata?: object`\n JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.\n\n\n- `description?: string`\n Optional text to describe the contents of the file.\n\n\n- `expire?: number`\n The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It should be in seconds. This field is only required for authentication when uploading a file from the client side.\n\n\n- `extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[]`\n Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.\n\n\n- `folder?: string`\n The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created.\n\nThe folder name can contain:\n\n - Alphanumeric Characters: `a-z` , `A-Z` , `0-9`\n - Special Characters: `/` , `_` , `-`\n\nUsing multiple `/` creates a nested folder.\n\n\n- `isPrivateFile?: boolean`\n Whether to mark the file as private or not.\n\nIf `true`, the file is marked as private and is accessible only using named transformation or signed URL.\n\n\n- `isPublished?: boolean`\n Whether to upload file as published or not.\n\nIf `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published.\n\nThe option to upload in draft state is only available in custom enterprise pricing plans.\n\n\n- `overwriteAITags?: boolean`\n If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags.\n\n\n- `overwriteCustomMetadata?: boolean`\n If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed.\n\n\n- `overwriteFile?: boolean`\n If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately.\n\n\n- `overwriteTags?: boolean`\n If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed.\n\n\n- `publicKey?: string`\n Your ImageKit.io public key. This field is only required for authentication when uploading a file from the client side.\n\n\n- `responseFields?: string[]`\n Array of response field keys to include in the API response body.\n\n\n- `signature?: string`\n HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn how to create a signature on the page below. This should be in lowercase.\n\nSignature must be calculated on the server-side. This field is only required for authentication when uploading a file from the client side.\n\n\n- `tags?: string[]`\n Set the tags while uploading the file.\nProvide an array of tag strings (e.g. `[\"tag1\", \"tag2\", \"tag3\"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed.\nIf this field is not specified and the file is overwritten, the existing tags will be removed.\n\n\n- `transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }`\n Configure pre-processing (`pre`) and post-processing (`post`) transformations.\n\n- `pre` — applied before the file is uploaded to the Media Library. \n Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress).\n\n- `post` — applied immediately after upload. \n Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay.\n\nYou can mix and match any combination of post-processing types.\n\n - `post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]`\n List of transformations to apply *after* the file is uploaded. \nEach item must match one of the following types:\n`transformation`, `gif-to-video`, `thumbnail`, `abs`.\n\n - `pre?: string`\n Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion.\n\n\n- `useUniqueFileName?: boolean`\n Whether to use a unique filename for this file or not.\n\nIf `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename.\n\nIf `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced.\n\n\n- `webhookUrl?: string`\n The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure.\n\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a successful upload.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnailUrl?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'fileName' });\n\nconsole.log(response);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.upload", - "example": "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);" - }, - "python": { - "method": "files.upload", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.upload(\n file=b\"Example data\",\n file_name=\"fileName\",\n)\nprint(response.video_codec)" - }, - "java": { - "method": "files().upload", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream(\"Example data\".getBytes()))\n .fileName(\"fileName\")\n .build();\n FileUploadResponse response = client.files().upload(params);\n }\n}" - }, - "kotlin": { - "method": "files().upload", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUploadParams = FileUploadParams.builder()\n .file(\"Example data\".byteInputStream())\n .fileName(\"fileName\")\n .build()\n val response: FileUploadResponse = client.files().upload(params)\n}" - }, - "go": { - "method": "client.Files.Upload", - "example": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\tFileName: \"fileName\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.VideoCodec)\n}\n" - }, - "ruby": { - "method": "files.upload", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.upload(file: StringIO.new(\"Example data\"), file_name: \"fileName\")\n\nputs(response)" - }, - "cli": { - "method": "files upload", - "example": "imagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name fileName" - }, - "php": { - "method": "files->upload", - "example": "files->upload(\n file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),\n fileName: 'fileName',\n token: 'token',\n checks: \"\\\"request.folder\\\" : \\\"marketing/\\\"\\n\",\n customCoordinates: 'customCoordinates',\n customMetadata: ['brand' => 'bar', 'color' => 'bar'],\n description: 'Running shoes',\n expire: 0,\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n folder: 'folder',\n isPrivateFile: true,\n isPublished: true,\n overwriteAITags: true,\n overwriteCustomMetadata: true,\n overwriteFile: true,\n overwriteTags: true,\n publicKey: 'publicKey',\n responseFields: ['tags', 'customCoordinates', 'isPrivateFile'],\n signature: 'signature',\n tags: ['t-shirt', 'round-neck', 'men'],\n transformation: [\n 'post' => [\n ['type' => 'thumbnail', 'value' => 'w-150,h-150'],\n [\n 'protocol' => 'dash',\n 'type' => 'abs',\n 'value' => 'sr-240_360_480_720_1080',\n ],\n ],\n 'pre' => 'w-300,h-300,q-80',\n ],\n useUniqueFileName: true,\n webhookURL: 'https://example.com',\n);\n\nvar_dump($response);" - }, - "csharp": { - "method": "Files.Upload", - "example": "FileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes(\"Example data\"),\n FileName = \"fileName\",\n};\n\nvar response = await client.Files.Upload(parameters);\n\nConsole.WriteLine(response);" - }, - "http": { - "example": "curl https://upload.imagekit.io/api/v1/files/upload \\\n -H 'Content-Type: multipart/form-data' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -F 'file=@/path/to/file' \\\n -F fileName=fileName \\\n -F checks='\"request.folder\" : \"marketing/\"\n ' \\\n -F customMetadata='{\"brand\":\"bar\",\"color\":\"bar\"}' \\\n -F description='Running shoes' \\\n -F extensions='[{\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true}},{\"maxTags\":5,\"minConfidence\":95,\"name\":\"google-auto-tagging\"},{\"name\":\"ai-auto-description\"},{\"name\":\"ai-tasks\",\"tasks\":[{\"instruction\":\"What types of clothing items are visible in this image?\",\"type\":\"select_tags\",\"vocabulary\":[\"shirt\",\"tshirt\",\"dress\",\"trousers\",\"jacket\"]},{\"instruction\":\"Is this a luxury or high-end fashion item?\",\"type\":\"yes_no\",\"on_yes\":{\"add_tags\":[\"luxury\",\"premium\"]}}]},{\"id\":\"ext_abc123\",\"name\":\"saved-extension\"}]' \\\n -F responseFields='[\"tags\",\"customCoordinates\",\"isPrivateFile\"]' \\\n -F tags='[\"t-shirt\",\"round-neck\",\"men\"]' \\\n -F transformation='{\"post\":[{\"type\":\"thumbnail\",\"value\":\"w-150,h-150\"},{\"protocol\":\"dash\",\"type\":\"abs\",\"value\":\"sr-240_360_480_720_1080\"}]}'" - } - } + response: + "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", + markdown: + "## upload\n\n`client.files.upload(file: string, fileName: string, token?: string, checks?: string, customCoordinates?: string, customMetadata?: object, description?: string, expire?: number, extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[], folder?: string, isPrivateFile?: boolean, isPublished?: boolean, overwriteAITags?: boolean, overwriteCustomMetadata?: boolean, overwriteFile?: boolean, overwriteTags?: boolean, publicKey?: string, responseFields?: string[], signature?: string, tags?: string[], transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }, useUniqueFileName?: boolean, webhookUrl?: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: object; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: metadata; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**post** `/api/v1/files/upload`\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token`, `signature`, and `expire` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) about how to implement client-side file upload.\n\nThe [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the entire payload using JWT.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n\n\n### Parameters\n\n- `file: string`\n The API accepts any of the following:\n\n- **Binary data** – send the raw bytes as `multipart/form-data`.\n- **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.\n- **Base64 string** – the file encoded as a Base64 data URI or plain Base64.\n\nWhen supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.\n\n\n- `fileName: string`\n The name with which the file has to be uploaded.\nThe file name can contain:\n\n - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`.\n - Special Characters: `.`, `-`\n\nAny other character including space will be replaced by `_`\n\n\n- `token?: string`\n A unique value that the ImageKit.io server will use to recognize and prevent subsequent retries for the same request. We suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. This field is only required for authentication when uploading a file from the client side.\n\n**Note**: Sending a value that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new value for this field.\n\n\n- `checks?: string`\n Server-side checks to run on the asset.\nRead more about [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks).\n\n\n- `customCoordinates?: string`\n Define an important area in the image. This is only relevant for image type files.\n\n - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100`\n - Can be used with fo-customtransformation.\n - If this field is not specified and the file is overwritten, then customCoordinates will be removed.\n\n\n- `customMetadata?: object`\n JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.\n\n\n- `description?: string`\n Optional text to describe the contents of the file.\n\n\n- `expire?: number`\n The time until your signature is valid. It must be a [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It should be in seconds. This field is only required for authentication when uploading a file from the client side.\n\n\n- `extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[]`\n Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.\n\n\n- `folder?: string`\n The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created.\n\nThe folder name can contain:\n\n - Alphanumeric Characters: `a-z` , `A-Z` , `0-9`\n - Special Characters: `/` , `_` , `-`\n\nUsing multiple `/` creates a nested folder.\n\n\n- `isPrivateFile?: boolean`\n Whether to mark the file as private or not.\n\nIf `true`, the file is marked as private and is accessible only using named transformation or signed URL.\n\n\n- `isPublished?: boolean`\n Whether to upload file as published or not.\n\nIf `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published.\n\nThe option to upload in draft state is only available in custom enterprise pricing plans.\n\n\n- `overwriteAITags?: boolean`\n If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags.\n\n\n- `overwriteCustomMetadata?: boolean`\n If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed.\n\n\n- `overwriteFile?: boolean`\n If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately.\n\n\n- `overwriteTags?: boolean`\n If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed.\n\n\n- `publicKey?: string`\n Your ImageKit.io public key. This field is only required for authentication when uploading a file from the client side.\n\n\n- `responseFields?: string[]`\n Array of response field keys to include in the API response body.\n\n\n- `signature?: string`\n HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn how to create a signature on the page below. This should be in lowercase.\n\nSignature must be calculated on the server-side. This field is only required for authentication when uploading a file from the client side.\n\n\n- `tags?: string[]`\n Set the tags while uploading the file.\nProvide an array of tag strings (e.g. `[\"tag1\", \"tag2\", \"tag3\"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed.\nIf this field is not specified and the file is overwritten, the existing tags will be removed.\n\n\n- `transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }`\n Configure pre-processing (`pre`) and post-processing (`post`) transformations.\n\n- `pre` — applied before the file is uploaded to the Media Library. \n Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress).\n\n- `post` — applied immediately after upload. \n Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay.\n\nYou can mix and match any combination of post-processing types.\n\n - `post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]`\n List of transformations to apply *after* the file is uploaded. \nEach item must match one of the following types:\n`transformation`, `gif-to-video`, `thumbnail`, `abs`.\n\n - `pre?: string`\n Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion.\n\n\n- `useUniqueFileName?: boolean`\n Whether to use a unique filename for this file or not.\n\nIf `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename.\n\nIf `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced.\n\n\n- `webhookUrl?: string`\n The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure.\n\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a successful upload.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnailUrl?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'fileName' });\n\nconsole.log(response);\n```", + perLanguage: { + typescript: { + method: 'client.files.upload', + example: + "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);", + }, + python: { + method: 'files.upload', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.upload(\n file=b"Example data",\n file_name="fileName",\n)\nprint(response.video_codec)', + }, + java: { + method: 'files().upload', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.files().upload(params);\n }\n}', + }, + kotlin: { + method: 'files().upload', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUploadParams = FileUploadParams.builder()\n .file("Example data".byteInputStream())\n .fileName("fileName")\n .build()\n val response: FileUploadResponse = client.files().upload(params)\n}', + }, + go: { + method: 'client.Files.Upload', + example: + 'package main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("Example data"))),\n\t\tFileName: "fileName",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n', + }, + ruby: { + method: 'files.upload', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.upload(file: StringIO.new("Example data"), file_name: "fileName")\n\nputs(response)', + }, + cli: { + method: 'files upload', + example: + "imagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name fileName", + }, + php: { + method: 'files->upload', + example: + "files->upload(\n file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),\n fileName: 'fileName',\n token: 'token',\n checks: \"\\\"request.folder\\\" : \\\"marketing/\\\"\\n\",\n customCoordinates: 'customCoordinates',\n customMetadata: ['brand' => 'bar', 'color' => 'bar'],\n description: 'Running shoes',\n expire: 0,\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n folder: 'folder',\n isPrivateFile: true,\n isPublished: true,\n overwriteAITags: true,\n overwriteCustomMetadata: true,\n overwriteFile: true,\n overwriteTags: true,\n publicKey: 'publicKey',\n responseFields: ['tags', 'customCoordinates', 'isPrivateFile'],\n signature: 'signature',\n tags: ['t-shirt', 'round-neck', 'men'],\n transformation: [\n 'post' => [\n ['type' => 'thumbnail', 'value' => 'w-150,h-150'],\n [\n 'protocol' => 'dash',\n 'type' => 'abs',\n 'value' => 'sr-240_360_480_720_1080',\n ],\n ],\n 'pre' => 'w-300,h-300,q-80',\n ],\n useUniqueFileName: true,\n webhookURL: 'https://example.com',\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Upload', + example: + 'FileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes("Example data"),\n FileName = "fileName",\n};\n\nvar response = await client.Files.Upload(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://upload.imagekit.io/api/v1/files/upload \\\n -H \'Content-Type: multipart/form-data\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -F \'file=@/path/to/file\' \\\n -F fileName=fileName \\\n -F checks=\'"request.folder" : "marketing/"\n \' \\\n -F customMetadata=\'{"brand":"bar","color":"bar"}\' \\\n -F description=\'Running shoes\' \\\n -F extensions=\'[{"name":"remove-bg","options":{"add_shadow":true}},{"maxTags":5,"minConfidence":95,"name":"google-auto-tagging"},{"name":"ai-auto-description"},{"name":"ai-tasks","tasks":[{"instruction":"What types of clothing items are visible in this image?","type":"select_tags","vocabulary":["shirt","tshirt","dress","trousers","jacket"]},{"instruction":"Is this a luxury or high-end fashion item?","type":"yes_no","on_yes":{"add_tags":["luxury","premium"]}}]},{"id":"ext_abc123","name":"saved-extension"}]\' \\\n -F responseFields=\'["tags","customCoordinates","isPrivateFile"]\' \\\n -F tags=\'["t-shirt","round-neck","men"]\' \\\n -F transformation=\'{"post":[{"type":"thumbnail","value":"w-150,h-150"},{"protocol":"dash","type":"abs","value":"sr-240_360_480_720_1080"}]}\'', + }, + }, }, { - "name": "get", - "endpoint": "/v1/files/{fileId}/details", - "httpMethod": "get", - "summary": "Get file details", - "description": "This API returns an object with details or attributes about the current version of the file.", - "stainlessPath": "(resource) files > (method) get", - "qualified": "client.files.get", - "params": [ - "fileId: string;" - ], - "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", - "markdown": "## get\n\n`client.files.get(fileId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/details`\n\nThis API returns an object with details or attributes about the current version of the file.\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.get('fileId');\n\nconsole.log(file);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.get", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.get('fileId');\n\nconsole.log(file.videoCodec);" - }, - "python": { - "method": "files.get", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfile = client.files.get(\n \"fileId\",\n)\nprint(file.video_codec)" - }, - "java": { - "method": "files().get", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.FileGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n File file = client.files().get(\"fileId\");\n }\n}" - }, - "kotlin": { - "method": "files().get", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.FileGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val file: File = client.files().get(\"fileId\")\n}" - }, - "go": { - "method": "client.Files.Get", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfile, err := client.Files.Get(context.TODO(), \"fileId\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", file.VideoCodec)\n}\n" - }, - "ruby": { - "method": "files.get", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfile = image_kit.files.get(\"fileId\")\n\nputs(file)" - }, - "cli": { - "method": "files get", - "example": "imagekit files get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId" - }, - "php": { - "method": "files->get", - "example": "files->get('fileId');\n\nvar_dump($file);" - }, - "csharp": { - "method": "Files.Get", - "example": "FileGetParams parameters = new() { FileID = \"fileId\" };\n\nvar file = await client.Files.Get(parameters);\n\nConsole.WriteLine(file);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/details \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'get', + endpoint: '/v1/files/{fileId}/details', + httpMethod: 'get', + summary: 'Get file details', + description: + 'This API returns an object with details or attributes about the current version of the file.', + stainlessPath: '(resource) files > (method) get', + qualified: 'client.files.get', + params: ['fileId: string;'], + response: + "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", + markdown: + "## get\n\n`client.files.get(fileId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/details`\n\nThis API returns an object with details or attributes about the current version of the file.\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.get('fileId');\n\nconsole.log(file);\n```", + perLanguage: { + typescript: { + method: 'client.files.get', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.get('fileId');\n\nconsole.log(file.videoCodec);", + }, + python: { + method: 'files.get', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.get(\n "fileId",\n)\nprint(file.video_codec)', + }, + java: { + method: 'files().get', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.FileGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n File file = client.files().get("fileId");\n }\n}', + }, + kotlin: { + method: 'files().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.FileGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val file: File = client.files().get("fileId")\n}', + }, + go: { + method: 'client.Files.Get', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Get(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file.VideoCodec)\n}\n', + }, + ruby: { + method: 'files.get', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfile = image_kit.files.get("fileId")\n\nputs(file)', + }, + cli: { + method: 'files get', + example: + "imagekit files get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", + }, + php: { + method: 'files->get', + example: + "files->get('fileId');\n\nvar_dump($file);", + }, + csharp: { + method: 'Files.Get', + example: + 'FileGetParams parameters = new() { FileID = "fileId" };\n\nvar file = await client.Files.Get(parameters);\n\nConsole.WriteLine(file);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID/details \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "update", - "endpoint": "/v1/files/{fileId}/details", - "httpMethod": "patch", - "summary": "Update file details", - "description": "This API updates the details or attributes of the current version of the file. You can update `tags`, `customCoordinates`, `customMetadata`, publication status, remove existing `AITags` and apply extensions using this API.\n", - "stainlessPath": "(resource) files > (method) update", - "qualified": "client.files.update", - "params": [ - "fileId: string;", - "UpdateFileRequest: { customCoordinates?: string; customMetadata?: object; description?: string; extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[]; removeAITags?: string[] | 'all'; tags?: string[]; webhookUrl?: string; } | { publish?: { isPublished: boolean; includeFileVersions?: boolean; }; };" + name: 'update', + endpoint: '/v1/files/{fileId}/details', + httpMethod: 'patch', + summary: 'Update file details', + description: + 'This API updates the details or attributes of the current version of the file. You can update `tags`, `customCoordinates`, `customMetadata`, publication status, remove existing `AITags` and apply extensions using this API.\n', + stainlessPath: '(resource) files > (method) update', + qualified: 'client.files.update', + params: [ + 'fileId: string;', + "UpdateFileRequest: { customCoordinates?: string; customMetadata?: object; description?: string; extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[]; removeAITags?: string[] | 'all'; tags?: string[]; webhookUrl?: string; } | { publish?: { isPublished: boolean; includeFileVersions?: boolean; }; };", ], - "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", - "perLanguage": { - "typescript": { - "method": "client.files.update", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.update('fileId');\n\nconsole.log(file);" - }, - "python": { - "method": "files.update", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfile = client.files.update(\n file_id=\"fileId\",\n)\nprint(file)" - }, - "java": { - "method": "files().update", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUpdateParams;\nimport io.imagekit.models.files.FileUpdateResponse;\nimport io.imagekit.models.files.UpdateFileRequest;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUpdateParams params = FileUpdateParams.builder()\n .fileId(\"fileId\")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build();\n FileUpdateResponse file = client.files().update(params);\n }\n}" - }, - "kotlin": { - "method": "files().update", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUpdateParams\nimport com.imagekit.api.models.files.FileUpdateResponse\nimport com.imagekit.api.models.files.UpdateFileRequest\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUpdateParams = FileUpdateParams.builder()\n .fileId(\"fileId\")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build()\n val file: FileUpdateResponse = client.files().update(params)\n}" - }, - "go": { - "method": "client.Files.Update", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfile, err := client.Files.Update(\n\t\tcontext.TODO(),\n\t\t\"fileId\",\n\t\timagekit.FileUpdateParams{\n\t\t\tUpdateFileRequest: imagekit.UpdateFileRequestUnionParam{\n\t\t\t\tOfUpdateFileDetails: &imagekit.UpdateFileRequestUpdateFileDetailsParam{},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", file)\n}\n" - }, - "ruby": { - "method": "files.update", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfile = image_kit.files.update(\"fileId\", update_file_request: {})\n\nputs(file)" - }, - "cli": { - "method": "files update", - "example": "imagekit files update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId" - }, - "php": { - "method": "files->update", - "example": "files->update(\n 'fileId',\n customCoordinates: 'customCoordinates',\n customMetadata: ['foo' => 'bar'],\n description: 'description',\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n removeAITags: 'all',\n tags: ['tag1', 'tag2'],\n webhookURL: 'https://example.com',\n publish: ['isPublished' => true, 'includeFileVersions' => true],\n);\n\nvar_dump($file);" - }, - "csharp": { - "method": "Files.Update", - "example": "FileUpdateParams parameters = new()\n{\n FileID = \"fileId\",\n UpdateFileRequest = new UpdateFileDetails()\n {\n CustomCoordinates = \"10,10,100,100\",\n CustomMetadata = new Dictionary()\n {\n { \"brand\", JsonSerializer.SerializeToElement(\"bar\") },\n { \"color\", JsonSerializer.SerializeToElement(\"bar\") },\n },\n Description = \"description\",\n Extensions =\n [\n new RemoveBg()\n {\n Options = new()\n {\n AddShadow = true,\n BgColor = \"bg_color\",\n BgImageUrl = \"bg_image_url\",\n Semitransparency = true,\n },\n },\n new AutoTaggingExtension()\n {\n MaxTags = 10,\n MinConfidence = 80,\n Name = Name.GoogleAutoTagging,\n },\n new AutoTaggingExtension()\n {\n MaxTags = 10,\n MinConfidence = 80,\n Name = Name.AwsAutoTagging,\n },\n new AIAutoDescription(),\n new AITasks(\n\n [\n new SelectTags()\n {\n Instruction = \"What types of clothing items are visible?\",\n MaxSelections = 1,\n MinSelections = 0,\n Vocabulary =\n [\n \"shirt\", \"dress\", \"jacket\"\n ],\n },\n ]\n ),\n new SavedExtension(\"ext_abc123\"),\n ],\n RemoveAITags = new(\n\n [\n \"car\", \"vehicle\", \"motorsports\"\n ]\n ),\n Tags =\n [\n \"tag1\", \"tag2\"\n ],\n WebhookUrl = \"https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a\",\n },\n};\n\nvar file = await client.Files.Update(parameters);\n\nConsole.WriteLine(file);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/details \\\n -X PATCH \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"extensions\": [\n {\n \"name\": \"remove-bg\",\n \"options\": {\n \"add_shadow\": true\n }\n },\n {\n \"maxTags\": 5,\n \"minConfidence\": 95,\n \"name\": \"google-auto-tagging\"\n },\n {\n \"name\": \"ai-auto-description\"\n },\n {\n \"name\": \"ai-tasks\",\n \"tasks\": [\n {\n \"instruction\": \"What types of clothing items are visible in this image?\",\n \"type\": \"select_tags\",\n \"vocabulary\": [\n \"shirt\",\n \"tshirt\",\n \"dress\",\n \"trousers\",\n \"jacket\"\n ]\n },\n {\n \"instruction\": \"Is this a luxury or high-end fashion item?\",\n \"type\": \"yes_no\",\n \"on_yes\": {\n \"add_tags\": [\n \"luxury\",\n \"premium\"\n ]\n }\n }\n ]\n },\n {\n \"id\": \"ext_abc123\",\n \"name\": \"saved-extension\"\n }\n ],\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ]\n }'" - } - } + response: + "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", + perLanguage: { + typescript: { + method: 'client.files.update', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.update('fileId');\n\nconsole.log(file);", + }, + python: { + method: 'files.update', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.update(\n file_id="fileId",\n)\nprint(file)', + }, + java: { + method: 'files().update', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUpdateParams;\nimport io.imagekit.models.files.FileUpdateResponse;\nimport io.imagekit.models.files.UpdateFileRequest;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUpdateParams params = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build();\n FileUpdateResponse file = client.files().update(params);\n }\n}', + }, + kotlin: { + method: 'files().update', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUpdateParams\nimport com.imagekit.api.models.files.FileUpdateResponse\nimport com.imagekit.api.models.files.UpdateFileRequest\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUpdateParams = FileUpdateParams.builder()\n .fileId("fileId")\n .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build())\n .build()\n val file: FileUpdateResponse = client.files().update(params)\n}', + }, + go: { + method: 'client.Files.Update', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Update(\n\t\tcontext.TODO(),\n\t\t"fileId",\n\t\timagekit.FileUpdateParams{\n\t\t\tUpdateFileRequest: imagekit.UpdateFileRequestUnionParam{\n\t\t\t\tOfUpdateFileDetails: &imagekit.UpdateFileRequestUpdateFileDetailsParam{},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file)\n}\n', + }, + ruby: { + method: 'files.update', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfile = image_kit.files.update("fileId", update_file_request: {})\n\nputs(file)', + }, + cli: { + method: 'files update', + example: + "imagekit files update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", + }, + php: { + method: 'files->update', + example: + "files->update(\n 'fileId',\n customCoordinates: 'customCoordinates',\n customMetadata: ['foo' => 'bar'],\n description: 'description',\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n removeAITags: 'all',\n tags: ['tag1', 'tag2'],\n webhookURL: 'https://example.com',\n publish: ['isPublished' => true, 'includeFileVersions' => true],\n);\n\nvar_dump($file);", + }, + csharp: { + method: 'Files.Update', + example: + 'FileUpdateParams parameters = new()\n{\n FileID = "fileId",\n UpdateFileRequest = new UpdateFileDetails()\n {\n CustomCoordinates = "10,10,100,100",\n CustomMetadata = new Dictionary()\n {\n { "brand", JsonSerializer.SerializeToElement("bar") },\n { "color", JsonSerializer.SerializeToElement("bar") },\n },\n Description = "description",\n Extensions =\n [\n new RemoveBg()\n {\n Options = new()\n {\n AddShadow = true,\n BgColor = "bg_color",\n BgImageUrl = "bg_image_url",\n Semitransparency = true,\n },\n },\n new AutoTaggingExtension()\n {\n MaxTags = 10,\n MinConfidence = 80,\n Name = Name.GoogleAutoTagging,\n },\n new AutoTaggingExtension()\n {\n MaxTags = 10,\n MinConfidence = 80,\n Name = Name.AwsAutoTagging,\n },\n new AIAutoDescription(),\n new AITasks(\n\n [\n new SelectTags()\n {\n Instruction = "What types of clothing items are visible?",\n MaxSelections = 1,\n MinSelections = 0,\n Vocabulary =\n [\n "shirt", "dress", "jacket"\n ],\n },\n ]\n ),\n new SavedExtension("ext_abc123"),\n ],\n RemoveAITags = new(\n\n [\n "car", "vehicle", "motorsports"\n ]\n ),\n Tags =\n [\n "tag1", "tag2"\n ],\n WebhookUrl = "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a",\n },\n};\n\nvar file = await client.Files.Update(parameters);\n\nConsole.WriteLine(file);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID/details \\\n -X PATCH \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "extensions": [\n {\n "name": "remove-bg",\n "options": {\n "add_shadow": true\n }\n },\n {\n "maxTags": 5,\n "minConfidence": 95,\n "name": "google-auto-tagging"\n },\n {\n "name": "ai-auto-description"\n },\n {\n "name": "ai-tasks",\n "tasks": [\n {\n "instruction": "What types of clothing items are visible in this image?",\n "type": "select_tags",\n "vocabulary": [\n "shirt",\n "tshirt",\n "dress",\n "trousers",\n "jacket"\n ]\n },\n {\n "instruction": "Is this a luxury or high-end fashion item?",\n "type": "yes_no",\n "on_yes": {\n "add_tags": [\n "luxury",\n "premium"\n ]\n }\n }\n ]\n },\n {\n "id": "ext_abc123",\n "name": "saved-extension"\n }\n ],\n "tags": [\n "tag1",\n "tag2"\n ]\n }\'', + }, + }, }, { - "name": "delete", - "endpoint": "/v1/files/{fileId}", - "httpMethod": "delete", - "summary": "Delete file", - "description": "This API deletes the file and all its file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n", - "stainlessPath": "(resource) files > (method) delete", - "qualified": "client.files.delete", - "params": [ - "fileId: string;" - ], - "markdown": "## delete\n\n`client.files.delete(fileId: string): void`\n\n**delete** `/v1/files/{fileId}`\n\nThis API deletes the file and all its file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.files.delete('fileId')\n```", - "perLanguage": { - "typescript": { - "method": "client.files.delete", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.files.delete('fileId');" - }, - "python": { - "method": "files.delete", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nclient.files.delete(\n \"fileId\",\n)" - }, - "java": { - "method": "files().delete", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.files().delete(\"fileId\");\n }\n}" - }, - "kotlin": { - "method": "files().delete", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.files().delete(\"fileId\")\n}" - }, - "go": { - "method": "client.Files.Delete", - "example": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\terr := client.Files.Delete(context.TODO(), \"fileId\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n" - }, - "ruby": { - "method": "files.delete", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresult = image_kit.files.delete(\"fileId\")\n\nputs(result)" - }, - "cli": { - "method": "files delete", - "example": "imagekit files delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId" - }, - "php": { - "method": "files->delete", - "example": "files->delete('fileId');\n\nvar_dump($result);" - }, - "csharp": { - "method": "Files.Delete", - "example": "FileDeleteParams parameters = new() { FileID = \"fileId\" };\n\nawait client.Files.Delete(parameters);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/$FILE_ID \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'delete', + endpoint: '/v1/files/{fileId}', + httpMethod: 'delete', + summary: 'Delete file', + description: + 'This API deletes the file and all its file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n', + stainlessPath: '(resource) files > (method) delete', + qualified: 'client.files.delete', + params: ['fileId: string;'], + markdown: + "## delete\n\n`client.files.delete(fileId: string): void`\n\n**delete** `/v1/files/{fileId}`\n\nThis API deletes the file and all its file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.files.delete('fileId')\n```", + perLanguage: { + typescript: { + method: 'client.files.delete', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.files.delete('fileId');", + }, + python: { + method: 'files.delete', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.files.delete(\n "fileId",\n)', + }, + java: { + method: 'files().delete', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.files().delete("fileId");\n }\n}', + }, + kotlin: { + method: 'files().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.files().delete("fileId")\n}', + }, + go: { + method: 'client.Files.Delete', + example: + 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Files.Delete(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', + }, + ruby: { + method: 'files.delete', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.files.delete("fileId")\n\nputs(result)', + }, + cli: { + method: 'files delete', + example: + "imagekit files delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", + }, + php: { + method: 'files->delete', + example: + "files->delete('fileId');\n\nvar_dump($result);", + }, + csharp: { + method: 'Files.Delete', + example: + 'FileDeleteParams parameters = new() { FileID = "fileId" };\n\nawait client.Files.Delete(parameters);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "copy", - "endpoint": "/v1/files/copy", - "httpMethod": "post", - "summary": "Copy file", - "description": "This will copy a file from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions (if `includeFileVersions` is set to true) will be appended to the destination file version history.\n", - "stainlessPath": "(resource) files > (method) copy", - "qualified": "client.files.copy", - "params": [ - "destinationPath: string;", - "sourceFilePath: string;", - "includeFileVersions?: boolean;" - ], - "response": "{ }", - "markdown": "## copy\n\n`client.files.copy(destinationPath: string, sourceFilePath: string, includeFileVersions?: boolean): { }`\n\n**post** `/v1/files/copy`\n\nThis will copy a file from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions (if `includeFileVersions` is set to true) will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the folder you want to copy the above file into.\n\n\n- `sourceFilePath: string`\n The full path of the file you want to copy.\n\n\n- `includeFileVersions?: boolean`\n Option to copy all versions of a file. By default, only the current version of the file is copied. When set to true, all versions of the file will be copied. Default value - `false`.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.copy({ destinationPath: '/folder/to/copy/into/', sourceFilePath: '/path/to/file.jpg' });\n\nconsole.log(response);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.copy", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.copy({\n destinationPath: '/folder/to/copy/into/',\n sourceFilePath: '/path/to/file.jpg',\n});\n\nconsole.log(response);" - }, - "python": { - "method": "files.copy", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.copy(\n destination_path=\"/folder/to/copy/into/\",\n source_file_path=\"/path/to/file.jpg\",\n)\nprint(response)" - }, - "java": { - "method": "files().copy", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileCopyParams;\nimport io.imagekit.models.files.FileCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileCopyParams params = FileCopyParams.builder()\n .destinationPath(\"/folder/to/copy/into/\")\n .sourceFilePath(\"/path/to/file.jpg\")\n .build();\n FileCopyResponse response = client.files().copy(params);\n }\n}" - }, - "kotlin": { - "method": "files().copy", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileCopyParams\nimport com.imagekit.api.models.files.FileCopyResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileCopyParams = FileCopyParams.builder()\n .destinationPath(\"/folder/to/copy/into/\")\n .sourceFilePath(\"/path/to/file.jpg\")\n .build()\n val response: FileCopyResponse = client.files().copy(params)\n}" - }, - "go": { - "method": "client.Files.Copy", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Copy(context.TODO(), imagekit.FileCopyParams{\n\t\tDestinationPath: \"/folder/to/copy/into/\",\n\t\tSourceFilePath: \"/path/to/file.jpg\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response)\n}\n" - }, - "ruby": { - "method": "files.copy", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.copy(destination_path: \"/folder/to/copy/into/\", source_file_path: \"/path/to/file.jpg\")\n\nputs(response)" - }, - "cli": { - "method": "files copy", - "example": "imagekit files copy \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /folder/to/copy/into/ \\\n --source-file-path /path/to/file.jpg" - }, - "php": { - "method": "files->copy", - "example": "files->copy(\n destinationPath: '/folder/to/copy/into/',\n sourceFilePath: '/path/to/file.jpg',\n includeFileVersions: false,\n);\n\nvar_dump($response);" - }, - "csharp": { - "method": "Files.Copy", - "example": "FileCopyParams parameters = new()\n{\n DestinationPath = \"/folder/to/copy/into/\",\n SourceFilePath = \"/path/to/file.jpg\",\n};\n\nvar response = await client.Files.Copy(parameters);\n\nConsole.WriteLine(response);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/copy \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"destinationPath\": \"/folder/to/copy/into/\",\n \"sourceFilePath\": \"/path/to/file.jpg\"\n }'" - } - } + name: 'copy', + endpoint: '/v1/files/copy', + httpMethod: 'post', + summary: 'Copy file', + description: + 'This will copy a file from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions (if `includeFileVersions` is set to true) will be appended to the destination file version history.\n', + stainlessPath: '(resource) files > (method) copy', + qualified: 'client.files.copy', + params: ['destinationPath: string;', 'sourceFilePath: string;', 'includeFileVersions?: boolean;'], + response: '{ }', + markdown: + "## copy\n\n`client.files.copy(destinationPath: string, sourceFilePath: string, includeFileVersions?: boolean): { }`\n\n**post** `/v1/files/copy`\n\nThis will copy a file from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions (if `includeFileVersions` is set to true) will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the folder you want to copy the above file into.\n\n\n- `sourceFilePath: string`\n The full path of the file you want to copy.\n\n\n- `includeFileVersions?: boolean`\n Option to copy all versions of a file. By default, only the current version of the file is copied. When set to true, all versions of the file will be copied. Default value - `false`.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.copy({ destinationPath: '/folder/to/copy/into/', sourceFilePath: '/path/to/file.jpg' });\n\nconsole.log(response);\n```", + perLanguage: { + typescript: { + method: 'client.files.copy', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.copy({\n destinationPath: '/folder/to/copy/into/',\n sourceFilePath: '/path/to/file.jpg',\n});\n\nconsole.log(response);", + }, + python: { + method: 'files.copy', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.copy(\n destination_path="/folder/to/copy/into/",\n source_file_path="/path/to/file.jpg",\n)\nprint(response)', + }, + java: { + method: 'files().copy', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileCopyParams;\nimport io.imagekit.models.files.FileCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileCopyParams params = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileCopyResponse response = client.files().copy(params);\n }\n}', + }, + kotlin: { + method: 'files().copy', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileCopyParams\nimport com.imagekit.api.models.files.FileCopyResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileCopyParams = FileCopyParams.builder()\n .destinationPath("/folder/to/copy/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build()\n val response: FileCopyResponse = client.files().copy(params)\n}', + }, + go: { + method: 'client.Files.Copy', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Copy(context.TODO(), imagekit.FileCopyParams{\n\t\tDestinationPath: "/folder/to/copy/into/",\n\t\tSourceFilePath: "/path/to/file.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response)\n}\n', + }, + ruby: { + method: 'files.copy', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.copy(destination_path: "/folder/to/copy/into/", source_file_path: "/path/to/file.jpg")\n\nputs(response)', + }, + cli: { + method: 'files copy', + example: + "imagekit files copy \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /folder/to/copy/into/ \\\n --source-file-path /path/to/file.jpg", + }, + php: { + method: 'files->copy', + example: + "files->copy(\n destinationPath: '/folder/to/copy/into/',\n sourceFilePath: '/path/to/file.jpg',\n includeFileVersions: false,\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Copy', + example: + 'FileCopyParams parameters = new()\n{\n DestinationPath = "/folder/to/copy/into/",\n SourceFilePath = "/path/to/file.jpg",\n};\n\nvar response = await client.Files.Copy(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/copy \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/folder/to/copy/into/",\n "sourceFilePath": "/path/to/file.jpg"\n }\'', + }, + }, }, { - "name": "move", - "endpoint": "/v1/files/move", - "httpMethod": "post", - "summary": "Move file", - "description": "This will move a file and all its versions from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file.\n", - "stainlessPath": "(resource) files > (method) move", - "qualified": "client.files.move", - "params": [ - "destinationPath: string;", - "sourceFilePath: string;" - ], - "response": "{ }", - "markdown": "## move\n\n`client.files.move(destinationPath: string, sourceFilePath: string): { }`\n\n**post** `/v1/files/move`\n\nThis will move a file and all its versions from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the folder you want to move the above file into.\n\n\n- `sourceFilePath: string`\n The full path of the file you want to move.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.move({ destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg' });\n\nconsole.log(response);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.move", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.move({\n destinationPath: '/folder/to/move/into/',\n sourceFilePath: '/path/to/file.jpg',\n});\n\nconsole.log(response);" - }, - "python": { - "method": "files.move", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.move(\n destination_path=\"/folder/to/move/into/\",\n source_file_path=\"/path/to/file.jpg\",\n)\nprint(response)" - }, - "java": { - "method": "files().move", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileMoveParams;\nimport io.imagekit.models.files.FileMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileMoveParams params = FileMoveParams.builder()\n .destinationPath(\"/folder/to/move/into/\")\n .sourceFilePath(\"/path/to/file.jpg\")\n .build();\n FileMoveResponse response = client.files().move(params);\n }\n}" - }, - "kotlin": { - "method": "files().move", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileMoveParams\nimport com.imagekit.api.models.files.FileMoveResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileMoveParams = FileMoveParams.builder()\n .destinationPath(\"/folder/to/move/into/\")\n .sourceFilePath(\"/path/to/file.jpg\")\n .build()\n val response: FileMoveResponse = client.files().move(params)\n}" - }, - "go": { - "method": "client.Files.Move", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Move(context.TODO(), imagekit.FileMoveParams{\n\t\tDestinationPath: \"/folder/to/move/into/\",\n\t\tSourceFilePath: \"/path/to/file.jpg\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response)\n}\n" - }, - "ruby": { - "method": "files.move", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.move(destination_path: \"/folder/to/move/into/\", source_file_path: \"/path/to/file.jpg\")\n\nputs(response)" - }, - "cli": { - "method": "files move", - "example": "imagekit files move \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /folder/to/move/into/ \\\n --source-file-path /path/to/file.jpg" - }, - "php": { - "method": "files->move", - "example": "files->move(\n destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg'\n);\n\nvar_dump($response);" - }, - "csharp": { - "method": "Files.Move", - "example": "FileMoveParams parameters = new()\n{\n DestinationPath = \"/folder/to/move/into/\",\n SourceFilePath = \"/path/to/file.jpg\",\n};\n\nvar response = await client.Files.Move(parameters);\n\nConsole.WriteLine(response);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/move \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"destinationPath\": \"/folder/to/move/into/\",\n \"sourceFilePath\": \"/path/to/file.jpg\"\n }'" - } - } + name: 'move', + endpoint: '/v1/files/move', + httpMethod: 'post', + summary: 'Move file', + description: + 'This will move a file and all its versions from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file.\n', + stainlessPath: '(resource) files > (method) move', + qualified: 'client.files.move', + params: ['destinationPath: string;', 'sourceFilePath: string;'], + response: '{ }', + markdown: + "## move\n\n`client.files.move(destinationPath: string, sourceFilePath: string): { }`\n\n**post** `/v1/files/move`\n\nThis will move a file and all its versions from one folder to another. \n\nNote: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the folder you want to move the above file into.\n\n\n- `sourceFilePath: string`\n The full path of the file you want to move.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.move({ destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg' });\n\nconsole.log(response);\n```", + perLanguage: { + typescript: { + method: 'client.files.move', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.move({\n destinationPath: '/folder/to/move/into/',\n sourceFilePath: '/path/to/file.jpg',\n});\n\nconsole.log(response);", + }, + python: { + method: 'files.move', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.move(\n destination_path="/folder/to/move/into/",\n source_file_path="/path/to/file.jpg",\n)\nprint(response)', + }, + java: { + method: 'files().move', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileMoveParams;\nimport io.imagekit.models.files.FileMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileMoveParams params = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build();\n FileMoveResponse response = client.files().move(params);\n }\n}', + }, + kotlin: { + method: 'files().move', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileMoveParams\nimport com.imagekit.api.models.files.FileMoveResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileMoveParams = FileMoveParams.builder()\n .destinationPath("/folder/to/move/into/")\n .sourceFilePath("/path/to/file.jpg")\n .build()\n val response: FileMoveResponse = client.files().move(params)\n}', + }, + go: { + method: 'client.Files.Move', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Move(context.TODO(), imagekit.FileMoveParams{\n\t\tDestinationPath: "/folder/to/move/into/",\n\t\tSourceFilePath: "/path/to/file.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response)\n}\n', + }, + ruby: { + method: 'files.move', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.move(destination_path: "/folder/to/move/into/", source_file_path: "/path/to/file.jpg")\n\nputs(response)', + }, + cli: { + method: 'files move', + example: + "imagekit files move \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /folder/to/move/into/ \\\n --source-file-path /path/to/file.jpg", + }, + php: { + method: 'files->move', + example: + "files->move(\n destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg'\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Move', + example: + 'FileMoveParams parameters = new()\n{\n DestinationPath = "/folder/to/move/into/",\n SourceFilePath = "/path/to/file.jpg",\n};\n\nvar response = await client.Files.Move(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/move \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/folder/to/move/into/",\n "sourceFilePath": "/path/to/file.jpg"\n }\'', + }, + }, }, { - "name": "rename", - "endpoint": "/v1/files/rename", - "httpMethod": "put", - "summary": "Rename file", - "description": "You can rename an already existing file in the media library using rename file API. This operation would rename all file versions of the file. \n\nNote: The old URLs will stop working. The file/file version URLs cached on CDN will continue to work unless a purge is requested.\n", - "stainlessPath": "(resource) files > (method) rename", - "qualified": "client.files.rename", - "params": [ - "filePath: string;", - "newFileName: string;", - "purgeCache?: boolean;" - ], - "response": "{ purgeRequestId?: string; }", - "markdown": "## rename\n\n`client.files.rename(filePath: string, newFileName: string, purgeCache?: boolean): { purgeRequestId?: string; }`\n\n**put** `/v1/files/rename`\n\nYou can rename an already existing file in the media library using rename file API. This operation would rename all file versions of the file. \n\nNote: The old URLs will stop working. The file/file version URLs cached on CDN will continue to work unless a purge is requested.\n\n\n### Parameters\n\n- `filePath: string`\n The full path of the file you want to rename.\n\n\n- `newFileName: string`\n The new name of the file. A filename can contain:\n\nAlphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, and numerals in other languages).\nSpecial Characters: `.`, `_`, and `-`.\n\nAny other character, including space, will be replaced by `_`.\n\n\n- `purgeCache?: boolean`\n Option to purge cache for the old file and its versions' URLs.\n\nWhen set to true, it will internally issue a purge cache request on CDN to remove cached content of old file and its versions. This purge request is counted against your monthly purge quota.\n\nNote: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard at the end). It will remove the file and its versions' URLs and any transformations made using query parameters on this file or its versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation.\n\n\n\nDefault value - `false`\n\n\n### Returns\n\n- `{ purgeRequestId?: string; }`\n\n - `purgeRequestId?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.rename({ filePath: '/path/to/file.jpg', newFileName: 'newFileName.jpg' });\n\nconsole.log(response);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.rename", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.rename({\n filePath: '/path/to/file.jpg',\n newFileName: 'newFileName.jpg',\n});\n\nconsole.log(response.purgeRequestId);" - }, - "python": { - "method": "files.rename", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.rename(\n file_path=\"/path/to/file.jpg\",\n new_file_name=\"newFileName.jpg\",\n)\nprint(response.purge_request_id)" - }, - "java": { - "method": "files().rename", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileRenameParams;\nimport io.imagekit.models.files.FileRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileRenameParams params = FileRenameParams.builder()\n .filePath(\"/path/to/file.jpg\")\n .newFileName(\"newFileName.jpg\")\n .build();\n FileRenameResponse response = client.files().rename(params);\n }\n}" - }, - "kotlin": { - "method": "files().rename", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileRenameParams\nimport com.imagekit.api.models.files.FileRenameResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileRenameParams = FileRenameParams.builder()\n .filePath(\"/path/to/file.jpg\")\n .newFileName(\"newFileName.jpg\")\n .build()\n val response: FileRenameResponse = client.files().rename(params)\n}" - }, - "go": { - "method": "client.Files.Rename", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Rename(context.TODO(), imagekit.FileRenameParams{\n\t\tFilePath: \"/path/to/file.jpg\",\n\t\tNewFileName: \"newFileName.jpg\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.PurgeRequestID)\n}\n" - }, - "ruby": { - "method": "files.rename", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.rename(file_path: \"/path/to/file.jpg\", new_file_name: \"newFileName.jpg\")\n\nputs(response)" - }, - "cli": { - "method": "files rename", - "example": "imagekit files rename \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-path /path/to/file.jpg \\\n --new-file-name newFileName.jpg" - }, - "php": { - "method": "files->rename", - "example": "files->rename(\n filePath: '/path/to/file.jpg',\n newFileName: 'newFileName.jpg',\n purgeCache: true,\n);\n\nvar_dump($response);" - }, - "csharp": { - "method": "Files.Rename", - "example": "FileRenameParams parameters = new()\n{\n FilePath = \"/path/to/file.jpg\",\n NewFileName = \"newFileName.jpg\",\n};\n\nvar response = await client.Files.Rename(parameters);\n\nConsole.WriteLine(response);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/rename \\\n -X PUT \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"filePath\": \"/path/to/file.jpg\",\n \"newFileName\": \"newFileName.jpg\",\n \"purgeCache\": true\n }'" - } - } + name: 'rename', + endpoint: '/v1/files/rename', + httpMethod: 'put', + summary: 'Rename file', + description: + 'You can rename an already existing file in the media library using rename file API. This operation would rename all file versions of the file. \n\nNote: The old URLs will stop working. The file/file version URLs cached on CDN will continue to work unless a purge is requested.\n', + stainlessPath: '(resource) files > (method) rename', + qualified: 'client.files.rename', + params: ['filePath: string;', 'newFileName: string;', 'purgeCache?: boolean;'], + response: '{ purgeRequestId?: string; }', + markdown: + "## rename\n\n`client.files.rename(filePath: string, newFileName: string, purgeCache?: boolean): { purgeRequestId?: string; }`\n\n**put** `/v1/files/rename`\n\nYou can rename an already existing file in the media library using rename file API. This operation would rename all file versions of the file. \n\nNote: The old URLs will stop working. The file/file version URLs cached on CDN will continue to work unless a purge is requested.\n\n\n### Parameters\n\n- `filePath: string`\n The full path of the file you want to rename.\n\n\n- `newFileName: string`\n The new name of the file. A filename can contain:\n\nAlphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, and numerals in other languages).\nSpecial Characters: `.`, `_`, and `-`.\n\nAny other character, including space, will be replaced by `_`.\n\n\n- `purgeCache?: boolean`\n Option to purge cache for the old file and its versions' URLs.\n\nWhen set to true, it will internally issue a purge cache request on CDN to remove cached content of old file and its versions. This purge request is counted against your monthly purge quota.\n\nNote: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard at the end). It will remove the file and its versions' URLs and any transformations made using query parameters on this file or its versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation.\n\n\n\nDefault value - `false`\n\n\n### Returns\n\n- `{ purgeRequestId?: string; }`\n\n - `purgeRequestId?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.rename({ filePath: '/path/to/file.jpg', newFileName: 'newFileName.jpg' });\n\nconsole.log(response);\n```", + perLanguage: { + typescript: { + method: 'client.files.rename', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.rename({\n filePath: '/path/to/file.jpg',\n newFileName: 'newFileName.jpg',\n});\n\nconsole.log(response.purgeRequestId);", + }, + python: { + method: 'files.rename', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.rename(\n file_path="/path/to/file.jpg",\n new_file_name="newFileName.jpg",\n)\nprint(response.purge_request_id)', + }, + java: { + method: 'files().rename', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileRenameParams;\nimport io.imagekit.models.files.FileRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileRenameParams params = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build();\n FileRenameResponse response = client.files().rename(params);\n }\n}', + }, + kotlin: { + method: 'files().rename', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileRenameParams\nimport com.imagekit.api.models.files.FileRenameResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileRenameParams = FileRenameParams.builder()\n .filePath("/path/to/file.jpg")\n .newFileName("newFileName.jpg")\n .build()\n val response: FileRenameResponse = client.files().rename(params)\n}', + }, + go: { + method: 'client.Files.Rename', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Rename(context.TODO(), imagekit.FileRenameParams{\n\t\tFilePath: "/path/to/file.jpg",\n\t\tNewFileName: "newFileName.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.PurgeRequestID)\n}\n', + }, + ruby: { + method: 'files.rename', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.rename(file_path: "/path/to/file.jpg", new_file_name: "newFileName.jpg")\n\nputs(response)', + }, + cli: { + method: 'files rename', + example: + "imagekit files rename \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-path /path/to/file.jpg \\\n --new-file-name newFileName.jpg", + }, + php: { + method: 'files->rename', + example: + "files->rename(\n filePath: '/path/to/file.jpg',\n newFileName: 'newFileName.jpg',\n purgeCache: true,\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Rename', + example: + 'FileRenameParams parameters = new()\n{\n FilePath = "/path/to/file.jpg",\n NewFileName = "newFileName.jpg",\n};\n\nvar response = await client.Files.Rename(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/rename \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "filePath": "/path/to/file.jpg",\n "newFileName": "newFileName.jpg",\n "purgeCache": true\n }\'', + }, + }, }, { - "name": "delete", - "endpoint": "/v1/files/batch/deleteByFileIds", - "httpMethod": "post", - "summary": "Delete multiple files", - "description": "This API deletes multiple files and all their file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\nA maximum of 100 files can be deleted at a time.\n", - "stainlessPath": "(resource) files.bulk > (method) delete", - "qualified": "client.files.bulk.delete", - "params": [ - "fileIds: string[];" - ], - "response": "{ successfullyDeletedFileIds?: string[]; }", - "markdown": "## delete\n\n`client.files.bulk.delete(fileIds: string[]): { successfullyDeletedFileIds?: string[]; }`\n\n**post** `/v1/files/batch/deleteByFileIds`\n\nThis API deletes multiple files and all their file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\nA maximum of 100 files can be deleted at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds which you want to delete.\n\n\n### Returns\n\n- `{ successfullyDeletedFileIds?: string[]; }`\n\n - `successfullyDeletedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst bulk = await client.files.bulk.delete({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] });\n\nconsole.log(bulk);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.bulk.delete", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst bulk = await client.files.bulk.delete({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n});\n\nconsole.log(bulk.successfullyDeletedFileIds);" - }, - "python": { - "method": "files.bulk.delete", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nbulk = client.files.bulk.delete(\n file_ids=[\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"],\n)\nprint(bulk.successfully_deleted_file_ids)" - }, - "java": { - "method": "files().bulk().delete", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkDeleteParams;\nimport io.imagekit.models.files.bulk.BulkDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkDeleteParams params = BulkDeleteParams.builder()\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .build();\n BulkDeleteResponse bulk = client.files().bulk().delete(params);\n }\n}" - }, - "kotlin": { - "method": "files().bulk().delete", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkDeleteParams\nimport com.imagekit.api.models.files.bulk.BulkDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkDeleteParams = BulkDeleteParams.builder()\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .build()\n val bulk: BulkDeleteResponse = client.files().bulk().delete(params)\n}" - }, - "go": { - "method": "client.Files.Bulk.Delete", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tbulk, err := client.Files.Bulk.Delete(context.TODO(), imagekit.FileBulkDeleteParams{\n\t\tFileIDs: []string{\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", bulk.SuccessfullyDeletedFileIDs)\n}\n" - }, - "ruby": { - "method": "files.bulk.delete", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nbulk = image_kit.files.bulk.delete(file_ids: [\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"])\n\nputs(bulk)" - }, - "cli": { - "method": "bulk delete", - "example": "imagekit files:bulk delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be" - }, - "php": { - "method": "files->bulk->delete", - "example": "files->bulk->delete(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be']\n);\n\nvar_dump($bulk);" - }, - "csharp": { - "method": "Files.Bulk.Delete", - "example": "BulkDeleteParams parameters = new()\n{\n FileIds =\n [\n \"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"\n ],\n};\n\nvar bulk = await client.Files.Bulk.Delete(parameters);\n\nConsole.WriteLine(bulk);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/batch/deleteByFileIds \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"fileIds\": [\n \"598821f949c0a938d57563bd\",\n \"598821f949c0a938d57563be\"\n ]\n }'" - } - } + name: 'delete', + endpoint: '/v1/files/batch/deleteByFileIds', + httpMethod: 'post', + summary: 'Delete multiple files', + description: + 'This API deletes multiple files and all their file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\nA maximum of 100 files can be deleted at a time.\n', + stainlessPath: '(resource) files.bulk > (method) delete', + qualified: 'client.files.bulk.delete', + params: ['fileIds: string[];'], + response: '{ successfullyDeletedFileIds?: string[]; }', + markdown: + "## delete\n\n`client.files.bulk.delete(fileIds: string[]): { successfullyDeletedFileIds?: string[]; }`\n\n**post** `/v1/files/batch/deleteByFileIds`\n\nThis API deletes multiple files and all their file versions permanently.\n\nNote: If a file or specific transformation has been requested in the past, then the response is cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API.\n\nA maximum of 100 files can be deleted at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds which you want to delete.\n\n\n### Returns\n\n- `{ successfullyDeletedFileIds?: string[]; }`\n\n - `successfullyDeletedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst bulk = await client.files.bulk.delete({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] });\n\nconsole.log(bulk);\n```", + perLanguage: { + typescript: { + method: 'client.files.bulk.delete', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst bulk = await client.files.bulk.delete({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n});\n\nconsole.log(bulk.successfullyDeletedFileIds);", + }, + python: { + method: 'files.bulk.delete', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nbulk = client.files.bulk.delete(\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n)\nprint(bulk.successfully_deleted_file_ids)', + }, + java: { + method: 'files().bulk().delete', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkDeleteParams;\nimport io.imagekit.models.files.bulk.BulkDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkDeleteParams params = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkDeleteResponse bulk = client.files().bulk().delete(params);\n }\n}', + }, + kotlin: { + method: 'files().bulk().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkDeleteParams\nimport com.imagekit.api.models.files.bulk.BulkDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkDeleteParams = BulkDeleteParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build()\n val bulk: BulkDeleteResponse = client.files().bulk().delete(params)\n}', + }, + go: { + method: 'client.Files.Bulk.Delete', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tbulk, err := client.Files.Bulk.Delete(context.TODO(), imagekit.FileBulkDeleteParams{\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", bulk.SuccessfullyDeletedFileIDs)\n}\n', + }, + ruby: { + method: 'files.bulk.delete', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nbulk = image_kit.files.bulk.delete(file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"])\n\nputs(bulk)', + }, + cli: { + method: 'bulk delete', + example: + "imagekit files:bulk delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be", + }, + php: { + method: 'files->bulk->delete', + example: + "files->bulk->delete(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be']\n);\n\nvar_dump($bulk);", + }, + csharp: { + method: 'Files.Bulk.Delete', + example: + 'BulkDeleteParams parameters = new()\n{\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n};\n\nvar bulk = await client.Files.Bulk.Delete(parameters);\n\nConsole.WriteLine(bulk);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/batch/deleteByFileIds \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ]\n }\'', + }, + }, }, { - "name": "addTags", - "endpoint": "/v1/files/addTags", - "httpMethod": "post", - "summary": "Add tags (bulk)", - "description": "This API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a time.\n", - "stainlessPath": "(resource) files.bulk > (method) addTags", - "qualified": "client.files.bulk.addTags", - "params": [ - "fileIds: string[];", - "tags: string[];" - ], - "response": "{ successfullyUpdatedFileIds?: string[]; }", - "markdown": "## addTags\n\n`client.files.bulk.addTags(fileIds: string[], tags: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/addTags`\n\nThis API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds to which you want to add tags.\n\n\n- `tags: string[]`\n An array of tags that you want to add to the files.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.addTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] });\n\nconsole.log(response);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.bulk.addTags", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.addTags({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);" - }, - "python": { - "method": "files.bulk.add_tags", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.add_tags(\n file_ids=[\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"],\n tags=[\"t-shirt\", \"round-neck\", \"sale2019\"],\n)\nprint(response.successfully_updated_file_ids)" - }, - "java": { - "method": "files().bulk().addTags", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkAddTagsParams;\nimport io.imagekit.models.files.bulk.BulkAddTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkAddTagsParams params = BulkAddTagsParams.builder()\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .tags(List.of(\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\"\n ))\n .build();\n BulkAddTagsResponse response = client.files().bulk().addTags(params);\n }\n}" - }, - "kotlin": { - "method": "files().bulk().addTags", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkAddTagsParams\nimport com.imagekit.api.models.files.bulk.BulkAddTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkAddTagsParams = BulkAddTagsParams.builder()\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .tags(listOf(\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\",\n ))\n .build()\n val response: BulkAddTagsResponse = client.files().bulk().addTags(params)\n}" - }, - "go": { - "method": "client.Files.Bulk.AddTags", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Bulk.AddTags(context.TODO(), imagekit.FileBulkAddTagsParams{\n\t\tFileIDs: []string{\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"},\n\t\tTags: []string{\"t-shirt\", \"round-neck\", \"sale2019\"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.SuccessfullyUpdatedFileIDs)\n}\n" - }, - "ruby": { - "method": "files.bulk.add_tags", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.bulk.add_tags(\n file_ids: [\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"],\n tags: [\"t-shirt\", \"round-neck\", \"sale2019\"]\n)\n\nputs(response)" - }, - "cli": { - "method": "bulk addTags", - "example": "imagekit files:bulk add-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be \\\n --tag t-shirt \\\n --tag round-neck \\\n --tag sale2019" - }, - "php": { - "method": "files->bulk->addTags", - "example": "files->bulk->addTags(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n);\n\nvar_dump($response);" - }, - "csharp": { - "method": "Files.Bulk.AddTags", - "example": "BulkAddTagsParams parameters = new()\n{\n FileIds =\n [\n \"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"\n ],\n Tags =\n [\n \"t-shirt\", \"round-neck\", \"sale2019\"\n ],\n};\n\nvar response = await client.Files.Bulk.AddTags(parameters);\n\nConsole.WriteLine(response);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/addTags \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"fileIds\": [\n \"598821f949c0a938d57563bd\",\n \"598821f949c0a938d57563be\"\n ],\n \"tags\": [\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\"\n ]\n }'" - } - } + name: 'addTags', + endpoint: '/v1/files/addTags', + httpMethod: 'post', + summary: 'Add tags (bulk)', + description: + 'This API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a time.\n', + stainlessPath: '(resource) files.bulk > (method) addTags', + qualified: 'client.files.bulk.addTags', + params: ['fileIds: string[];', 'tags: string[];'], + response: '{ successfullyUpdatedFileIds?: string[]; }', + markdown: + "## addTags\n\n`client.files.bulk.addTags(fileIds: string[], tags: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/addTags`\n\nThis API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds to which you want to add tags.\n\n\n- `tags: string[]`\n An array of tags that you want to add to the files.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.addTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] });\n\nconsole.log(response);\n```", + perLanguage: { + typescript: { + method: 'client.files.bulk.addTags', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.addTags({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);", + }, + python: { + method: 'files.bulk.add_tags', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.add_tags(\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags=["t-shirt", "round-neck", "sale2019"],\n)\nprint(response.successfully_updated_file_ids)', + }, + java: { + method: 'files().bulk().addTags', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkAddTagsParams;\nimport io.imagekit.models.files.bulk.BulkAddTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkAddTagsParams params = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkAddTagsResponse response = client.files().bulk().addTags(params);\n }\n}', + }, + kotlin: { + method: 'files().bulk().addTags', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkAddTagsParams\nimport com.imagekit.api.models.files.bulk.BulkAddTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkAddTagsParams = BulkAddTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(listOf(\n "t-shirt",\n "round-neck",\n "sale2019",\n ))\n .build()\n val response: BulkAddTagsResponse = client.files().bulk().addTags(params)\n}', + }, + go: { + method: 'client.Files.Bulk.AddTags', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Bulk.AddTags(context.TODO(), imagekit.FileBulkAddTagsParams{\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t\tTags: []string{"t-shirt", "round-neck", "sale2019"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.SuccessfullyUpdatedFileIDs)\n}\n', + }, + ruby: { + method: 'files.bulk.add_tags', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.bulk.add_tags(\n file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags: ["t-shirt", "round-neck", "sale2019"]\n)\n\nputs(response)', + }, + cli: { + method: 'bulk addTags', + example: + "imagekit files:bulk add-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be \\\n --tag t-shirt \\\n --tag round-neck \\\n --tag sale2019", + }, + php: { + method: 'files->bulk->addTags', + example: + "files->bulk->addTags(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Bulk.AddTags', + example: + 'BulkAddTagsParams parameters = new()\n{\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n Tags =\n [\n "t-shirt", "round-neck", "sale2019"\n ],\n};\n\nvar response = await client.Files.Bulk.AddTags(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/addTags \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ],\n "tags": [\n "t-shirt",\n "round-neck",\n "sale2019"\n ]\n }\'', + }, + }, }, { - "name": "removeTags", - "endpoint": "/v1/files/removeTags", - "httpMethod": "post", - "summary": "Remove tags (bulk)", - "description": "This API removes tags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n", - "stainlessPath": "(resource) files.bulk > (method) removeTags", - "qualified": "client.files.bulk.removeTags", - "params": [ - "fileIds: string[];", - "tags: string[];" - ], - "response": "{ successfullyUpdatedFileIds?: string[]; }", - "markdown": "## removeTags\n\n`client.files.bulk.removeTags(fileIds: string[], tags: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/removeTags`\n\nThis API removes tags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds from which you want to remove tags.\n\n\n- `tags: string[]`\n An array of tags that you want to remove from the files.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.removeTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] });\n\nconsole.log(response);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.bulk.removeTags", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.removeTags({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);" - }, - "python": { - "method": "files.bulk.remove_tags", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.remove_tags(\n file_ids=[\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"],\n tags=[\"t-shirt\", \"round-neck\", \"sale2019\"],\n)\nprint(response.successfully_updated_file_ids)" - }, - "java": { - "method": "files().bulk().removeTags", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkRemoveTagsParams;\nimport io.imagekit.models.files.bulk.BulkRemoveTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveTagsParams params = BulkRemoveTagsParams.builder()\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .tags(List.of(\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\"\n ))\n .build();\n BulkRemoveTagsResponse response = client.files().bulk().removeTags(params);\n }\n}" - }, - "kotlin": { - "method": "files().bulk().removeTags", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsParams\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkRemoveTagsParams = BulkRemoveTagsParams.builder()\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .tags(listOf(\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\",\n ))\n .build()\n val response: BulkRemoveTagsResponse = client.files().bulk().removeTags(params)\n}" - }, - "go": { - "method": "client.Files.Bulk.RemoveTags", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Bulk.RemoveTags(context.TODO(), imagekit.FileBulkRemoveTagsParams{\n\t\tFileIDs: []string{\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"},\n\t\tTags: []string{\"t-shirt\", \"round-neck\", \"sale2019\"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.SuccessfullyUpdatedFileIDs)\n}\n" - }, - "ruby": { - "method": "files.bulk.remove_tags", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.bulk.remove_tags(\n file_ids: [\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"],\n tags: [\"t-shirt\", \"round-neck\", \"sale2019\"]\n)\n\nputs(response)" - }, - "cli": { - "method": "bulk removeTags", - "example": "imagekit files:bulk remove-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be \\\n --tag t-shirt \\\n --tag round-neck \\\n --tag sale2019" - }, - "php": { - "method": "files->bulk->removeTags", - "example": "files->bulk->removeTags(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n);\n\nvar_dump($response);" - }, - "csharp": { - "method": "Files.Bulk.RemoveTags", - "example": "BulkRemoveTagsParams parameters = new()\n{\n FileIds =\n [\n \"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"\n ],\n Tags =\n [\n \"t-shirt\", \"round-neck\", \"sale2019\"\n ],\n};\n\nvar response = await client.Files.Bulk.RemoveTags(parameters);\n\nConsole.WriteLine(response);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/removeTags \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"fileIds\": [\n \"598821f949c0a938d57563bd\",\n \"598821f949c0a938d57563be\"\n ],\n \"tags\": [\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\"\n ]\n }'" - } - } + name: 'removeTags', + endpoint: '/v1/files/removeTags', + httpMethod: 'post', + summary: 'Remove tags (bulk)', + description: + 'This API removes tags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n', + stainlessPath: '(resource) files.bulk > (method) removeTags', + qualified: 'client.files.bulk.removeTags', + params: ['fileIds: string[];', 'tags: string[];'], + response: '{ successfullyUpdatedFileIds?: string[]; }', + markdown: + "## removeTags\n\n`client.files.bulk.removeTags(fileIds: string[], tags: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/removeTags`\n\nThis API removes tags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `fileIds: string[]`\n An array of fileIds from which you want to remove tags.\n\n\n- `tags: string[]`\n An array of tags that you want to remove from the files.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.removeTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] });\n\nconsole.log(response);\n```", + perLanguage: { + typescript: { + method: 'client.files.bulk.removeTags', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.removeTags({\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);", + }, + python: { + method: 'files.bulk.remove_tags', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.remove_tags(\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags=["t-shirt", "round-neck", "sale2019"],\n)\nprint(response.successfully_updated_file_ids)', + }, + java: { + method: 'files().bulk().removeTags', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkRemoveTagsParams;\nimport io.imagekit.models.files.bulk.BulkRemoveTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveTagsParams params = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .build();\n BulkRemoveTagsResponse response = client.files().bulk().removeTags(params);\n }\n}', + }, + kotlin: { + method: 'files().bulk().removeTags', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsParams\nimport com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkRemoveTagsParams = BulkRemoveTagsParams.builder()\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .tags(listOf(\n "t-shirt",\n "round-neck",\n "sale2019",\n ))\n .build()\n val response: BulkRemoveTagsResponse = client.files().bulk().removeTags(params)\n}', + }, + go: { + method: 'client.Files.Bulk.RemoveTags', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Bulk.RemoveTags(context.TODO(), imagekit.FileBulkRemoveTagsParams{\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t\tTags: []string{"t-shirt", "round-neck", "sale2019"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.SuccessfullyUpdatedFileIDs)\n}\n', + }, + ruby: { + method: 'files.bulk.remove_tags', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.bulk.remove_tags(\n file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n tags: ["t-shirt", "round-neck", "sale2019"]\n)\n\nputs(response)', + }, + cli: { + method: 'bulk removeTags', + example: + "imagekit files:bulk remove-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be \\\n --tag t-shirt \\\n --tag round-neck \\\n --tag sale2019", + }, + php: { + method: 'files->bulk->removeTags', + example: + "files->bulk->removeTags(\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n tags: ['t-shirt', 'round-neck', 'sale2019'],\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Bulk.RemoveTags', + example: + 'BulkRemoveTagsParams parameters = new()\n{\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n Tags =\n [\n "t-shirt", "round-neck", "sale2019"\n ],\n};\n\nvar response = await client.Files.Bulk.RemoveTags(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/removeTags \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ],\n "tags": [\n "t-shirt",\n "round-neck",\n "sale2019"\n ]\n }\'', + }, + }, }, { - "name": "removeAiTags", - "endpoint": "/v1/files/removeAITags", - "httpMethod": "post", - "summary": "Remove AI tags (bulk)", - "description": "This API removes AITags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n", - "stainlessPath": "(resource) files.bulk > (method) removeAiTags", - "qualified": "client.files.bulk.removeAITags", - "params": [ - "AITags: string[];", - "fileIds: string[];" - ], - "response": "{ successfullyUpdatedFileIds?: string[]; }", - "markdown": "## removeAiTags\n\n`client.files.bulk.removeAITags(AITags: string[], fileIds: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/removeAITags`\n\nThis API removes AITags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `AITags: string[]`\n An array of AITags that you want to remove from the files.\n\n\n- `fileIds: string[]`\n An array of fileIds from which you want to remove AITags.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.removeAITags({ AITags: ['t-shirt', 'round-neck', 'sale2019'], fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] });\n\nconsole.log(response);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.bulk.removeAITags", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.removeAITags({\n AITags: ['t-shirt', 'round-neck', 'sale2019'],\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);" - }, - "python": { - "method": "files.bulk.remove_ai_tags", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.remove_ai_tags(\n ai_tags=[\"t-shirt\", \"round-neck\", \"sale2019\"],\n file_ids=[\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"],\n)\nprint(response.successfully_updated_file_ids)" - }, - "java": { - "method": "files().bulk().removeAiTags", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkRemoveAiTagsParams;\nimport io.imagekit.models.files.bulk.BulkRemoveAiTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveAiTagsParams params = BulkRemoveAiTagsParams.builder()\n .aiTags(List.of(\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\"\n ))\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .build();\n BulkRemoveAiTagsResponse response = client.files().bulk().removeAiTags(params);\n }\n}" - }, - "kotlin": { - "method": "files().bulk().removeAiTags", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkRemoveAiTagsParams = BulkRemoveAiTagsParams.builder()\n .aiTags(listOf(\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\",\n ))\n .addFileId(\"598821f949c0a938d57563bd\")\n .addFileId(\"598821f949c0a938d57563be\")\n .build()\n val response: BulkRemoveAiTagsResponse = client.files().bulk().removeAiTags(params)\n}" - }, - "go": { - "method": "client.Files.Bulk.RemoveAITags", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Files.Bulk.RemoveAITags(context.TODO(), imagekit.FileBulkRemoveAITagsParams{\n\t\tAITags: []string{\"t-shirt\", \"round-neck\", \"sale2019\"},\n\t\tFileIDs: []string{\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.SuccessfullyUpdatedFileIDs)\n}\n" - }, - "ruby": { - "method": "files.bulk.remove_ai_tags", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.files.bulk.remove_ai_tags(\n ai_tags: [\"t-shirt\", \"round-neck\", \"sale2019\"],\n file_ids: [\"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"]\n)\n\nputs(response)" - }, - "cli": { - "method": "bulk removeAiTags", - "example": "imagekit files:bulk remove-ai-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --ai-tag t-shirt \\\n --ai-tag round-neck \\\n --ai-tag sale2019 \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be" - }, - "php": { - "method": "files->bulk->removeAITags", - "example": "files->bulk->removeAITags(\n aiTags: ['t-shirt', 'round-neck', 'sale2019'],\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n);\n\nvar_dump($response);" - }, - "csharp": { - "method": "Files.Bulk.RemoveAITags", - "example": "BulkRemoveAITagsParams parameters = new()\n{\n AITags =\n [\n \"t-shirt\", \"round-neck\", \"sale2019\"\n ],\n FileIds =\n [\n \"598821f949c0a938d57563bd\", \"598821f949c0a938d57563be\"\n ],\n};\n\nvar response = await client.Files.Bulk.RemoveAITags(parameters);\n\nConsole.WriteLine(response);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/removeAITags \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"AITags\": [\n \"t-shirt\",\n \"round-neck\",\n \"sale2019\"\n ],\n \"fileIds\": [\n \"598821f949c0a938d57563bd\",\n \"598821f949c0a938d57563be\"\n ]\n }'" - } - } + name: 'removeAiTags', + endpoint: '/v1/files/removeAITags', + httpMethod: 'post', + summary: 'Remove AI tags (bulk)', + description: + 'This API removes AITags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n', + stainlessPath: '(resource) files.bulk > (method) removeAiTags', + qualified: 'client.files.bulk.removeAITags', + params: ['AITags: string[];', 'fileIds: string[];'], + response: '{ successfullyUpdatedFileIds?: string[]; }', + markdown: + "## removeAiTags\n\n`client.files.bulk.removeAITags(AITags: string[], fileIds: string[]): { successfullyUpdatedFileIds?: string[]; }`\n\n**post** `/v1/files/removeAITags`\n\nThis API removes AITags from multiple files in bulk. A maximum of 50 files can be specified at a time.\n\n\n### Parameters\n\n- `AITags: string[]`\n An array of AITags that you want to remove from the files.\n\n\n- `fileIds: string[]`\n An array of fileIds from which you want to remove AITags.\n\n\n### Returns\n\n- `{ successfullyUpdatedFileIds?: string[]; }`\n\n - `successfullyUpdatedFileIds?: string[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.files.bulk.removeAITags({ AITags: ['t-shirt', 'round-neck', 'sale2019'], fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] });\n\nconsole.log(response);\n```", + perLanguage: { + typescript: { + method: 'client.files.bulk.removeAITags', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.bulk.removeAITags({\n AITags: ['t-shirt', 'round-neck', 'sale2019'],\n fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n});\n\nconsole.log(response.successfullyUpdatedFileIds);", + }, + python: { + method: 'files.bulk.remove_ai_tags', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.files.bulk.remove_ai_tags(\n ai_tags=["t-shirt", "round-neck", "sale2019"],\n file_ids=["598821f949c0a938d57563bd", "598821f949c0a938d57563be"],\n)\nprint(response.successfully_updated_file_ids)', + }, + java: { + method: 'files().bulk().removeAiTags', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.bulk.BulkRemoveAiTagsParams;\nimport io.imagekit.models.files.bulk.BulkRemoveAiTagsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n BulkRemoveAiTagsParams params = BulkRemoveAiTagsParams.builder()\n .aiTags(List.of(\n "t-shirt",\n "round-neck",\n "sale2019"\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build();\n BulkRemoveAiTagsResponse response = client.files().bulk().removeAiTags(params);\n }\n}', + }, + kotlin: { + method: 'files().bulk().removeAiTags', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams\nimport com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: BulkRemoveAiTagsParams = BulkRemoveAiTagsParams.builder()\n .aiTags(listOf(\n "t-shirt",\n "round-neck",\n "sale2019",\n ))\n .addFileId("598821f949c0a938d57563bd")\n .addFileId("598821f949c0a938d57563be")\n .build()\n val response: BulkRemoveAiTagsResponse = client.files().bulk().removeAiTags(params)\n}', + }, + go: { + method: 'client.Files.Bulk.RemoveAITags', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Files.Bulk.RemoveAITags(context.TODO(), imagekit.FileBulkRemoveAITagsParams{\n\t\tAITags: []string{"t-shirt", "round-neck", "sale2019"},\n\t\tFileIDs: []string{"598821f949c0a938d57563bd", "598821f949c0a938d57563be"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.SuccessfullyUpdatedFileIDs)\n}\n', + }, + ruby: { + method: 'files.bulk.remove_ai_tags', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.files.bulk.remove_ai_tags(\n ai_tags: ["t-shirt", "round-neck", "sale2019"],\n file_ids: ["598821f949c0a938d57563bd", "598821f949c0a938d57563be"]\n)\n\nputs(response)', + }, + cli: { + method: 'bulk removeAiTags', + example: + "imagekit files:bulk remove-ai-tags \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --ai-tag t-shirt \\\n --ai-tag round-neck \\\n --ai-tag sale2019 \\\n --file-id 598821f949c0a938d57563bd \\\n --file-id 598821f949c0a938d57563be", + }, + php: { + method: 'files->bulk->removeAITags', + example: + "files->bulk->removeAITags(\n aiTags: ['t-shirt', 'round-neck', 'sale2019'],\n fileIDs: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'],\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Files.Bulk.RemoveAITags', + example: + 'BulkRemoveAITagsParams parameters = new()\n{\n AITags =\n [\n "t-shirt", "round-neck", "sale2019"\n ],\n FileIds =\n [\n "598821f949c0a938d57563bd", "598821f949c0a938d57563be"\n ],\n};\n\nvar response = await client.Files.Bulk.RemoveAITags(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/removeAITags \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "AITags": [\n "t-shirt",\n "round-neck",\n "sale2019"\n ],\n "fileIds": [\n "598821f949c0a938d57563bd",\n "598821f949c0a938d57563be"\n ]\n }\'', + }, + }, }, { - "name": "list", - "endpoint": "/v1/files/{fileId}/versions", - "httpMethod": "get", - "summary": "List file versions", - "description": "This API returns details of all versions of a file.\n", - "stainlessPath": "(resource) files.versions > (method) list", - "qualified": "client.files.versions.list", - "params": [ - "fileId: string;" - ], - "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }[]", - "markdown": "## list\n\n`client.files.versions.list(fileId: string): object[]`\n\n**get** `/v1/files/{fileId}/versions`\n\nThis API returns details of all versions of a file.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst files = await client.files.versions.list('fileId');\n\nconsole.log(files);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.versions.list", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst files = await client.files.versions.list('fileId');\n\nconsole.log(files);" - }, - "python": { - "method": "files.versions.list", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfiles = client.files.versions.list(\n \"fileId\",\n)\nprint(files)" - }, - "java": { - "method": "files().versions().list", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List files = client.files().versions().list(\"fileId\");\n }\n}" - }, - "kotlin": { - "method": "files().versions().list", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val files: List = client.files().versions().list(\"fileId\")\n}" - }, - "go": { - "method": "client.Files.Versions.List", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfiles, err := client.Files.Versions.List(context.TODO(), \"fileId\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", files)\n}\n" - }, - "ruby": { - "method": "files.versions.list", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfiles = image_kit.files.versions.list(\"fileId\")\n\nputs(files)" - }, - "cli": { - "method": "versions list", - "example": "imagekit files:versions list \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId" - }, - "php": { - "method": "files->versions->list", - "example": "files->versions->list('fileId');\n\nvar_dump($files);" - }, - "csharp": { - "method": "Files.Versions.List", - "example": "VersionListParams parameters = new() { FileID = \"fileId\" };\n\nvar files = await client.Files.Versions.List(parameters);\n\nConsole.WriteLine(files);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/versions \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'list', + endpoint: '/v1/files/{fileId}/versions', + httpMethod: 'get', + summary: 'List file versions', + description: 'This API returns details of all versions of a file.\n', + stainlessPath: '(resource) files.versions > (method) list', + qualified: 'client.files.versions.list', + params: ['fileId: string;'], + response: + "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }[]", + markdown: + "## list\n\n`client.files.versions.list(fileId: string): object[]`\n\n**get** `/v1/files/{fileId}/versions`\n\nThis API returns details of all versions of a file.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst files = await client.files.versions.list('fileId');\n\nconsole.log(files);\n```", + perLanguage: { + typescript: { + method: 'client.files.versions.list', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst files = await client.files.versions.list('fileId');\n\nconsole.log(files);", + }, + python: { + method: 'files.versions.list', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfiles = client.files.versions.list(\n "fileId",\n)\nprint(files)', + }, + java: { + method: 'files().versions().list', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List files = client.files().versions().list("fileId");\n }\n}', + }, + kotlin: { + method: 'files().versions().list', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val files: List = client.files().versions().list("fileId")\n}', + }, + go: { + method: 'client.Files.Versions.List', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfiles, err := client.Files.Versions.List(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", files)\n}\n', + }, + ruby: { + method: 'files.versions.list', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfiles = image_kit.files.versions.list("fileId")\n\nputs(files)', + }, + cli: { + method: 'versions list', + example: + "imagekit files:versions list \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", + }, + php: { + method: 'files->versions->list', + example: + "files->versions->list('fileId');\n\nvar_dump($files);", + }, + csharp: { + method: 'Files.Versions.List', + example: + 'VersionListParams parameters = new() { FileID = "fileId" };\n\nvar files = await client.Files.Versions.List(parameters);\n\nConsole.WriteLine(files);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "get", - "endpoint": "/v1/files/{fileId}/versions/{versionId}", - "httpMethod": "get", - "summary": "Get file version details", - "description": "This API returns an object with details or attributes of a file version.", - "stainlessPath": "(resource) files.versions > (method) get", - "qualified": "client.files.versions.get", - "params": [ - "fileId: string;", - "versionId: string;" - ], - "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", - "markdown": "## get\n\n`client.files.versions.get(fileId: string, versionId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/versions/{versionId}`\n\nThis API returns an object with details or attributes of a file version.\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.versions.get('versionId', { fileId: 'fileId' });\n\nconsole.log(file);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.versions.get", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.versions.get('versionId', { fileId: 'fileId' });\n\nconsole.log(file.videoCodec);" - }, - "python": { - "method": "files.versions.get", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfile = client.files.versions.get(\n version_id=\"versionId\",\n file_id=\"fileId\",\n)\nprint(file.video_codec)" - }, - "java": { - "method": "files().versions().get", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionGetParams params = VersionGetParams.builder()\n .fileId(\"fileId\")\n .versionId(\"versionId\")\n .build();\n File file = client.files().versions().get(params);\n }\n}" - }, - "kotlin": { - "method": "files().versions().get", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionGetParams = VersionGetParams.builder()\n .fileId(\"fileId\")\n .versionId(\"versionId\")\n .build()\n val file: File = client.files().versions().get(params)\n}" - }, - "go": { - "method": "client.Files.Versions.Get", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfile, err := client.Files.Versions.Get(\n\t\tcontext.TODO(),\n\t\t\"versionId\",\n\t\timagekit.FileVersionGetParams{\n\t\t\tFileID: \"fileId\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", file.VideoCodec)\n}\n" - }, - "ruby": { - "method": "files.versions.get", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfile = image_kit.files.versions.get(\"versionId\", file_id: \"fileId\")\n\nputs(file)" - }, - "cli": { - "method": "versions get", - "example": "imagekit files:versions get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId" - }, - "php": { - "method": "files->versions->get", - "example": "files->versions->get('versionId', fileID: 'fileId');\n\nvar_dump($file);" - }, - "csharp": { - "method": "Files.Versions.Get", - "example": "VersionGetParams parameters = new()\n{\n FileID = \"fileId\",\n VersionID = \"versionId\",\n};\n\nvar file = await client.Files.Versions.Get(parameters);\n\nConsole.WriteLine(file);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'get', + endpoint: '/v1/files/{fileId}/versions/{versionId}', + httpMethod: 'get', + summary: 'Get file version details', + description: 'This API returns an object with details or attributes of a file version.', + stainlessPath: '(resource) files.versions > (method) get', + qualified: 'client.files.versions.get', + params: ['fileId: string;', 'versionId: string;'], + response: + "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", + markdown: + "## get\n\n`client.files.versions.get(fileId: string, versionId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/versions/{versionId}`\n\nThis API returns an object with details or attributes of a file version.\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.versions.get('versionId', { fileId: 'fileId' });\n\nconsole.log(file);\n```", + perLanguage: { + typescript: { + method: 'client.files.versions.get', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.versions.get('versionId', { fileId: 'fileId' });\n\nconsole.log(file.videoCodec);", + }, + python: { + method: 'files.versions.get', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.versions.get(\n version_id="versionId",\n file_id="fileId",\n)\nprint(file.video_codec)', + }, + java: { + method: 'files().versions().get', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionGetParams params = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().get(params);\n }\n}', + }, + kotlin: { + method: 'files().versions().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionGetParams = VersionGetParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build()\n val file: File = client.files().versions().get(params)\n}', + }, + go: { + method: 'client.Files.Versions.Get', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Versions.Get(\n\t\tcontext.TODO(),\n\t\t"versionId",\n\t\timagekit.FileVersionGetParams{\n\t\t\tFileID: "fileId",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file.VideoCodec)\n}\n', + }, + ruby: { + method: 'files.versions.get', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfile = image_kit.files.versions.get("versionId", file_id: "fileId")\n\nputs(file)', + }, + cli: { + method: 'versions get', + example: + "imagekit files:versions get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId", + }, + php: { + method: 'files->versions->get', + example: + "files->versions->get('versionId', fileID: 'fileId');\n\nvar_dump($file);", + }, + csharp: { + method: 'Files.Versions.Get', + example: + 'VersionGetParams parameters = new()\n{\n FileID = "fileId",\n VersionID = "versionId",\n};\n\nvar file = await client.Files.Versions.Get(parameters);\n\nConsole.WriteLine(file);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "delete", - "endpoint": "/v1/files/{fileId}/versions/{versionId}", - "httpMethod": "delete", - "summary": "Delete file version", - "description": "This API deletes a non-current file version permanently. The API returns an empty response.\n\nNote: If you want to delete all versions of a file, use the delete file API.\n", - "stainlessPath": "(resource) files.versions > (method) delete", - "qualified": "client.files.versions.delete", - "params": [ - "fileId: string;", - "versionId: string;" - ], - "response": "{ }", - "markdown": "## delete\n\n`client.files.versions.delete(fileId: string, versionId: string): { }`\n\n**delete** `/v1/files/{fileId}/versions/{versionId}`\n\nThis API deletes a non-current file version permanently. The API returns an empty response.\n\nNote: If you want to delete all versions of a file, use the delete file API.\n\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst version = await client.files.versions.delete('versionId', { fileId: 'fileId' });\n\nconsole.log(version);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.versions.delete", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst version = await client.files.versions.delete('versionId', { fileId: 'fileId' });\n\nconsole.log(version);" - }, - "python": { - "method": "files.versions.delete", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nversion = client.files.versions.delete(\n version_id=\"versionId\",\n file_id=\"fileId\",\n)\nprint(version)" - }, - "java": { - "method": "files().versions().delete", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.versions.VersionDeleteParams;\nimport io.imagekit.models.files.versions.VersionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionDeleteParams params = VersionDeleteParams.builder()\n .fileId(\"fileId\")\n .versionId(\"versionId\")\n .build();\n VersionDeleteResponse version = client.files().versions().delete(params);\n }\n}" - }, - "kotlin": { - "method": "files().versions().delete", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.versions.VersionDeleteParams\nimport com.imagekit.api.models.files.versions.VersionDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionDeleteParams = VersionDeleteParams.builder()\n .fileId(\"fileId\")\n .versionId(\"versionId\")\n .build()\n val version: VersionDeleteResponse = client.files().versions().delete(params)\n}" - }, - "go": { - "method": "client.Files.Versions.Delete", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tversion, err := client.Files.Versions.Delete(\n\t\tcontext.TODO(),\n\t\t\"versionId\",\n\t\timagekit.FileVersionDeleteParams{\n\t\t\tFileID: \"fileId\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", version)\n}\n" - }, - "ruby": { - "method": "files.versions.delete", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nversion = image_kit.files.versions.delete(\"versionId\", file_id: \"fileId\")\n\nputs(version)" - }, - "cli": { - "method": "versions delete", - "example": "imagekit files:versions delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId" - }, - "php": { - "method": "files->versions->delete", - "example": "files->versions->delete('versionId', fileID: 'fileId');\n\nvar_dump($version);" - }, - "csharp": { - "method": "Files.Versions.Delete", - "example": "VersionDeleteParams parameters = new()\n{\n FileID = \"fileId\",\n VersionID = \"versionId\",\n};\n\nvar version = await client.Files.Versions.Delete(parameters);\n\nConsole.WriteLine(version);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'delete', + endpoint: '/v1/files/{fileId}/versions/{versionId}', + httpMethod: 'delete', + summary: 'Delete file version', + description: + 'This API deletes a non-current file version permanently. The API returns an empty response.\n\nNote: If you want to delete all versions of a file, use the delete file API.\n', + stainlessPath: '(resource) files.versions > (method) delete', + qualified: 'client.files.versions.delete', + params: ['fileId: string;', 'versionId: string;'], + response: '{ }', + markdown: + "## delete\n\n`client.files.versions.delete(fileId: string, versionId: string): { }`\n\n**delete** `/v1/files/{fileId}/versions/{versionId}`\n\nThis API deletes a non-current file version permanently. The API returns an empty response.\n\nNote: If you want to delete all versions of a file, use the delete file API.\n\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst version = await client.files.versions.delete('versionId', { fileId: 'fileId' });\n\nconsole.log(version);\n```", + perLanguage: { + typescript: { + method: 'client.files.versions.delete', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst version = await client.files.versions.delete('versionId', { fileId: 'fileId' });\n\nconsole.log(version);", + }, + python: { + method: 'files.versions.delete', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nversion = client.files.versions.delete(\n version_id="versionId",\n file_id="fileId",\n)\nprint(version)', + }, + java: { + method: 'files().versions().delete', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.versions.VersionDeleteParams;\nimport io.imagekit.models.files.versions.VersionDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionDeleteParams params = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n VersionDeleteResponse version = client.files().versions().delete(params);\n }\n}', + }, + kotlin: { + method: 'files().versions().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.versions.VersionDeleteParams\nimport com.imagekit.api.models.files.versions.VersionDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionDeleteParams = VersionDeleteParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build()\n val version: VersionDeleteResponse = client.files().versions().delete(params)\n}', + }, + go: { + method: 'client.Files.Versions.Delete', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tversion, err := client.Files.Versions.Delete(\n\t\tcontext.TODO(),\n\t\t"versionId",\n\t\timagekit.FileVersionDeleteParams{\n\t\t\tFileID: "fileId",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", version)\n}\n', + }, + ruby: { + method: 'files.versions.delete', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nversion = image_kit.files.versions.delete("versionId", file_id: "fileId")\n\nputs(version)', + }, + cli: { + method: 'versions delete', + example: + "imagekit files:versions delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId", + }, + php: { + method: 'files->versions->delete', + example: + "files->versions->delete('versionId', fileID: 'fileId');\n\nvar_dump($version);", + }, + csharp: { + method: 'Files.Versions.Delete', + example: + 'VersionDeleteParams parameters = new()\n{\n FileID = "fileId",\n VersionID = "versionId",\n};\n\nvar version = await client.Files.Versions.Delete(parameters);\n\nConsole.WriteLine(version);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "restore", - "endpoint": "/v1/files/{fileId}/versions/{versionId}/restore", - "httpMethod": "put", - "summary": "Restore file version", - "description": "This API restores a file version as the current file version.\n", - "stainlessPath": "(resource) files.versions > (method) restore", - "qualified": "client.files.versions.restore", - "params": [ - "fileId: string;", - "versionId: string;" - ], - "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", - "markdown": "## restore\n\n`client.files.versions.restore(fileId: string, versionId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**put** `/v1/files/{fileId}/versions/{versionId}/restore`\n\nThis API restores a file version as the current file version.\n\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.versions.restore('versionId', { fileId: 'fileId' });\n\nconsole.log(file);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.versions.restore", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.versions.restore('versionId', { fileId: 'fileId' });\n\nconsole.log(file.videoCodec);" - }, - "python": { - "method": "files.versions.restore", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfile = client.files.versions.restore(\n version_id=\"versionId\",\n file_id=\"fileId\",\n)\nprint(file.video_codec)" - }, - "java": { - "method": "files().versions().restore", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionRestoreParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionRestoreParams params = VersionRestoreParams.builder()\n .fileId(\"fileId\")\n .versionId(\"versionId\")\n .build();\n File file = client.files().versions().restore(params);\n }\n}" - }, - "kotlin": { - "method": "files().versions().restore", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionRestoreParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionRestoreParams = VersionRestoreParams.builder()\n .fileId(\"fileId\")\n .versionId(\"versionId\")\n .build()\n val file: File = client.files().versions().restore(params)\n}" - }, - "go": { - "method": "client.Files.Versions.Restore", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfile, err := client.Files.Versions.Restore(\n\t\tcontext.TODO(),\n\t\t\"versionId\",\n\t\timagekit.FileVersionRestoreParams{\n\t\t\tFileID: \"fileId\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", file.VideoCodec)\n}\n" - }, - "ruby": { - "method": "files.versions.restore", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfile = image_kit.files.versions.restore(\"versionId\", file_id: \"fileId\")\n\nputs(file)" - }, - "cli": { - "method": "versions restore", - "example": "imagekit files:versions restore \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId" - }, - "php": { - "method": "files->versions->restore", - "example": "files->versions->restore('versionId', fileID: 'fileId');\n\nvar_dump($file);" - }, - "csharp": { - "method": "Files.Versions.Restore", - "example": "VersionRestoreParams parameters = new()\n{\n FileID = \"fileId\",\n VersionID = \"versionId\",\n};\n\nvar file = await client.Files.Versions.Restore(parameters);\n\nConsole.WriteLine(file);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID/restore \\\n -X PUT \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'restore', + endpoint: '/v1/files/{fileId}/versions/{versionId}/restore', + httpMethod: 'put', + summary: 'Restore file version', + description: 'This API restores a file version as the current file version.\n', + stainlessPath: '(resource) files.versions > (method) restore', + qualified: 'client.files.versions.restore', + params: ['fileId: string;', 'versionId: string;'], + response: + "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", + markdown: + "## restore\n\n`client.files.versions.restore(fileId: string, versionId: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**put** `/v1/files/{fileId}/versions/{versionId}/restore`\n\nThis API restores a file version as the current file version.\n\n\n### Parameters\n\n- `fileId: string`\n\n- `versionId: string`\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a file or file version.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `createdAt?: string`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `hasAlpha?: boolean`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `mime?: string`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnail?: string`\n - `type?: 'file' | 'file-version'`\n - `updatedAt?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst file = await client.files.versions.restore('versionId', { fileId: 'fileId' });\n\nconsole.log(file);\n```", + perLanguage: { + typescript: { + method: 'client.files.versions.restore', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst file = await client.files.versions.restore('versionId', { fileId: 'fileId' });\n\nconsole.log(file.videoCodec);", + }, + python: { + method: 'files.versions.restore', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfile = client.files.versions.restore(\n version_id="versionId",\n file_id="fileId",\n)\nprint(file.video_codec)', + }, + java: { + method: 'files().versions().restore', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.File;\nimport io.imagekit.models.files.versions.VersionRestoreParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n VersionRestoreParams params = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build();\n File file = client.files().versions().restore(params);\n }\n}', + }, + kotlin: { + method: 'files().versions().restore', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.File\nimport com.imagekit.api.models.files.versions.VersionRestoreParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: VersionRestoreParams = VersionRestoreParams.builder()\n .fileId("fileId")\n .versionId("versionId")\n .build()\n val file: File = client.files().versions().restore(params)\n}', + }, + go: { + method: 'client.Files.Versions.Restore', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfile, err := client.Files.Versions.Restore(\n\t\tcontext.TODO(),\n\t\t"versionId",\n\t\timagekit.FileVersionRestoreParams{\n\t\t\tFileID: "fileId",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", file.VideoCodec)\n}\n', + }, + ruby: { + method: 'files.versions.restore', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfile = image_kit.files.versions.restore("versionId", file_id: "fileId")\n\nputs(file)', + }, + cli: { + method: 'versions restore', + example: + "imagekit files:versions restore \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId \\\n --version-id versionId", + }, + php: { + method: 'files->versions->restore', + example: + "files->versions->restore('versionId', fileID: 'fileId');\n\nvar_dump($file);", + }, + csharp: { + method: 'Files.Versions.Restore', + example: + 'VersionRestoreParams parameters = new()\n{\n FileID = "fileId",\n VersionID = "versionId",\n};\n\nvar file = await client.Files.Versions.Restore(parameters);\n\nConsole.WriteLine(file);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID/versions/$VERSION_ID/restore \\\n -X PUT \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "get", - "endpoint": "/v1/files/{fileId}/metadata", - "httpMethod": "get", - "summary": "Get uploaded file metadata", - "description": "You can programmatically get image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API.\n\nYou can also get the metadata in upload API response by passing `metadata` in `responseFields` parameter.\n", - "stainlessPath": "(resource) files.metadata > (method) get", - "qualified": "client.files.metadata.get", - "params": [ - "fileId: string;" - ], - "response": "{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: object; gps?: object; image?: object; interoperability?: object; makernote?: object; thumbnail?: object; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }", - "markdown": "## get\n\n`client.files.metadata.get(fileId: string): { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/metadata`\n\nYou can programmatically get image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API.\n\nYou can also get the metadata in upload API response by passing `metadata` in `responseFields` parameter.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n JSON object containing metadata.\n\n - `audioCodec?: string`\n - `bitRate?: number`\n - `density?: number`\n - `duration?: number`\n - `exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }`\n - `format?: string`\n - `hasColorProfile?: boolean`\n - `hasTransparency?: boolean`\n - `height?: number`\n - `pHash?: string`\n - `quality?: number`\n - `size?: number`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst metadata = await client.files.metadata.get('fileId');\n\nconsole.log(metadata);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.metadata.get", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst metadata = await client.files.metadata.get('fileId');\n\nconsole.log(metadata.videoCodec);" - }, - "python": { - "method": "files.metadata.get", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nmetadata = client.files.metadata.get(\n \"fileId\",\n)\nprint(metadata.video_codec)" - }, - "java": { - "method": "files().metadata().get", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.Metadata;\nimport io.imagekit.models.files.metadata.MetadataGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n Metadata metadata = client.files().metadata().get(\"fileId\");\n }\n}" - }, - "kotlin": { - "method": "files().metadata().get", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.Metadata\nimport com.imagekit.api.models.files.metadata.MetadataGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val metadata: Metadata = client.files().metadata().get(\"fileId\")\n}" - }, - "go": { - "method": "client.Files.Metadata.Get", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tmetadata, err := client.Files.Metadata.Get(context.TODO(), \"fileId\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", metadata.VideoCodec)\n}\n" - }, - "ruby": { - "method": "files.metadata.get", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nmetadata = image_kit.files.metadata.get(\"fileId\")\n\nputs(metadata)" - }, - "cli": { - "method": "metadata get", - "example": "imagekit files:metadata get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId" - }, - "php": { - "method": "files->metadata->get", - "example": "files->metadata->get('fileId');\n\nvar_dump($metadata);" - }, - "csharp": { - "method": "Files.Metadata.Get", - "example": "MetadataGetParams parameters = new() { FileID = \"fileId\" };\n\nvar metadata = await client.Files.Metadata.Get(parameters);\n\nConsole.WriteLine(metadata);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/$FILE_ID/metadata \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'get', + endpoint: '/v1/files/{fileId}/metadata', + httpMethod: 'get', + summary: 'Get uploaded file metadata', + description: + 'You can programmatically get image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API.\n\nYou can also get the metadata in upload API response by passing `metadata` in `responseFields` parameter.\n', + stainlessPath: '(resource) files.metadata > (method) get', + qualified: 'client.files.metadata.get', + params: ['fileId: string;'], + response: + '{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: object; gps?: object; image?: object; interoperability?: object; makernote?: object; thumbnail?: object; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }', + markdown: + "## get\n\n`client.files.metadata.get(fileId: string): { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n\n**get** `/v1/files/{fileId}/metadata`\n\nYou can programmatically get image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API.\n\nYou can also get the metadata in upload API response by passing `metadata` in `responseFields` parameter.\n\n\n### Parameters\n\n- `fileId: string`\n\n### Returns\n\n- `{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n JSON object containing metadata.\n\n - `audioCodec?: string`\n - `bitRate?: number`\n - `density?: number`\n - `duration?: number`\n - `exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }`\n - `format?: string`\n - `hasColorProfile?: boolean`\n - `hasTransparency?: boolean`\n - `height?: number`\n - `pHash?: string`\n - `quality?: number`\n - `size?: number`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst metadata = await client.files.metadata.get('fileId');\n\nconsole.log(metadata);\n```", + perLanguage: { + typescript: { + method: 'client.files.metadata.get', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst metadata = await client.files.metadata.get('fileId');\n\nconsole.log(metadata.videoCodec);", + }, + python: { + method: 'files.metadata.get', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nmetadata = client.files.metadata.get(\n "fileId",\n)\nprint(metadata.video_codec)', + }, + java: { + method: 'files().metadata().get', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.Metadata;\nimport io.imagekit.models.files.metadata.MetadataGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n Metadata metadata = client.files().metadata().get("fileId");\n }\n}', + }, + kotlin: { + method: 'files().metadata().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.Metadata\nimport com.imagekit.api.models.files.metadata.MetadataGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val metadata: Metadata = client.files().metadata().get("fileId")\n}', + }, + go: { + method: 'client.Files.Metadata.Get', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tmetadata, err := client.Files.Metadata.Get(context.TODO(), "fileId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", metadata.VideoCodec)\n}\n', + }, + ruby: { + method: 'files.metadata.get', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nmetadata = image_kit.files.metadata.get("fileId")\n\nputs(metadata)', + }, + cli: { + method: 'metadata get', + example: + "imagekit files:metadata get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file-id fileId", + }, + php: { + method: 'files->metadata->get', + example: + "files->metadata->get('fileId');\n\nvar_dump($metadata);", + }, + csharp: { + method: 'Files.Metadata.Get', + example: + 'MetadataGetParams parameters = new() { FileID = "fileId" };\n\nvar metadata = await client.Files.Metadata.Get(parameters);\n\nConsole.WriteLine(metadata);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/$FILE_ID/metadata \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "getFromURL", - "endpoint": "/v1/metadata", - "httpMethod": "get", - "summary": "Get metadata from remote URL", - "description": "Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API.\n", - "stainlessPath": "(resource) files.metadata > (method) getFromURL", - "qualified": "client.files.metadata.getFromURL", - "params": [ - "url: string;" - ], - "response": "{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: object; gps?: object; image?: object; interoperability?: object; makernote?: object; thumbnail?: object; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }", - "markdown": "## getFromURL\n\n`client.files.metadata.getFromURL(url: string): { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n\n**get** `/v1/metadata`\n\nGet image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API.\n\n\n### Parameters\n\n- `url: string`\n Should be a valid file URL. It should be accessible using your ImageKit.io account.\n\n\n### Returns\n\n- `{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n JSON object containing metadata.\n\n - `audioCodec?: string`\n - `bitRate?: number`\n - `density?: number`\n - `duration?: number`\n - `exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }`\n - `format?: string`\n - `hasColorProfile?: boolean`\n - `hasTransparency?: boolean`\n - `height?: number`\n - `pHash?: string`\n - `quality?: number`\n - `size?: number`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst metadata = await client.files.metadata.getFromURL({ url: 'https://example.com' });\n\nconsole.log(metadata);\n```", - "perLanguage": { - "typescript": { - "method": "client.files.metadata.getFromURL", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst metadata = await client.files.metadata.getFromURL({ url: 'https://example.com' });\n\nconsole.log(metadata.videoCodec);" - }, - "python": { - "method": "files.metadata.get_from_url", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nmetadata = client.files.metadata.get_from_url(\n url=\"https://example.com\",\n)\nprint(metadata.video_codec)" - }, - "java": { - "method": "files().metadata().getFromUrl", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.Metadata;\nimport io.imagekit.models.files.metadata.MetadataGetFromUrlParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n MetadataGetFromUrlParams params = MetadataGetFromUrlParams.builder()\n .url(\"https://example.com\")\n .build();\n Metadata metadata = client.files().metadata().getFromUrl(params);\n }\n}" - }, - "kotlin": { - "method": "files().metadata().getFromUrl", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.Metadata\nimport com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: MetadataGetFromUrlParams = MetadataGetFromUrlParams.builder()\n .url(\"https://example.com\")\n .build()\n val metadata: Metadata = client.files().metadata().getFromUrl(params)\n}" - }, - "go": { - "method": "client.Files.Metadata.GetFromURL", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tmetadata, err := client.Files.Metadata.GetFromURL(context.TODO(), imagekit.FileMetadataGetFromURLParams{\n\t\tURL: \"https://example.com\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", metadata.VideoCodec)\n}\n" - }, - "ruby": { - "method": "files.metadata.get_from_url", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nmetadata = image_kit.files.metadata.get_from_url(url: \"https://example.com\")\n\nputs(metadata)" - }, - "cli": { - "method": "metadata getFromURL", - "example": "imagekit files:metadata get-from-url \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --url https://example.com" - }, - "php": { - "method": "files->metadata->getFromURL", - "example": "files->metadata->getFromURL(url: 'https://example.com');\n\nvar_dump($metadata);" - }, - "csharp": { - "method": "Files.Metadata.GetFromUrl", - "example": "MetadataGetFromUrlParams parameters = new() { Url = \"https://example.com\" };\n\nvar metadata = await client.Files.Metadata.GetFromUrl(parameters);\n\nConsole.WriteLine(metadata);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/metadata \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'getFromURL', + endpoint: '/v1/metadata', + httpMethod: 'get', + summary: 'Get metadata from remote URL', + description: + 'Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API.\n', + stainlessPath: '(resource) files.metadata > (method) getFromURL', + qualified: 'client.files.metadata.getFromURL', + params: ['url: string;'], + response: + '{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: object; gps?: object; image?: object; interoperability?: object; makernote?: object; thumbnail?: object; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }', + markdown: + "## getFromURL\n\n`client.files.metadata.getFromURL(url: string): { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n\n**get** `/v1/metadata`\n\nGet image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API.\n\n\n### Parameters\n\n- `url: string`\n Should be a valid file URL. It should be accessible using your ImageKit.io account.\n\n\n### Returns\n\n- `{ audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n JSON object containing metadata.\n\n - `audioCodec?: string`\n - `bitRate?: number`\n - `density?: number`\n - `duration?: number`\n - `exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }`\n - `format?: string`\n - `hasColorProfile?: boolean`\n - `hasTransparency?: boolean`\n - `height?: number`\n - `pHash?: string`\n - `quality?: number`\n - `size?: number`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst metadata = await client.files.metadata.getFromURL({ url: 'https://example.com' });\n\nconsole.log(metadata);\n```", + perLanguage: { + typescript: { + method: 'client.files.metadata.getFromURL', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst metadata = await client.files.metadata.getFromURL({ url: 'https://example.com' });\n\nconsole.log(metadata.videoCodec);", + }, + python: { + method: 'files.metadata.get_from_url', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nmetadata = client.files.metadata.get_from_url(\n url="https://example.com",\n)\nprint(metadata.video_codec)', + }, + java: { + method: 'files().metadata().getFromUrl', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.Metadata;\nimport io.imagekit.models.files.metadata.MetadataGetFromUrlParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n MetadataGetFromUrlParams params = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build();\n Metadata metadata = client.files().metadata().getFromUrl(params);\n }\n}', + }, + kotlin: { + method: 'files().metadata().getFromUrl', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.Metadata\nimport com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: MetadataGetFromUrlParams = MetadataGetFromUrlParams.builder()\n .url("https://example.com")\n .build()\n val metadata: Metadata = client.files().metadata().getFromUrl(params)\n}', + }, + go: { + method: 'client.Files.Metadata.GetFromURL', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tmetadata, err := client.Files.Metadata.GetFromURL(context.TODO(), imagekit.FileMetadataGetFromURLParams{\n\t\tURL: "https://example.com",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", metadata.VideoCodec)\n}\n', + }, + ruby: { + method: 'files.metadata.get_from_url', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nmetadata = image_kit.files.metadata.get_from_url(url: "https://example.com")\n\nputs(metadata)', + }, + cli: { + method: 'metadata getFromURL', + example: + "imagekit files:metadata get-from-url \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --url https://example.com", + }, + php: { + method: 'files->metadata->getFromURL', + example: + "files->metadata->getFromURL(url: 'https://example.com');\n\nvar_dump($metadata);", + }, + csharp: { + method: 'Files.Metadata.GetFromUrl', + example: + 'MetadataGetFromUrlParams parameters = new() { Url = "https://example.com" };\n\nvar metadata = await client.Files.Metadata.GetFromUrl(parameters);\n\nConsole.WriteLine(metadata);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/metadata \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "list", - "endpoint": "/v1/saved-extensions", - "httpMethod": "get", - "summary": "List all saved extensions", - "description": "This API returns an array of all saved extensions for your account. Saved extensions allow you to save complex extension configurations and reuse them by referencing them by ID in upload or update file APIs.\n", - "stainlessPath": "(resource) savedExtensions > (method) list", - "qualified": "client.savedExtensions.list", - "response": "{ id?: string; config?: object | object | object | object; createdAt?: string; description?: string; name?: string; updatedAt?: string; }[]", - "markdown": "## list\n\n`client.savedExtensions.list(): object[]`\n\n**get** `/v1/saved-extensions`\n\nThis API returns an array of all saved extensions for your account. Saved extensions allow you to save complex extension configurations and reuse them by referencing them by ID in upload or update file APIs.\n\n\n### Returns\n\n- `{ id?: string; config?: object | object | object | object; createdAt?: string; description?: string; name?: string; updatedAt?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtensions = await client.savedExtensions.list();\n\nconsole.log(savedExtensions);\n```", - "perLanguage": { - "typescript": { - "method": "client.savedExtensions.list", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtensions = await client.savedExtensions.list();\n\nconsole.log(savedExtensions);" - }, - "python": { - "method": "saved_extensions.list", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nsaved_extensions = client.saved_extensions.list()\nprint(saved_extensions)" - }, - "java": { - "method": "savedExtensions().list", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List savedExtensions = client.savedExtensions().list();\n }\n}" - }, - "kotlin": { - "method": "savedExtensions().list", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtensions: List = client.savedExtensions().list()\n}" - }, - "go": { - "method": "client.SavedExtensions.List", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tsavedExtensions, err := client.SavedExtensions.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", savedExtensions)\n}\n" - }, - "ruby": { - "method": "saved_extensions.list", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nsaved_extensions = image_kit.saved_extensions.list\n\nputs(saved_extensions)" - }, - "cli": { - "method": "savedExtensions list", - "example": "imagekit saved-extensions list \\\n --private-key 'My Private Key' \\\n --password 'My Password'" - }, - "php": { - "method": "savedExtensions->list", - "example": "savedExtensions->list();\n\nvar_dump($savedExtensions);" - }, - "csharp": { - "method": "SavedExtensions.List", - "example": "SavedExtensionListParams parameters = new();\n\nvar savedExtensions = await client.SavedExtensions.List(parameters);\n\nConsole.WriteLine(savedExtensions);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/saved-extensions \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'list', + endpoint: '/v1/saved-extensions', + httpMethod: 'get', + summary: 'List all saved extensions', + description: + 'This API returns an array of all saved extensions for your account. Saved extensions allow you to save complex extension configurations and reuse them by referencing them by ID in upload or update file APIs.\n', + stainlessPath: '(resource) savedExtensions > (method) list', + qualified: 'client.savedExtensions.list', + response: + '{ id?: string; config?: object | object | object | object; createdAt?: string; description?: string; name?: string; updatedAt?: string; }[]', + markdown: + "## list\n\n`client.savedExtensions.list(): object[]`\n\n**get** `/v1/saved-extensions`\n\nThis API returns an array of all saved extensions for your account. Saved extensions allow you to save complex extension configurations and reuse them by referencing them by ID in upload or update file APIs.\n\n\n### Returns\n\n- `{ id?: string; config?: object | object | object | object; createdAt?: string; description?: string; name?: string; updatedAt?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtensions = await client.savedExtensions.list();\n\nconsole.log(savedExtensions);\n```", + perLanguage: { + typescript: { + method: 'client.savedExtensions.list', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtensions = await client.savedExtensions.list();\n\nconsole.log(savedExtensions);", + }, + python: { + method: 'saved_extensions.list', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extensions = client.saved_extensions.list()\nprint(saved_extensions)', + }, + java: { + method: 'savedExtensions().list', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List savedExtensions = client.savedExtensions().list();\n }\n}', + }, + kotlin: { + method: 'savedExtensions().list', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionListParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtensions: List = client.savedExtensions().list()\n}', + }, + go: { + method: 'client.SavedExtensions.List', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtensions, err := client.SavedExtensions.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtensions)\n}\n', + }, + ruby: { + method: 'saved_extensions.list', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nsaved_extensions = image_kit.saved_extensions.list\n\nputs(saved_extensions)', + }, + cli: { + method: 'savedExtensions list', + example: + "imagekit saved-extensions list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'savedExtensions->list', + example: + "savedExtensions->list();\n\nvar_dump($savedExtensions);", + }, + csharp: { + method: 'SavedExtensions.List', + example: + 'SavedExtensionListParams parameters = new();\n\nvar savedExtensions = await client.SavedExtensions.List(parameters);\n\nConsole.WriteLine(savedExtensions);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/saved-extensions \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "create", - "endpoint": "/v1/saved-extensions", - "httpMethod": "post", - "summary": "Create saved extension", - "description": "This API creates a new saved extension. Saved extensions allow you to save complex extension configurations (like AI tasks) and reuse them by referencing the ID in upload or update file APIs.\n\n**Saved extension limit** \\\nYou can create a maximum of 100 saved extensions per account.\n", - "stainlessPath": "(resource) savedExtensions > (method) create", - "qualified": "client.savedExtensions.create", - "params": [ + name: 'create', + endpoint: '/v1/saved-extensions', + httpMethod: 'post', + summary: 'Create saved extension', + description: + 'This API creates a new saved extension. Saved extensions allow you to save complex extension configurations (like AI tasks) and reuse them by referencing the ID in upload or update file APIs.\n\n**Saved extension limit** \\\nYou can create a maximum of 100 saved extensions per account.\n', + stainlessPath: '(resource) savedExtensions > (method) create', + qualified: 'client.savedExtensions.create', + params: [ "config: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; };", - "description: string;", - "name: string;" + 'description: string;', + 'name: string;', ], - "response": "{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }", - "markdown": "## create\n\n`client.savedExtensions.create(config: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }, description: string, name: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**post** `/v1/saved-extensions`\n\nThis API creates a new saved extension. Saved extensions allow you to save complex extension configurations (like AI tasks) and reuse them by referencing the ID in upload or update file APIs.\n\n**Saved extension limit** \\\nYou can create a maximum of 100 saved extensions per account.\n\n\n### Parameters\n\n- `config: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n Configuration object for an extension (base extensions only, not saved extension references).\n\n- `description: string`\n Description of what the saved extension does.\n\n- `name: string`\n Name of the saved extension.\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.create({\n config: { name: 'remove-bg' },\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n});\n\nconsole.log(savedExtension);\n```", - "perLanguage": { - "typescript": { - "method": "client.savedExtensions.create", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.create({\n config: { name: 'remove-bg' },\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n});\n\nconsole.log(savedExtension.id);" - }, - "python": { - "method": "saved_extensions.create", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.create(\n config={\n \"name\": \"remove-bg\"\n },\n description=\"Analyzes vehicle images for type, condition, and quality assessment\",\n name=\"Car Quality Analysis\",\n)\nprint(saved_extension.id)" - }, - "java": { - "method": "savedExtensions().create", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.ExtensionConfig;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtensionCreateParams params = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description(\"Analyzes vehicle images for type, condition, and quality assessment\")\n .name(\"Car Quality Analysis\")\n .build();\n SavedExtension savedExtension = client.savedExtensions().create(params);\n }\n}" - }, - "kotlin": { - "method": "savedExtensions().create", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.ExtensionConfig\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionCreateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: SavedExtensionCreateParams = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description(\"Analyzes vehicle images for type, condition, and quality assessment\")\n .name(\"Car Quality Analysis\")\n .build()\n val savedExtension: SavedExtension = client.savedExtensions().create(params)\n}" - }, - "go": { - "method": "client.SavedExtensions.New", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n\t\"github.com/imagekit-developer/imagekit-go/shared\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.New(context.TODO(), imagekit.SavedExtensionNewParams{\n\t\tConfig: shared.ExtensionConfigUnionParam{\n\t\t\tOfRemoveBg: &shared.ExtensionConfigRemoveBgParam{},\n\t\t},\n\t\tDescription: \"Analyzes vehicle images for type, condition, and quality assessment\",\n\t\tName: \"Car Quality Analysis\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", savedExtension.ID)\n}\n" - }, - "ruby": { - "method": "saved_extensions.create", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nsaved_extension = image_kit.saved_extensions.create(\n config: {name: :\"remove-bg\"},\n description: \"Analyzes vehicle images for type, condition, and quality assessment\",\n name: \"Car Quality Analysis\"\n)\n\nputs(saved_extension)" - }, - "cli": { - "method": "savedExtensions create", - "example": "imagekit saved-extensions create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --config '{name: remove-bg}' \\\n --description 'Analyzes vehicle images for type, condition, and quality assessment' \\\n --name 'Car Quality Analysis'" - }, - "php": { - "method": "savedExtensions->create", - "example": "savedExtensions->create(\n config: [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n);\n\nvar_dump($savedExtension);" - }, - "csharp": { - "method": "SavedExtensions.Create", - "example": "SavedExtensionCreateParams parameters = new()\n{\n Config = new RemoveBg()\n {\n Options = new()\n {\n AddShadow = true,\n BgColor = \"bg_color\",\n BgImageUrl = \"bg_image_url\",\n Semitransparency = true,\n },\n },\n Description = \"Analyzes vehicle images for type, condition, and quality assessment\",\n Name = \"Car Quality Analysis\",\n};\n\nvar savedExtension = await client.SavedExtensions.Create(parameters);\n\nConsole.WriteLine(savedExtension);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/saved-extensions \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"config\": {\n \"name\": \"remove-bg\"\n },\n \"description\": \"Analyzes vehicle images for type, condition, and quality assessment\",\n \"name\": \"Car Quality Analysis\"\n }'" - } - } + response: + "{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }", + markdown: + "## create\n\n`client.savedExtensions.create(config: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }, description: string, name: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**post** `/v1/saved-extensions`\n\nThis API creates a new saved extension. Saved extensions allow you to save complex extension configurations (like AI tasks) and reuse them by referencing the ID in upload or update file APIs.\n\n**Saved extension limit** \\\nYou can create a maximum of 100 saved extensions per account.\n\n\n### Parameters\n\n- `config: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n Configuration object for an extension (base extensions only, not saved extension references).\n\n- `description: string`\n Description of what the saved extension does.\n\n- `name: string`\n Name of the saved extension.\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.create({\n config: { name: 'remove-bg' },\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n});\n\nconsole.log(savedExtension);\n```", + perLanguage: { + typescript: { + method: 'client.savedExtensions.create', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.create({\n config: { name: 'remove-bg' },\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n});\n\nconsole.log(savedExtension.id);", + }, + python: { + method: 'saved_extensions.create', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.create(\n config={\n "name": "remove-bg"\n },\n description="Analyzes vehicle images for type, condition, and quality assessment",\n name="Car Quality Analysis",\n)\nprint(saved_extension.id)', + }, + java: { + method: 'savedExtensions().create', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.ExtensionConfig;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtensionCreateParams params = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build();\n SavedExtension savedExtension = client.savedExtensions().create(params);\n }\n}', + }, + kotlin: { + method: 'savedExtensions().create', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.ExtensionConfig\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionCreateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: SavedExtensionCreateParams = SavedExtensionCreateParams.builder()\n .config(ExtensionConfig.RemoveBg.builder().build())\n .description("Analyzes vehicle images for type, condition, and quality assessment")\n .name("Car Quality Analysis")\n .build()\n val savedExtension: SavedExtension = client.savedExtensions().create(params)\n}', + }, + go: { + method: 'client.SavedExtensions.New', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n\t"github.com/imagekit-developer/imagekit-go/shared"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.New(context.TODO(), imagekit.SavedExtensionNewParams{\n\t\tConfig: shared.ExtensionConfigUnionParam{\n\t\t\tOfRemoveBg: &shared.ExtensionConfigRemoveBgParam{},\n\t\t},\n\t\tDescription: "Analyzes vehicle images for type, condition, and quality assessment",\n\t\tName: "Car Quality Analysis",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtension.ID)\n}\n', + }, + ruby: { + method: 'saved_extensions.create', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nsaved_extension = image_kit.saved_extensions.create(\n config: {name: :"remove-bg"},\n description: "Analyzes vehicle images for type, condition, and quality assessment",\n name: "Car Quality Analysis"\n)\n\nputs(saved_extension)', + }, + cli: { + method: 'savedExtensions create', + example: + "imagekit saved-extensions create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --config '{name: remove-bg}' \\\n --description 'Analyzes vehicle images for type, condition, and quality assessment' \\\n --name 'Car Quality Analysis'", + }, + php: { + method: 'savedExtensions->create', + example: + "savedExtensions->create(\n config: [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n description: 'Analyzes vehicle images for type, condition, and quality assessment',\n name: 'Car Quality Analysis',\n);\n\nvar_dump($savedExtension);", + }, + csharp: { + method: 'SavedExtensions.Create', + example: + 'SavedExtensionCreateParams parameters = new()\n{\n Config = new RemoveBg()\n {\n Options = new()\n {\n AddShadow = true,\n BgColor = "bg_color",\n BgImageUrl = "bg_image_url",\n Semitransparency = true,\n },\n },\n Description = "Analyzes vehicle images for type, condition, and quality assessment",\n Name = "Car Quality Analysis",\n};\n\nvar savedExtension = await client.SavedExtensions.Create(parameters);\n\nConsole.WriteLine(savedExtension);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/saved-extensions \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "config": {\n "name": "remove-bg"\n },\n "description": "Analyzes vehicle images for type, condition, and quality assessment",\n "name": "Car Quality Analysis"\n }\'', + }, + }, }, { - "name": "get", - "endpoint": "/v1/saved-extensions/{id}", - "httpMethod": "get", - "summary": "Get saved extension details", - "description": "This API returns details of a specific saved extension by ID.\n", - "stainlessPath": "(resource) savedExtensions > (method) get", - "qualified": "client.savedExtensions.get", - "params": [ - "id: string;" - ], - "response": "{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }", - "markdown": "## get\n\n`client.savedExtensions.get(id: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**get** `/v1/saved-extensions/{id}`\n\nThis API returns details of a specific saved extension by ID.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.get('id');\n\nconsole.log(savedExtension);\n```", - "perLanguage": { - "typescript": { - "method": "client.savedExtensions.get", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.get('id');\n\nconsole.log(savedExtension.id);" - }, - "python": { - "method": "saved_extensions.get", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.get(\n \"id\",\n)\nprint(saved_extension.id)" - }, - "java": { - "method": "savedExtensions().get", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().get(\"id\");\n }\n}" - }, - "kotlin": { - "method": "savedExtensions().get", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtension: SavedExtension = client.savedExtensions().get(\"id\")\n}" - }, - "go": { - "method": "client.SavedExtensions.Get", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.Get(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", savedExtension.ID)\n}\n" - }, - "ruby": { - "method": "saved_extensions.get", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nsaved_extension = image_kit.saved_extensions.get(\"id\")\n\nputs(saved_extension)" - }, - "cli": { - "method": "savedExtensions get", - "example": "imagekit saved-extensions get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" - }, - "php": { - "method": "savedExtensions->get", - "example": "savedExtensions->get('id');\n\nvar_dump($savedExtension);" - }, - "csharp": { - "method": "SavedExtensions.Get", - "example": "SavedExtensionGetParams parameters = new() { ID = \"id\" };\n\nvar savedExtension = await client.SavedExtensions.Get(parameters);\n\nConsole.WriteLine(savedExtension);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'get', + endpoint: '/v1/saved-extensions/{id}', + httpMethod: 'get', + summary: 'Get saved extension details', + description: 'This API returns details of a specific saved extension by ID.\n', + stainlessPath: '(resource) savedExtensions > (method) get', + qualified: 'client.savedExtensions.get', + params: ['id: string;'], + response: + "{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }", + markdown: + "## get\n\n`client.savedExtensions.get(id: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**get** `/v1/saved-extensions/{id}`\n\nThis API returns details of a specific saved extension by ID.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.get('id');\n\nconsole.log(savedExtension);\n```", + perLanguage: { + typescript: { + method: 'client.savedExtensions.get', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.get('id');\n\nconsole.log(savedExtension.id);", + }, + python: { + method: 'saved_extensions.get', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.get(\n "id",\n)\nprint(saved_extension.id)', + }, + java: { + method: 'savedExtensions().get', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionGetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().get("id");\n }\n}', + }, + kotlin: { + method: 'savedExtensions().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionGetParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtension: SavedExtension = client.savedExtensions().get("id")\n}', + }, + go: { + method: 'client.SavedExtensions.Get', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.Get(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtension.ID)\n}\n', + }, + ruby: { + method: 'saved_extensions.get', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nsaved_extension = image_kit.saved_extensions.get("id")\n\nputs(saved_extension)', + }, + cli: { + method: 'savedExtensions get', + example: + "imagekit saved-extensions get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'savedExtensions->get', + example: + "savedExtensions->get('id');\n\nvar_dump($savedExtension);", + }, + csharp: { + method: 'SavedExtensions.Get', + example: + 'SavedExtensionGetParams parameters = new() { ID = "id" };\n\nvar savedExtension = await client.SavedExtensions.Get(parameters);\n\nConsole.WriteLine(savedExtension);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "update", - "endpoint": "/v1/saved-extensions/{id}", - "httpMethod": "patch", - "summary": "Update saved extension", - "description": "This API updates an existing saved extension. You can update the name, description, or config.\n", - "stainlessPath": "(resource) savedExtensions > (method) update", - "qualified": "client.savedExtensions.update", - "params": [ - "id: string;", + name: 'update', + endpoint: '/v1/saved-extensions/{id}', + httpMethod: 'patch', + summary: 'Update saved extension', + description: + 'This API updates an existing saved extension. You can update the name, description, or config.\n', + stainlessPath: '(resource) savedExtensions > (method) update', + qualified: 'client.savedExtensions.update', + params: [ + 'id: string;', "config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; };", - "description?: string;", - "name?: string;" + 'description?: string;', + 'name?: string;', ], - "response": "{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }", - "markdown": "## update\n\n`client.savedExtensions.update(id: string, config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }, description?: string, name?: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**patch** `/v1/saved-extensions/{id}`\n\nThis API updates an existing saved extension. You can update the name, description, or config.\n\n\n### Parameters\n\n- `id: string`\n\n- `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n Configuration object for an extension (base extensions only, not saved extension references).\n\n- `description?: string`\n Updated description of the saved extension.\n\n- `name?: string`\n Updated name of the saved extension.\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.update('id');\n\nconsole.log(savedExtension);\n```", - "perLanguage": { - "typescript": { - "method": "client.savedExtensions.update", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.update('id');\n\nconsole.log(savedExtension.id);" - }, - "python": { - "method": "saved_extensions.update", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.update(\n id=\"id\",\n)\nprint(saved_extension.id)" - }, - "java": { - "method": "savedExtensions().update", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().update(\"id\");\n }\n}" - }, - "kotlin": { - "method": "savedExtensions().update", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtension: SavedExtension = client.savedExtensions().update(\"id\")\n}" - }, - "go": { - "method": "client.SavedExtensions.Update", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.Update(\n\t\tcontext.TODO(),\n\t\t\"id\",\n\t\timagekit.SavedExtensionUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", savedExtension.ID)\n}\n" - }, - "ruby": { - "method": "saved_extensions.update", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nsaved_extension = image_kit.saved_extensions.update(\"id\")\n\nputs(saved_extension)" - }, - "cli": { - "method": "savedExtensions update", - "example": "imagekit saved-extensions update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" - }, - "php": { - "method": "savedExtensions->update", - "example": "savedExtensions->update(\n 'id',\n config: [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n description: 'x',\n name: 'x',\n);\n\nvar_dump($savedExtension);" - }, - "csharp": { - "method": "SavedExtensions.Update", - "example": "SavedExtensionUpdateParams parameters = new() { ID = \"id\" };\n\nvar savedExtension = await client.SavedExtensions.Update(parameters);\n\nConsole.WriteLine(savedExtension);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -X PATCH \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{}'" - } - } + response: + "{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }", + markdown: + "## update\n\n`client.savedExtensions.update(id: string, config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }, description?: string, name?: string): { id?: string; config?: extension_config; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n\n**patch** `/v1/saved-extensions/{id}`\n\nThis API updates an existing saved extension. You can update the name, description, or config.\n\n\n### Parameters\n\n- `id: string`\n\n- `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n Configuration object for an extension (base extensions only, not saved extension references).\n\n- `description?: string`\n Updated description of the saved extension.\n\n- `name?: string`\n Updated name of the saved extension.\n\n### Returns\n\n- `{ id?: string; config?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; }; createdAt?: string; description?: string; name?: string; updatedAt?: string; }`\n Saved extension object containing extension configuration.\n\n - `id?: string`\n - `config?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; }`\n - `createdAt?: string`\n - `description?: string`\n - `name?: string`\n - `updatedAt?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst savedExtension = await client.savedExtensions.update('id');\n\nconsole.log(savedExtension);\n```", + perLanguage: { + typescript: { + method: 'client.savedExtensions.update', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst savedExtension = await client.savedExtensions.update('id');\n\nconsole.log(savedExtension.id);", + }, + python: { + method: 'saved_extensions.update', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nsaved_extension = client.saved_extensions.update(\n id="id",\n)\nprint(saved_extension.id)', + }, + java: { + method: 'savedExtensions().update', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.SavedExtension;\nimport io.imagekit.models.savedextensions.SavedExtensionUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n SavedExtension savedExtension = client.savedExtensions().update("id");\n }\n}', + }, + kotlin: { + method: 'savedExtensions().update', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.SavedExtension\nimport com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val savedExtension: SavedExtension = client.savedExtensions().update("id")\n}', + }, + go: { + method: 'client.SavedExtensions.Update', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tsavedExtension, err := client.SavedExtensions.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.SavedExtensionUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", savedExtension.ID)\n}\n', + }, + ruby: { + method: 'saved_extensions.update', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nsaved_extension = image_kit.saved_extensions.update("id")\n\nputs(saved_extension)', + }, + cli: { + method: 'savedExtensions update', + example: + "imagekit saved-extensions update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'savedExtensions->update', + example: + "savedExtensions->update(\n 'id',\n config: [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n description: 'x',\n name: 'x',\n);\n\nvar_dump($savedExtension);", + }, + csharp: { + method: 'SavedExtensions.Update', + example: + 'SavedExtensionUpdateParams parameters = new() { ID = "id" };\n\nvar savedExtension = await client.SavedExtensions.Update(parameters);\n\nConsole.WriteLine(savedExtension);', + }, + http: { + example: + "curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -X PATCH \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{}'", + }, + }, }, { - "name": "delete", - "endpoint": "/v1/saved-extensions/{id}", - "httpMethod": "delete", - "summary": "Delete saved extension", - "description": "This API deletes a saved extension permanently.\n", - "stainlessPath": "(resource) savedExtensions > (method) delete", - "qualified": "client.savedExtensions.delete", - "params": [ - "id: string;" - ], - "markdown": "## delete\n\n`client.savedExtensions.delete(id: string): void`\n\n**delete** `/v1/saved-extensions/{id}`\n\nThis API deletes a saved extension permanently.\n\n\n### Parameters\n\n- `id: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.savedExtensions.delete('id')\n```", - "perLanguage": { - "typescript": { - "method": "client.savedExtensions.delete", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.savedExtensions.delete('id');" - }, - "python": { - "method": "saved_extensions.delete", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nclient.saved_extensions.delete(\n \"id\",\n)" - }, - "java": { - "method": "savedExtensions().delete", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.savedextensions.SavedExtensionDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.savedExtensions().delete(\"id\");\n }\n}" - }, - "kotlin": { - "method": "savedExtensions().delete", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.savedExtensions().delete(\"id\")\n}" - }, - "go": { - "method": "client.SavedExtensions.Delete", - "example": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\terr := client.SavedExtensions.Delete(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n" - }, - "ruby": { - "method": "saved_extensions.delete", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresult = image_kit.saved_extensions.delete(\"id\")\n\nputs(result)" - }, - "cli": { - "method": "savedExtensions delete", - "example": "imagekit saved-extensions delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" - }, - "php": { - "method": "savedExtensions->delete", - "example": "savedExtensions->delete('id');\n\nvar_dump($result);" - }, - "csharp": { - "method": "SavedExtensions.Delete", - "example": "SavedExtensionDeleteParams parameters = new() { ID = \"id\" };\n\nawait client.SavedExtensions.Delete(parameters);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'delete', + endpoint: '/v1/saved-extensions/{id}', + httpMethod: 'delete', + summary: 'Delete saved extension', + description: 'This API deletes a saved extension permanently.\n', + stainlessPath: '(resource) savedExtensions > (method) delete', + qualified: 'client.savedExtensions.delete', + params: ['id: string;'], + markdown: + "## delete\n\n`client.savedExtensions.delete(id: string): void`\n\n**delete** `/v1/saved-extensions/{id}`\n\nThis API deletes a saved extension permanently.\n\n\n### Parameters\n\n- `id: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.savedExtensions.delete('id')\n```", + perLanguage: { + typescript: { + method: 'client.savedExtensions.delete', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.savedExtensions.delete('id');", + }, + python: { + method: 'saved_extensions.delete', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.saved_extensions.delete(\n "id",\n)', + }, + java: { + method: 'savedExtensions().delete', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.savedextensions.SavedExtensionDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.savedExtensions().delete("id");\n }\n}', + }, + kotlin: { + method: 'savedExtensions().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.savedExtensions().delete("id")\n}', + }, + go: { + method: 'client.SavedExtensions.Delete', + example: + 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.SavedExtensions.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', + }, + ruby: { + method: 'saved_extensions.delete', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.saved_extensions.delete("id")\n\nputs(result)', + }, + cli: { + method: 'savedExtensions delete', + example: + "imagekit saved-extensions delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'savedExtensions->delete', + example: + "savedExtensions->delete('id');\n\nvar_dump($result);", + }, + csharp: { + method: 'SavedExtensions.Delete', + example: + 'SavedExtensionDeleteParams parameters = new() { ID = "id" };\n\nawait client.SavedExtensions.Delete(parameters);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/saved-extensions/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "list", - "endpoint": "/v1/files", - "httpMethod": "get", - "summary": "List and search assets", - "description": "This API can list all the uploaded files and folders in your ImageKit.io media library. In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and provide this generated string as the value of the `searchQuery`.\n", - "stainlessPath": "(resource) assets > (method) list", - "qualified": "client.assets.list", - "params": [ + name: 'list', + endpoint: '/v1/files', + httpMethod: 'get', + summary: 'List and search assets', + description: + 'This API can list all the uploaded files and folders in your ImageKit.io media library. In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and provide this generated string as the value of the `searchQuery`.\n', + stainlessPath: '(resource) assets > (method) list', + qualified: 'client.assets.list', + params: [ "fileType?: 'all' | 'image' | 'non-image';", - "limit?: number;", - "path?: string;", - "searchQuery?: string;", - "skip?: number;", - "sort?: string;", - "type?: 'file' | 'file-version' | 'folder' | 'all';" + 'limit?: number;', + 'path?: string;', + 'searchQuery?: string;', + 'skip?: number;', + 'sort?: string;', + "type?: 'file' | 'file-version' | 'folder' | 'all';", ], - "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; } | { createdAt?: string; customMetadata?: object; folderId?: string; folderPath?: string; name?: string; type?: 'folder'; updatedAt?: string; }[]", - "markdown": "## list\n\n`client.assets.list(fileType?: 'all' | 'image' | 'non-image', limit?: number, path?: string, searchQuery?: string, skip?: number, sort?: string, type?: 'file' | 'file-version' | 'folder' | 'all'): object | object[]`\n\n**get** `/v1/files`\n\nThis API can list all the uploaded files and folders in your ImageKit.io media library. In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and provide this generated string as the value of the `searchQuery`.\n\n\n### Parameters\n\n- `fileType?: 'all' | 'image' | 'non-image'`\n Filter results by file type.\n\n- `all` — include all file types \n- `image` — include only image files \n- `non-image` — include only non-image files (e.g., JS, CSS, video)\n\n- `limit?: number`\n The maximum number of results to return in response.\n\n\n- `path?: string`\n Folder path if you want to limit the search within a specific folder. For example, `/sales-banner/` will only search in folder sales-banner.\n\nNote : If your use case involves searching within a folder as well as its subfolders, you can use `path` parameter in `searchQuery` with appropriate operator.\nCheckout [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) for more information.\n\n\n- `searchQuery?: string`\n Query string in a Lucene-like query language e.g. `createdAt > \"7d\"`.\n\nNote : When the searchQuery parameter is present, the following query parameters will have no effect on the result:\n\n1. `tags`\n2. `type`\n3. `name`\n\n[Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) from examples.\n\n\n- `skip?: number`\n The number of results to skip before returning results.\n\n\n- `sort?: string`\n Sort the results by one of the supported fields in ascending or descending order.\n\n- `type?: 'file' | 'file-version' | 'folder' | 'all'`\n Filter results by asset type.\n\n- `file` — returns only files \n- `file-version` — returns specific file versions \n- `folder` — returns only folders \n- `all` — returns both files and folders (excludes `file-version`)\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; } | { createdAt?: string; customMetadata?: object; folderId?: string; folderPath?: string; name?: string; type?: 'folder'; updatedAt?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst assets = await client.assets.list();\n\nconsole.log(assets);\n```", - "perLanguage": { - "typescript": { - "method": "client.assets.list", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst assets = await client.assets.list();\n\nconsole.log(assets);" - }, - "python": { - "method": "assets.list", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nassets = client.assets.list()\nprint(assets)" - }, - "java": { - "method": "assets().list", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.assets.AssetListParams;\nimport io.imagekit.models.assets.AssetListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List assets = client.assets().list();\n }\n}" - }, - "kotlin": { - "method": "assets().list", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.assets.AssetListParams\nimport com.imagekit.api.models.assets.AssetListResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val assets: List = client.assets().list()\n}" - }, - "go": { - "method": "client.Assets.List", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tassets, err := client.Assets.List(context.TODO(), imagekit.AssetListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", assets)\n}\n" - }, - "ruby": { - "method": "assets.list", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nassets = image_kit.assets.list\n\nputs(assets)" - }, - "cli": { - "method": "assets list", - "example": "imagekit assets list \\\n --private-key 'My Private Key' \\\n --password 'My Password'" - }, - "php": { - "method": "assets->list", - "example": "assets->list(\n fileType: 'all',\n limit: 1,\n path: 'path',\n searchQuery: 'searchQuery',\n skip: 0,\n sort: 'ASC_NAME',\n type: 'file',\n);\n\nvar_dump($assets);" - }, - "csharp": { - "method": "Assets.List", - "example": "AssetListParams parameters = new();\n\nvar assets = await client.Assets.List(parameters);\n\nConsole.WriteLine(assets);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + response: + "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; } | { createdAt?: string; customMetadata?: object; folderId?: string; folderPath?: string; name?: string; type?: 'folder'; updatedAt?: string; }[]", + markdown: + "## list\n\n`client.assets.list(fileType?: 'all' | 'image' | 'non-image', limit?: number, path?: string, searchQuery?: string, skip?: number, sort?: string, type?: 'file' | 'file-version' | 'folder' | 'all'): object | object[]`\n\n**get** `/v1/files`\n\nThis API can list all the uploaded files and folders in your ImageKit.io media library. In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and provide this generated string as the value of the `searchQuery`.\n\n\n### Parameters\n\n- `fileType?: 'all' | 'image' | 'non-image'`\n Filter results by file type.\n\n- `all` — include all file types \n- `image` — include only image files \n- `non-image` — include only non-image files (e.g., JS, CSS, video)\n\n- `limit?: number`\n The maximum number of results to return in response.\n\n\n- `path?: string`\n Folder path if you want to limit the search within a specific folder. For example, `/sales-banner/` will only search in folder sales-banner.\n\nNote : If your use case involves searching within a folder as well as its subfolders, you can use `path` parameter in `searchQuery` with appropriate operator.\nCheckout [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) for more information.\n\n\n- `searchQuery?: string`\n Query string in a Lucene-like query language e.g. `createdAt > \"7d\"`.\n\nNote : When the searchQuery parameter is present, the following query parameters will have no effect on the result:\n\n1. `tags`\n2. `type`\n3. `name`\n\n[Learn more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) from examples.\n\n\n- `skip?: number`\n The number of results to skip before returning results.\n\n\n- `sort?: string`\n Sort the results by one of the supported fields in ascending or descending order.\n\n- `type?: 'file' | 'file-version' | 'folder' | 'all'`\n Filter results by asset type.\n\n- `file` — returns only files \n- `file-version` — returns specific file versions \n- `folder` — returns only folders \n- `all` — returns both files and folders (excludes `file-version`)\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; createdAt?: string; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; fileId?: string; filePath?: string; fileType?: string; hasAlpha?: boolean; height?: number; isPrivateFile?: boolean; isPublished?: boolean; mime?: string; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnail?: string; type?: 'file' | 'file-version'; updatedAt?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; } | { createdAt?: string; customMetadata?: object; folderId?: string; folderPath?: string; name?: string; type?: 'folder'; updatedAt?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst assets = await client.assets.list();\n\nconsole.log(assets);\n```", + perLanguage: { + typescript: { + method: 'client.assets.list', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst assets = await client.assets.list();\n\nconsole.log(assets);", + }, + python: { + method: 'assets.list', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nassets = client.assets.list()\nprint(assets)', + }, + java: { + method: 'assets().list', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.assets.AssetListParams;\nimport io.imagekit.models.assets.AssetListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List assets = client.assets().list();\n }\n}', + }, + kotlin: { + method: 'assets().list', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.assets.AssetListParams\nimport com.imagekit.api.models.assets.AssetListResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val assets: List = client.assets().list()\n}', + }, + go: { + method: 'client.Assets.List', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tassets, err := client.Assets.List(context.TODO(), imagekit.AssetListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", assets)\n}\n', + }, + ruby: { + method: 'assets.list', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nassets = image_kit.assets.list\n\nputs(assets)', + }, + cli: { + method: 'assets list', + example: "imagekit assets list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'assets->list', + example: + "assets->list(\n fileType: 'all',\n limit: 1,\n path: 'path',\n searchQuery: 'searchQuery',\n skip: 0,\n sort: 'ASC_NAME',\n type: 'file',\n);\n\nvar_dump($assets);", + }, + csharp: { + method: 'Assets.List', + example: + 'AssetListParams parameters = new();\n\nvar assets = await client.Assets.List(parameters);\n\nConsole.WriteLine(assets);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "create", - "endpoint": "/v1/files/purge", - "httpMethod": "post", - "summary": "Purge cache", - "description": "This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: Purge cache is an asynchronous process and it may take some time to reflect the changes.\n", - "stainlessPath": "(resource) cache.invalidation > (method) create", - "qualified": "client.cache.invalidation.create", - "params": [ - "url: string;" - ], - "response": "{ requestId?: string; }", - "markdown": "## create\n\n`client.cache.invalidation.create(url: string): { requestId?: string; }`\n\n**post** `/v1/files/purge`\n\nThis API will purge CDN cache and ImageKit.io's internal cache for a file. Note: Purge cache is an asynchronous process and it may take some time to reflect the changes.\n\n\n### Parameters\n\n- `url: string`\n The full URL of the file to be purged.\n\n\n### Returns\n\n- `{ requestId?: string; }`\n\n - `requestId?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst invalidation = await client.cache.invalidation.create({ url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg' });\n\nconsole.log(invalidation);\n```", - "perLanguage": { - "typescript": { - "method": "client.cache.invalidation.create", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst invalidation = await client.cache.invalidation.create({\n url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg',\n});\n\nconsole.log(invalidation.requestId);" - }, - "python": { - "method": "cache.invalidation.create", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\ninvalidation = client.cache.invalidation.create(\n url=\"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\",\n)\nprint(invalidation.request_id)" - }, - "java": { - "method": "cache().invalidation().create", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.cache.invalidation.InvalidationCreateParams;\nimport io.imagekit.models.cache.invalidation.InvalidationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationCreateParams params = InvalidationCreateParams.builder()\n .url(\"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\")\n .build();\n InvalidationCreateResponse invalidation = client.cache().invalidation().create(params);\n }\n}" - }, - "kotlin": { - "method": "cache().invalidation().create", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateParams\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: InvalidationCreateParams = InvalidationCreateParams.builder()\n .url(\"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\")\n .build()\n val invalidation: InvalidationCreateResponse = client.cache().invalidation().create(params)\n}" - }, - "go": { - "method": "client.Cache.Invalidation.New", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tinvalidation, err := client.Cache.Invalidation.New(context.TODO(), imagekit.CacheInvalidationNewParams{\n\t\tURL: \"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", invalidation.RequestID)\n}\n" - }, - "ruby": { - "method": "cache.invalidation.create", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\ninvalidation = image_kit.cache.invalidation.create(url: \"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\")\n\nputs(invalidation)" - }, - "cli": { - "method": "invalidation create", - "example": "imagekit cache:invalidation create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --url https://ik.imagekit.io/your_imagekit_id/default-image.jpg" - }, - "php": { - "method": "cache->invalidation->create", - "example": "cache->invalidation->create(\n url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg'\n);\n\nvar_dump($invalidation);" - }, - "csharp": { - "method": "Cache.Invalidation.Create", - "example": "InvalidationCreateParams parameters = new()\n{\n Url = \"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\"\n};\n\nvar invalidation = await client.Cache.Invalidation.Create(parameters);\n\nConsole.WriteLine(invalidation);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/purge \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"url\": \"https://ik.imagekit.io/your_imagekit_id/default-image.jpg\"\n }'" - } - } + name: 'create', + endpoint: '/v1/files/purge', + httpMethod: 'post', + summary: 'Purge cache', + description: + "This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: Purge cache is an asynchronous process and it may take some time to reflect the changes.\n", + stainlessPath: '(resource) cache.invalidation > (method) create', + qualified: 'client.cache.invalidation.create', + params: ['url: string;'], + response: '{ requestId?: string; }', + markdown: + "## create\n\n`client.cache.invalidation.create(url: string): { requestId?: string; }`\n\n**post** `/v1/files/purge`\n\nThis API will purge CDN cache and ImageKit.io's internal cache for a file. Note: Purge cache is an asynchronous process and it may take some time to reflect the changes.\n\n\n### Parameters\n\n- `url: string`\n The full URL of the file to be purged.\n\n\n### Returns\n\n- `{ requestId?: string; }`\n\n - `requestId?: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst invalidation = await client.cache.invalidation.create({ url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg' });\n\nconsole.log(invalidation);\n```", + perLanguage: { + typescript: { + method: 'client.cache.invalidation.create', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst invalidation = await client.cache.invalidation.create({\n url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg',\n});\n\nconsole.log(invalidation.requestId);", + }, + python: { + method: 'cache.invalidation.create', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ninvalidation = client.cache.invalidation.create(\n url="https://ik.imagekit.io/your_imagekit_id/default-image.jpg",\n)\nprint(invalidation.request_id)', + }, + java: { + method: 'cache().invalidation().create', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.cache.invalidation.InvalidationCreateParams;\nimport io.imagekit.models.cache.invalidation.InvalidationCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationCreateParams params = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build();\n InvalidationCreateResponse invalidation = client.cache().invalidation().create(params);\n }\n}', + }, + kotlin: { + method: 'cache().invalidation().create', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateParams\nimport com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: InvalidationCreateParams = InvalidationCreateParams.builder()\n .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n .build()\n val invalidation: InvalidationCreateResponse = client.cache().invalidation().create(params)\n}', + }, + go: { + method: 'client.Cache.Invalidation.New', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tinvalidation, err := client.Cache.Invalidation.New(context.TODO(), imagekit.CacheInvalidationNewParams{\n\t\tURL: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", invalidation.RequestID)\n}\n', + }, + ruby: { + method: 'cache.invalidation.create', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ninvalidation = image_kit.cache.invalidation.create(url: "https://ik.imagekit.io/your_imagekit_id/default-image.jpg")\n\nputs(invalidation)', + }, + cli: { + method: 'invalidation create', + example: + "imagekit cache:invalidation create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --url https://ik.imagekit.io/your_imagekit_id/default-image.jpg", + }, + php: { + method: 'cache->invalidation->create', + example: + "cache->invalidation->create(\n url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg'\n);\n\nvar_dump($invalidation);", + }, + csharp: { + method: 'Cache.Invalidation.Create', + example: + 'InvalidationCreateParams parameters = new()\n{\n Url = "https://ik.imagekit.io/your_imagekit_id/default-image.jpg"\n};\n\nvar invalidation = await client.Cache.Invalidation.Create(parameters);\n\nConsole.WriteLine(invalidation);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/purge \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "url": "https://ik.imagekit.io/your_imagekit_id/default-image.jpg"\n }\'', + }, + }, }, { - "name": "get", - "endpoint": "/v1/files/purge/{requestId}", - "httpMethod": "get", - "summary": "Get purge status", - "description": "This API returns the status of a purge cache request.\n", - "stainlessPath": "(resource) cache.invalidation > (method) get", - "qualified": "client.cache.invalidation.get", - "params": [ - "requestId: string;" - ], - "response": "{ status?: 'Pending' | 'Completed'; }", - "markdown": "## get\n\n`client.cache.invalidation.get(requestId: string): { status?: 'Pending' | 'Completed'; }`\n\n**get** `/v1/files/purge/{requestId}`\n\nThis API returns the status of a purge cache request.\n\n\n### Parameters\n\n- `requestId: string`\n\n### Returns\n\n- `{ status?: 'Pending' | 'Completed'; }`\n\n - `status?: 'Pending' | 'Completed'`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst invalidation = await client.cache.invalidation.get('requestId');\n\nconsole.log(invalidation);\n```", - "perLanguage": { - "typescript": { - "method": "client.cache.invalidation.get", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst invalidation = await client.cache.invalidation.get('requestId');\n\nconsole.log(invalidation.status);" - }, - "python": { - "method": "cache.invalidation.get", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\ninvalidation = client.cache.invalidation.get(\n \"requestId\",\n)\nprint(invalidation.status)" - }, - "java": { - "method": "cache().invalidation().get", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.cache.invalidation.InvalidationGetParams;\nimport io.imagekit.models.cache.invalidation.InvalidationGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationGetResponse invalidation = client.cache().invalidation().get(\"requestId\");\n }\n}" - }, - "kotlin": { - "method": "cache().invalidation().get", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetParams\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val invalidation: InvalidationGetResponse = client.cache().invalidation().get(\"requestId\")\n}" - }, - "go": { - "method": "client.Cache.Invalidation.Get", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tinvalidation, err := client.Cache.Invalidation.Get(context.TODO(), \"requestId\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", invalidation.Status)\n}\n" - }, - "ruby": { - "method": "cache.invalidation.get", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\ninvalidation = image_kit.cache.invalidation.get(\"requestId\")\n\nputs(invalidation)" - }, - "cli": { - "method": "invalidation get", - "example": "imagekit cache:invalidation get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --request-id requestId" - }, - "php": { - "method": "cache->invalidation->get", - "example": "cache->invalidation->get('requestId');\n\nvar_dump($invalidation);" - }, - "csharp": { - "method": "Cache.Invalidation.Get", - "example": "InvalidationGetParams parameters = new() { RequestID = \"requestId\" };\n\nvar invalidation = await client.Cache.Invalidation.Get(parameters);\n\nConsole.WriteLine(invalidation);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/files/purge/$REQUEST_ID \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'get', + endpoint: '/v1/files/purge/{requestId}', + httpMethod: 'get', + summary: 'Get purge status', + description: 'This API returns the status of a purge cache request.\n', + stainlessPath: '(resource) cache.invalidation > (method) get', + qualified: 'client.cache.invalidation.get', + params: ['requestId: string;'], + response: "{ status?: 'Pending' | 'Completed'; }", + markdown: + "## get\n\n`client.cache.invalidation.get(requestId: string): { status?: 'Pending' | 'Completed'; }`\n\n**get** `/v1/files/purge/{requestId}`\n\nThis API returns the status of a purge cache request.\n\n\n### Parameters\n\n- `requestId: string`\n\n### Returns\n\n- `{ status?: 'Pending' | 'Completed'; }`\n\n - `status?: 'Pending' | 'Completed'`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst invalidation = await client.cache.invalidation.get('requestId');\n\nconsole.log(invalidation);\n```", + perLanguage: { + typescript: { + method: 'client.cache.invalidation.get', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst invalidation = await client.cache.invalidation.get('requestId');\n\nconsole.log(invalidation.status);", + }, + python: { + method: 'cache.invalidation.get', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\ninvalidation = client.cache.invalidation.get(\n "requestId",\n)\nprint(invalidation.status)', + }, + java: { + method: 'cache().invalidation().get', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.cache.invalidation.InvalidationGetParams;\nimport io.imagekit.models.cache.invalidation.InvalidationGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n InvalidationGetResponse invalidation = client.cache().invalidation().get("requestId");\n }\n}', + }, + kotlin: { + method: 'cache().invalidation().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetParams\nimport com.imagekit.api.models.cache.invalidation.InvalidationGetResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val invalidation: InvalidationGetResponse = client.cache().invalidation().get("requestId")\n}', + }, + go: { + method: 'client.Cache.Invalidation.Get', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tinvalidation, err := client.Cache.Invalidation.Get(context.TODO(), "requestId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", invalidation.Status)\n}\n', + }, + ruby: { + method: 'cache.invalidation.get', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\ninvalidation = image_kit.cache.invalidation.get("requestId")\n\nputs(invalidation)', + }, + cli: { + method: 'invalidation get', + example: + "imagekit cache:invalidation get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --request-id requestId", + }, + php: { + method: 'cache->invalidation->get', + example: + "cache->invalidation->get('requestId');\n\nvar_dump($invalidation);", + }, + csharp: { + method: 'Cache.Invalidation.Get', + example: + 'InvalidationGetParams parameters = new() { RequestID = "requestId" };\n\nvar invalidation = await client.Cache.Invalidation.Get(parameters);\n\nConsole.WriteLine(invalidation);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/files/purge/$REQUEST_ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "create", - "endpoint": "/v1/folder", - "httpMethod": "post", - "summary": "Create folder", - "description": "This will create a new folder. You can specify the folder name and location of the parent folder where this new folder should be created.\n", - "stainlessPath": "(resource) folders > (method) create", - "qualified": "client.folders.create", - "params": [ - "folderName: string;", - "parentFolderPath: string;" - ], - "response": "{ }", - "markdown": "## create\n\n`client.folders.create(folderName: string, parentFolderPath: string): { }`\n\n**post** `/v1/folder`\n\nThis will create a new folder. You can specify the folder name and location of the parent folder where this new folder should be created.\n\n\n### Parameters\n\n- `folderName: string`\n The folder will be created with this name. \n\nAll characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) will be replaced by an underscore i.e. `_`.\n\n\n- `parentFolderPath: string`\n The folder where the new folder should be created, for root use `/` else the path e.g. `containing/folder/`.\n\nNote: If any folder(s) is not present in the parentFolderPath parameter, it will be automatically created. For example, if you pass `/product/images/summer`, then `product`, `images`, and `summer` folders will be created if they don't already exist.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst folder = await client.folders.create({ folderName: 'summer', parentFolderPath: '/product/images/' });\n\nconsole.log(folder);\n```", - "perLanguage": { - "typescript": { - "method": "client.folders.create", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst folder = await client.folders.create({\n folderName: 'summer',\n parentFolderPath: '/product/images/',\n});\n\nconsole.log(folder);" - }, - "python": { - "method": "folders.create", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfolder = client.folders.create(\n folder_name=\"summer\",\n parent_folder_path=\"/product/images/\",\n)\nprint(folder)" - }, - "java": { - "method": "folders().create", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderCreateParams;\nimport io.imagekit.models.folders.FolderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCreateParams params = FolderCreateParams.builder()\n .folderName(\"summer\")\n .parentFolderPath(\"/product/images/\")\n .build();\n FolderCreateResponse folder = client.folders().create(params);\n }\n}" - }, - "kotlin": { - "method": "folders().create", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderCreateParams\nimport com.imagekit.api.models.folders.FolderCreateResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderCreateParams = FolderCreateParams.builder()\n .folderName(\"summer\")\n .parentFolderPath(\"/product/images/\")\n .build()\n val folder: FolderCreateResponse = client.folders().create(params)\n}" - }, - "go": { - "method": "client.Folders.New", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfolder, err := client.Folders.New(context.TODO(), imagekit.FolderNewParams{\n\t\tFolderName: \"summer\",\n\t\tParentFolderPath: \"/product/images/\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", folder)\n}\n" - }, - "ruby": { - "method": "folders.create", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfolder = image_kit.folders.create(folder_name: \"summer\", parent_folder_path: \"/product/images/\")\n\nputs(folder)" - }, - "cli": { - "method": "folders create", - "example": "imagekit folders create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-name summer \\\n --parent-folder-path /product/images/" - }, - "php": { - "method": "folders->create", - "example": "folders->create(\n folderName: 'summer', parentFolderPath: '/product/images/'\n);\n\nvar_dump($folder);" - }, - "csharp": { - "method": "Folders.Create", - "example": "FolderCreateParams parameters = new()\n{\n FolderName = \"summer\",\n ParentFolderPath = \"/product/images/\",\n};\n\nvar folder = await client.Folders.Create(parameters);\n\nConsole.WriteLine(folder);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/folder \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"folderName\": \"summer\",\n \"parentFolderPath\": \"/product/images/\"\n }'" - } - } + name: 'create', + endpoint: '/v1/folder', + httpMethod: 'post', + summary: 'Create folder', + description: + 'This will create a new folder. You can specify the folder name and location of the parent folder where this new folder should be created.\n', + stainlessPath: '(resource) folders > (method) create', + qualified: 'client.folders.create', + params: ['folderName: string;', 'parentFolderPath: string;'], + response: '{ }', + markdown: + "## create\n\n`client.folders.create(folderName: string, parentFolderPath: string): { }`\n\n**post** `/v1/folder`\n\nThis will create a new folder. You can specify the folder name and location of the parent folder where this new folder should be created.\n\n\n### Parameters\n\n- `folderName: string`\n The folder will be created with this name. \n\nAll characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) will be replaced by an underscore i.e. `_`.\n\n\n- `parentFolderPath: string`\n The folder where the new folder should be created, for root use `/` else the path e.g. `containing/folder/`.\n\nNote: If any folder(s) is not present in the parentFolderPath parameter, it will be automatically created. For example, if you pass `/product/images/summer`, then `product`, `images`, and `summer` folders will be created if they don't already exist.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst folder = await client.folders.create({ folderName: 'summer', parentFolderPath: '/product/images/' });\n\nconsole.log(folder);\n```", + perLanguage: { + typescript: { + method: 'client.folders.create', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst folder = await client.folders.create({\n folderName: 'summer',\n parentFolderPath: '/product/images/',\n});\n\nconsole.log(folder);", + }, + python: { + method: 'folders.create', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfolder = client.folders.create(\n folder_name="summer",\n parent_folder_path="/product/images/",\n)\nprint(folder)', + }, + java: { + method: 'folders().create', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderCreateParams;\nimport io.imagekit.models.folders.FolderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCreateParams params = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build();\n FolderCreateResponse folder = client.folders().create(params);\n }\n}', + }, + kotlin: { + method: 'folders().create', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderCreateParams\nimport com.imagekit.api.models.folders.FolderCreateResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderCreateParams = FolderCreateParams.builder()\n .folderName("summer")\n .parentFolderPath("/product/images/")\n .build()\n val folder: FolderCreateResponse = client.folders().create(params)\n}', + }, + go: { + method: 'client.Folders.New', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfolder, err := client.Folders.New(context.TODO(), imagekit.FolderNewParams{\n\t\tFolderName: "summer",\n\t\tParentFolderPath: "/product/images/",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", folder)\n}\n', + }, + ruby: { + method: 'folders.create', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfolder = image_kit.folders.create(folder_name: "summer", parent_folder_path: "/product/images/")\n\nputs(folder)', + }, + cli: { + method: 'folders create', + example: + "imagekit folders create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-name summer \\\n --parent-folder-path /product/images/", + }, + php: { + method: 'folders->create', + example: + "folders->create(\n folderName: 'summer', parentFolderPath: '/product/images/'\n);\n\nvar_dump($folder);", + }, + csharp: { + method: 'Folders.Create', + example: + 'FolderCreateParams parameters = new()\n{\n FolderName = "summer",\n ParentFolderPath = "/product/images/",\n};\n\nvar folder = await client.Folders.Create(parameters);\n\nConsole.WriteLine(folder);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/folder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "folderName": "summer",\n "parentFolderPath": "/product/images/"\n }\'', + }, + }, }, { - "name": "delete", - "endpoint": "/v1/folder", - "httpMethod": "delete", - "summary": "Delete folder", - "description": "This will delete a folder and all its contents permanently. The API returns an empty response.\n", - "stainlessPath": "(resource) folders > (method) delete", - "qualified": "client.folders.delete", - "params": [ - "folderPath: string;" - ], - "response": "{ }", - "markdown": "## delete\n\n`client.folders.delete(folderPath: string): { }`\n\n**delete** `/v1/folder`\n\nThis will delete a folder and all its contents permanently. The API returns an empty response.\n\n\n### Parameters\n\n- `folderPath: string`\n Full path to the folder you want to delete. For example `/folder/to/delete/`.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst folder = await client.folders.delete({ folderPath: '/folder/to/delete/' });\n\nconsole.log(folder);\n```", - "perLanguage": { - "typescript": { - "method": "client.folders.delete", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst folder = await client.folders.delete({ folderPath: '/folder/to/delete/' });\n\nconsole.log(folder);" - }, - "python": { - "method": "folders.delete", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nfolder = client.folders.delete(\n folder_path=\"/folder/to/delete/\",\n)\nprint(folder)" - }, - "java": { - "method": "folders().delete", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderDeleteParams;\nimport io.imagekit.models.folders.FolderDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderDeleteParams params = FolderDeleteParams.builder()\n .folderPath(\"/folder/to/delete/\")\n .build();\n FolderDeleteResponse folder = client.folders().delete(params);\n }\n}" - }, - "kotlin": { - "method": "folders().delete", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderDeleteParams\nimport com.imagekit.api.models.folders.FolderDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderDeleteParams = FolderDeleteParams.builder()\n .folderPath(\"/folder/to/delete/\")\n .build()\n val folder: FolderDeleteResponse = client.folders().delete(params)\n}" - }, - "go": { - "method": "client.Folders.Delete", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tfolder, err := client.Folders.Delete(context.TODO(), imagekit.FolderDeleteParams{\n\t\tFolderPath: \"/folder/to/delete/\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", folder)\n}\n" - }, - "ruby": { - "method": "folders.delete", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nfolder = image_kit.folders.delete(folder_path: \"/folder/to/delete/\")\n\nputs(folder)" - }, - "cli": { - "method": "folders delete", - "example": "imagekit folders delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-path /folder/to/delete/" - }, - "php": { - "method": "folders->delete", - "example": "folders->delete(folderPath: '/folder/to/delete/');\n\nvar_dump($folder);" - }, - "csharp": { - "method": "Folders.Delete", - "example": "FolderDeleteParams parameters = new() { FolderPath = \"/folder/to/delete/\" };\n\nvar folder = await client.Folders.Delete(parameters);\n\nConsole.WriteLine(folder);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/folder \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'delete', + endpoint: '/v1/folder', + httpMethod: 'delete', + summary: 'Delete folder', + description: + 'This will delete a folder and all its contents permanently. The API returns an empty response.\n', + stainlessPath: '(resource) folders > (method) delete', + qualified: 'client.folders.delete', + params: ['folderPath: string;'], + response: '{ }', + markdown: + "## delete\n\n`client.folders.delete(folderPath: string): { }`\n\n**delete** `/v1/folder`\n\nThis will delete a folder and all its contents permanently. The API returns an empty response.\n\n\n### Parameters\n\n- `folderPath: string`\n Full path to the folder you want to delete. For example `/folder/to/delete/`.\n\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst folder = await client.folders.delete({ folderPath: '/folder/to/delete/' });\n\nconsole.log(folder);\n```", + perLanguage: { + typescript: { + method: 'client.folders.delete', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst folder = await client.folders.delete({ folderPath: '/folder/to/delete/' });\n\nconsole.log(folder);", + }, + python: { + method: 'folders.delete', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nfolder = client.folders.delete(\n folder_path="/folder/to/delete/",\n)\nprint(folder)', + }, + java: { + method: 'folders().delete', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderDeleteParams;\nimport io.imagekit.models.folders.FolderDeleteResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderDeleteParams params = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build();\n FolderDeleteResponse folder = client.folders().delete(params);\n }\n}', + }, + kotlin: { + method: 'folders().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderDeleteParams\nimport com.imagekit.api.models.folders.FolderDeleteResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderDeleteParams = FolderDeleteParams.builder()\n .folderPath("/folder/to/delete/")\n .build()\n val folder: FolderDeleteResponse = client.folders().delete(params)\n}', + }, + go: { + method: 'client.Folders.Delete', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tfolder, err := client.Folders.Delete(context.TODO(), imagekit.FolderDeleteParams{\n\t\tFolderPath: "/folder/to/delete/",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", folder)\n}\n', + }, + ruby: { + method: 'folders.delete', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nfolder = image_kit.folders.delete(folder_path: "/folder/to/delete/")\n\nputs(folder)', + }, + cli: { + method: 'folders delete', + example: + "imagekit folders delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-path /folder/to/delete/", + }, + php: { + method: 'folders->delete', + example: + "folders->delete(folderPath: '/folder/to/delete/');\n\nvar_dump($folder);", + }, + csharp: { + method: 'Folders.Delete', + example: + 'FolderDeleteParams parameters = new() { FolderPath = "/folder/to/delete/" };\n\nvar folder = await client.Folders.Delete(parameters);\n\nConsole.WriteLine(folder);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/folder \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "copy", - "endpoint": "/v1/bulkJobs/copyFolder", - "httpMethod": "post", - "summary": "Copy folder", - "description": "This will copy one folder into another. The selected folder, its nested folders, files, and their versions (in `includeVersions` is set to true) are copied in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n", - "stainlessPath": "(resource) folders > (method) copy", - "qualified": "client.folders.copy", - "params": [ - "destinationPath: string;", - "sourceFolderPath: string;", - "includeVersions?: boolean;" - ], - "response": "{ jobId: string; }", - "markdown": "## copy\n\n`client.folders.copy(destinationPath: string, sourceFolderPath: string, includeVersions?: boolean): { jobId: string; }`\n\n**post** `/v1/bulkJobs/copyFolder`\n\nThis will copy one folder into another. The selected folder, its nested folders, files, and their versions (in `includeVersions` is set to true) are copied in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the destination folder where you want to copy the source folder into.\n\n\n- `sourceFolderPath: string`\n The full path to the source folder you want to copy.\n\n\n- `includeVersions?: boolean`\n Option to copy all versions of files that are nested inside the selected folder. By default, only the current version of each file will be copied. When set to true, all versions of each file will be copied. Default value - `false`.\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.copy({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' });\n\nconsole.log(response);\n```", - "perLanguage": { - "typescript": { - "method": "client.folders.copy", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.copy({\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n});\n\nconsole.log(response.jobId);" - }, - "python": { - "method": "folders.copy", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.folders.copy(\n destination_path=\"/path/of/destination/folder\",\n source_folder_path=\"/path/of/source/folder\",\n)\nprint(response.job_id)" - }, - "java": { - "method": "folders().copy", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderCopyParams;\nimport io.imagekit.models.folders.FolderCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCopyParams params = FolderCopyParams.builder()\n .destinationPath(\"/path/of/destination/folder\")\n .sourceFolderPath(\"/path/of/source/folder\")\n .build();\n FolderCopyResponse response = client.folders().copy(params);\n }\n}" - }, - "kotlin": { - "method": "folders().copy", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderCopyParams\nimport com.imagekit.api.models.folders.FolderCopyResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderCopyParams = FolderCopyParams.builder()\n .destinationPath(\"/path/of/destination/folder\")\n .sourceFolderPath(\"/path/of/source/folder\")\n .build()\n val response: FolderCopyResponse = client.folders().copy(params)\n}" - }, - "go": { - "method": "client.Folders.Copy", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Folders.Copy(context.TODO(), imagekit.FolderCopyParams{\n\t\tDestinationPath: \"/path/of/destination/folder\",\n\t\tSourceFolderPath: \"/path/of/source/folder\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.JobID)\n}\n" - }, - "ruby": { - "method": "folders.copy", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.folders.copy(\n destination_path: \"/path/of/destination/folder\",\n source_folder_path: \"/path/of/source/folder\"\n)\n\nputs(response)" - }, - "cli": { - "method": "folders copy", - "example": "imagekit folders copy \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /path/of/destination/folder \\\n --source-folder-path /path/of/source/folder" - }, - "php": { - "method": "folders->copy", - "example": "folders->copy(\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n includeVersions: true,\n);\n\nvar_dump($response);" - }, - "csharp": { - "method": "Folders.Copy", - "example": "FolderCopyParams parameters = new()\n{\n DestinationPath = \"/path/of/destination/folder\",\n SourceFolderPath = \"/path/of/source/folder\",\n};\n\nvar response = await client.Folders.Copy(parameters);\n\nConsole.WriteLine(response);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/bulkJobs/copyFolder \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"destinationPath\": \"/path/of/destination/folder\",\n \"sourceFolderPath\": \"/path/of/source/folder\",\n \"includeVersions\": true\n }'" - } - } + name: 'copy', + endpoint: '/v1/bulkJobs/copyFolder', + httpMethod: 'post', + summary: 'Copy folder', + description: + 'This will copy one folder into another. The selected folder, its nested folders, files, and their versions (in `includeVersions` is set to true) are copied in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n', + stainlessPath: '(resource) folders > (method) copy', + qualified: 'client.folders.copy', + params: ['destinationPath: string;', 'sourceFolderPath: string;', 'includeVersions?: boolean;'], + response: '{ jobId: string; }', + markdown: + "## copy\n\n`client.folders.copy(destinationPath: string, sourceFolderPath: string, includeVersions?: boolean): { jobId: string; }`\n\n**post** `/v1/bulkJobs/copyFolder`\n\nThis will copy one folder into another. The selected folder, its nested folders, files, and their versions (in `includeVersions` is set to true) are copied in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the destination folder where you want to copy the source folder into.\n\n\n- `sourceFolderPath: string`\n The full path to the source folder you want to copy.\n\n\n- `includeVersions?: boolean`\n Option to copy all versions of files that are nested inside the selected folder. By default, only the current version of each file will be copied. When set to true, all versions of each file will be copied. Default value - `false`.\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.copy({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' });\n\nconsole.log(response);\n```", + perLanguage: { + typescript: { + method: 'client.folders.copy', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.copy({\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n});\n\nconsole.log(response.jobId);", + }, + python: { + method: 'folders.copy', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.folders.copy(\n destination_path="/path/of/destination/folder",\n source_folder_path="/path/of/source/folder",\n)\nprint(response.job_id)', + }, + java: { + method: 'folders().copy', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderCopyParams;\nimport io.imagekit.models.folders.FolderCopyResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderCopyParams params = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderCopyResponse response = client.folders().copy(params);\n }\n}', + }, + kotlin: { + method: 'folders().copy', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderCopyParams\nimport com.imagekit.api.models.folders.FolderCopyResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderCopyParams = FolderCopyParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build()\n val response: FolderCopyResponse = client.folders().copy(params)\n}', + }, + go: { + method: 'client.Folders.Copy', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Folders.Copy(context.TODO(), imagekit.FolderCopyParams{\n\t\tDestinationPath: "/path/of/destination/folder",\n\t\tSourceFolderPath: "/path/of/source/folder",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.JobID)\n}\n', + }, + ruby: { + method: 'folders.copy', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.folders.copy(\n destination_path: "/path/of/destination/folder",\n source_folder_path: "/path/of/source/folder"\n)\n\nputs(response)', + }, + cli: { + method: 'folders copy', + example: + "imagekit folders copy \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /path/of/destination/folder \\\n --source-folder-path /path/of/source/folder", + }, + php: { + method: 'folders->copy', + example: + "folders->copy(\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n includeVersions: true,\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Folders.Copy', + example: + 'FolderCopyParams parameters = new()\n{\n DestinationPath = "/path/of/destination/folder",\n SourceFolderPath = "/path/of/source/folder",\n};\n\nvar response = await client.Folders.Copy(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/bulkJobs/copyFolder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/path/of/destination/folder",\n "sourceFolderPath": "/path/of/source/folder",\n "includeVersions": true\n }\'', + }, + }, }, { - "name": "move", - "endpoint": "/v1/bulkJobs/moveFolder", - "httpMethod": "post", - "summary": "Move folder", - "description": "This will move one folder into another. The selected folder, its nested folders, files, and their versions are moved in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n", - "stainlessPath": "(resource) folders > (method) move", - "qualified": "client.folders.move", - "params": [ - "destinationPath: string;", - "sourceFolderPath: string;" - ], - "response": "{ jobId: string; }", - "markdown": "## move\n\n`client.folders.move(destinationPath: string, sourceFolderPath: string): { jobId: string; }`\n\n**post** `/v1/bulkJobs/moveFolder`\n\nThis will move one folder into another. The selected folder, its nested folders, files, and their versions are moved in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the destination folder where you want to move the source folder into.\n\n\n- `sourceFolderPath: string`\n The full path to the source folder you want to move.\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.move({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' });\n\nconsole.log(response);\n```", - "perLanguage": { - "typescript": { - "method": "client.folders.move", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.move({\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n});\n\nconsole.log(response.jobId);" - }, - "python": { - "method": "folders.move", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.folders.move(\n destination_path=\"/path/of/destination/folder\",\n source_folder_path=\"/path/of/source/folder\",\n)\nprint(response.job_id)" - }, - "java": { - "method": "folders().move", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderMoveParams;\nimport io.imagekit.models.folders.FolderMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderMoveParams params = FolderMoveParams.builder()\n .destinationPath(\"/path/of/destination/folder\")\n .sourceFolderPath(\"/path/of/source/folder\")\n .build();\n FolderMoveResponse response = client.folders().move(params);\n }\n}" - }, - "kotlin": { - "method": "folders().move", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderMoveParams\nimport com.imagekit.api.models.folders.FolderMoveResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderMoveParams = FolderMoveParams.builder()\n .destinationPath(\"/path/of/destination/folder\")\n .sourceFolderPath(\"/path/of/source/folder\")\n .build()\n val response: FolderMoveResponse = client.folders().move(params)\n}" - }, - "go": { - "method": "client.Folders.Move", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Folders.Move(context.TODO(), imagekit.FolderMoveParams{\n\t\tDestinationPath: \"/path/of/destination/folder\",\n\t\tSourceFolderPath: \"/path/of/source/folder\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.JobID)\n}\n" - }, - "ruby": { - "method": "folders.move", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.folders.move(\n destination_path: \"/path/of/destination/folder\",\n source_folder_path: \"/path/of/source/folder\"\n)\n\nputs(response)" - }, - "cli": { - "method": "folders move", - "example": "imagekit folders move \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /path/of/destination/folder \\\n --source-folder-path /path/of/source/folder" - }, - "php": { - "method": "folders->move", - "example": "folders->move(\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n);\n\nvar_dump($response);" - }, - "csharp": { - "method": "Folders.Move", - "example": "FolderMoveParams parameters = new()\n{\n DestinationPath = \"/path/of/destination/folder\",\n SourceFolderPath = \"/path/of/source/folder\",\n};\n\nvar response = await client.Folders.Move(parameters);\n\nConsole.WriteLine(response);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/bulkJobs/moveFolder \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"destinationPath\": \"/path/of/destination/folder\",\n \"sourceFolderPath\": \"/path/of/source/folder\"\n }'" - } - } + name: 'move', + endpoint: '/v1/bulkJobs/moveFolder', + httpMethod: 'post', + summary: 'Move folder', + description: + 'This will move one folder into another. The selected folder, its nested folders, files, and their versions are moved in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n', + stainlessPath: '(resource) folders > (method) move', + qualified: 'client.folders.move', + params: ['destinationPath: string;', 'sourceFolderPath: string;'], + response: '{ jobId: string; }', + markdown: + "## move\n\n`client.folders.move(destinationPath: string, sourceFolderPath: string): { jobId: string; }`\n\n**post** `/v1/bulkJobs/moveFolder`\n\nThis will move one folder into another. The selected folder, its nested folders, files, and their versions are moved in this operation. Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file version history.\n\n\n### Parameters\n\n- `destinationPath: string`\n Full path to the destination folder where you want to move the source folder into.\n\n\n- `sourceFolderPath: string`\n The full path to the source folder you want to move.\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.move({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' });\n\nconsole.log(response);\n```", + perLanguage: { + typescript: { + method: 'client.folders.move', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.move({\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n});\n\nconsole.log(response.jobId);", + }, + python: { + method: 'folders.move', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.folders.move(\n destination_path="/path/of/destination/folder",\n source_folder_path="/path/of/source/folder",\n)\nprint(response.job_id)', + }, + java: { + method: 'folders().move', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderMoveParams;\nimport io.imagekit.models.folders.FolderMoveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderMoveParams params = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build();\n FolderMoveResponse response = client.folders().move(params);\n }\n}', + }, + kotlin: { + method: 'folders().move', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderMoveParams\nimport com.imagekit.api.models.folders.FolderMoveResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderMoveParams = FolderMoveParams.builder()\n .destinationPath("/path/of/destination/folder")\n .sourceFolderPath("/path/of/source/folder")\n .build()\n val response: FolderMoveResponse = client.folders().move(params)\n}', + }, + go: { + method: 'client.Folders.Move', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Folders.Move(context.TODO(), imagekit.FolderMoveParams{\n\t\tDestinationPath: "/path/of/destination/folder",\n\t\tSourceFolderPath: "/path/of/source/folder",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.JobID)\n}\n', + }, + ruby: { + method: 'folders.move', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.folders.move(\n destination_path: "/path/of/destination/folder",\n source_folder_path: "/path/of/source/folder"\n)\n\nputs(response)', + }, + cli: { + method: 'folders move', + example: + "imagekit folders move \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --destination-path /path/of/destination/folder \\\n --source-folder-path /path/of/source/folder", + }, + php: { + method: 'folders->move', + example: + "folders->move(\n destinationPath: '/path/of/destination/folder',\n sourceFolderPath: '/path/of/source/folder',\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Folders.Move', + example: + 'FolderMoveParams parameters = new()\n{\n DestinationPath = "/path/of/destination/folder",\n SourceFolderPath = "/path/of/source/folder",\n};\n\nvar response = await client.Folders.Move(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/bulkJobs/moveFolder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/path/of/destination/folder",\n "sourceFolderPath": "/path/of/source/folder"\n }\'', + }, + }, }, { - "name": "rename", - "endpoint": "/v1/bulkJobs/renameFolder", - "httpMethod": "post", - "summary": "Rename folder", - "description": "This API allows you to rename an existing folder. The folder and all its nested assets and sub-folders will remain unchanged, but their paths will be updated to reflect the new folder name.\n", - "stainlessPath": "(resource) folders > (method) rename", - "qualified": "client.folders.rename", - "params": [ - "folderPath: string;", - "newFolderName: string;", - "purgeCache?: boolean;" - ], - "response": "{ jobId: string; }", - "markdown": "## rename\n\n`client.folders.rename(folderPath: string, newFolderName: string, purgeCache?: boolean): { jobId: string; }`\n\n**post** `/v1/bulkJobs/renameFolder`\n\nThis API allows you to rename an existing folder. The folder and all its nested assets and sub-folders will remain unchanged, but their paths will be updated to reflect the new folder name.\n\n\n### Parameters\n\n- `folderPath: string`\n The full path to the folder you want to rename.\n\n\n- `newFolderName: string`\n The new name for the folder.\n\nAll characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) and `-` will be replaced by an underscore i.e. `_`.\n\n\n- `purgeCache?: boolean`\n Option to purge cache for the old nested files and their versions' URLs.\n\nWhen set to true, it will internally issue a purge cache request on CDN to remove the cached content of the old nested files and their versions. There will only be one purge request for all the nested files, which will be counted against your monthly purge quota.\n\nNote: A purge cache request will be issued against `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This will remove all nested files, their versions' URLs, and any transformations made using query parameters on these files or their versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation.\n\nDefault value - `false`\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.rename({ folderPath: '/path/of/folder', newFolderName: 'new-folder-name' });\n\nconsole.log(response);\n```", - "perLanguage": { - "typescript": { - "method": "client.folders.rename", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.rename({\n folderPath: '/path/of/folder',\n newFolderName: 'new-folder-name',\n});\n\nconsole.log(response.jobId);" - }, - "python": { - "method": "folders.rename", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.folders.rename(\n folder_path=\"/path/of/folder\",\n new_folder_name=\"new-folder-name\",\n)\nprint(response.job_id)" - }, - "java": { - "method": "folders().rename", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderRenameParams;\nimport io.imagekit.models.folders.FolderRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderRenameParams params = FolderRenameParams.builder()\n .folderPath(\"/path/of/folder\")\n .newFolderName(\"new-folder-name\")\n .build();\n FolderRenameResponse response = client.folders().rename(params);\n }\n}" - }, - "kotlin": { - "method": "folders().rename", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderRenameParams\nimport com.imagekit.api.models.folders.FolderRenameResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderRenameParams = FolderRenameParams.builder()\n .folderPath(\"/path/of/folder\")\n .newFolderName(\"new-folder-name\")\n .build()\n val response: FolderRenameResponse = client.folders().rename(params)\n}" - }, - "go": { - "method": "client.Folders.Rename", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Folders.Rename(context.TODO(), imagekit.FolderRenameParams{\n\t\tFolderPath: \"/path/of/folder\",\n\t\tNewFolderName: \"new-folder-name\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.JobID)\n}\n" - }, - "ruby": { - "method": "folders.rename", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.folders.rename(folder_path: \"/path/of/folder\", new_folder_name: \"new-folder-name\")\n\nputs(response)" - }, - "cli": { - "method": "folders rename", - "example": "imagekit folders rename \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-path /path/of/folder \\\n --new-folder-name new-folder-name" - }, - "php": { - "method": "folders->rename", - "example": "folders->rename(\n folderPath: '/path/of/folder',\n newFolderName: 'new-folder-name',\n purgeCache: true,\n);\n\nvar_dump($response);" - }, - "csharp": { - "method": "Folders.Rename", - "example": "FolderRenameParams parameters = new()\n{\n FolderPath = \"/path/of/folder\",\n NewFolderName = \"new-folder-name\",\n};\n\nvar response = await client.Folders.Rename(parameters);\n\nConsole.WriteLine(response);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/bulkJobs/renameFolder \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"folderPath\": \"/path/of/folder\",\n \"newFolderName\": \"new-folder-name\",\n \"purgeCache\": true\n }'" - } - } + name: 'rename', + endpoint: '/v1/bulkJobs/renameFolder', + httpMethod: 'post', + summary: 'Rename folder', + description: + 'This API allows you to rename an existing folder. The folder and all its nested assets and sub-folders will remain unchanged, but their paths will be updated to reflect the new folder name.\n', + stainlessPath: '(resource) folders > (method) rename', + qualified: 'client.folders.rename', + params: ['folderPath: string;', 'newFolderName: string;', 'purgeCache?: boolean;'], + response: '{ jobId: string; }', + markdown: + "## rename\n\n`client.folders.rename(folderPath: string, newFolderName: string, purgeCache?: boolean): { jobId: string; }`\n\n**post** `/v1/bulkJobs/renameFolder`\n\nThis API allows you to rename an existing folder. The folder and all its nested assets and sub-folders will remain unchanged, but their paths will be updated to reflect the new folder name.\n\n\n### Parameters\n\n- `folderPath: string`\n The full path to the folder you want to rename.\n\n\n- `newFolderName: string`\n The new name for the folder.\n\nAll characters except alphabets and numbers (inclusive of unicode letters, marks, and numerals in other languages) and `-` will be replaced by an underscore i.e. `_`.\n\n\n- `purgeCache?: boolean`\n Option to purge cache for the old nested files and their versions' URLs.\n\nWhen set to true, it will internally issue a purge cache request on CDN to remove the cached content of the old nested files and their versions. There will only be one purge request for all the nested files, which will be counted against your monthly purge quota.\n\nNote: A purge cache request will be issued against `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This will remove all nested files, their versions' URLs, and any transformations made using query parameters on these files or their versions. However, the cache for file transformations made using path parameters will persist. You can purge them using the purge API. For more details, refer to the purge API documentation.\n\nDefault value - `false`\n\n\n### Returns\n\n- `{ jobId: string; }`\n Job submitted successfully. A `jobId` will be returned.\n\n - `jobId: string`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.folders.rename({ folderPath: '/path/of/folder', newFolderName: 'new-folder-name' });\n\nconsole.log(response);\n```", + perLanguage: { + typescript: { + method: 'client.folders.rename', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.folders.rename({\n folderPath: '/path/of/folder',\n newFolderName: 'new-folder-name',\n});\n\nconsole.log(response.jobId);", + }, + python: { + method: 'folders.rename', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.folders.rename(\n folder_path="/path/of/folder",\n new_folder_name="new-folder-name",\n)\nprint(response.job_id)', + }, + java: { + method: 'folders().rename', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.FolderRenameParams;\nimport io.imagekit.models.folders.FolderRenameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FolderRenameParams params = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build();\n FolderRenameResponse response = client.folders().rename(params);\n }\n}', + }, + kotlin: { + method: 'folders().rename', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.FolderRenameParams\nimport com.imagekit.api.models.folders.FolderRenameResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FolderRenameParams = FolderRenameParams.builder()\n .folderPath("/path/of/folder")\n .newFolderName("new-folder-name")\n .build()\n val response: FolderRenameResponse = client.folders().rename(params)\n}', + }, + go: { + method: 'client.Folders.Rename', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Folders.Rename(context.TODO(), imagekit.FolderRenameParams{\n\t\tFolderPath: "/path/of/folder",\n\t\tNewFolderName: "new-folder-name",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.JobID)\n}\n', + }, + ruby: { + method: 'folders.rename', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.folders.rename(folder_path: "/path/of/folder", new_folder_name: "new-folder-name")\n\nputs(response)', + }, + cli: { + method: 'folders rename', + example: + "imagekit folders rename \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --folder-path /path/of/folder \\\n --new-folder-name new-folder-name", + }, + php: { + method: 'folders->rename', + example: + "folders->rename(\n folderPath: '/path/of/folder',\n newFolderName: 'new-folder-name',\n purgeCache: true,\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Folders.Rename', + example: + 'FolderRenameParams parameters = new()\n{\n FolderPath = "/path/of/folder",\n NewFolderName = "new-folder-name",\n};\n\nvar response = await client.Folders.Rename(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/bulkJobs/renameFolder \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "folderPath": "/path/of/folder",\n "newFolderName": "new-folder-name",\n "purgeCache": true\n }\'', + }, + }, }, { - "name": "get", - "endpoint": "/v1/bulkJobs/{jobId}", - "httpMethod": "get", - "summary": "Bulk job status", - "description": "This API returns the status of a bulk job like copy and move folder operations.\n", - "stainlessPath": "(resource) folders.job > (method) get", - "qualified": "client.folders.job.get", - "params": [ - "jobId: string;" - ], - "response": "{ jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }", - "markdown": "## get\n\n`client.folders.job.get(jobId: string): { jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }`\n\n**get** `/v1/bulkJobs/{jobId}`\n\nThis API returns the status of a bulk job like copy and move folder operations.\n\n\n### Parameters\n\n- `jobId: string`\n\n### Returns\n\n- `{ jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }`\n\n - `jobId?: string`\n - `purgeRequestId?: string`\n - `status?: 'Pending' | 'Completed'`\n - `type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst job = await client.folders.job.get('jobId');\n\nconsole.log(job);\n```", - "perLanguage": { - "typescript": { - "method": "client.folders.job.get", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst job = await client.folders.job.get('jobId');\n\nconsole.log(job.jobId);" - }, - "python": { - "method": "folders.job.get", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\njob = client.folders.job.get(\n \"jobId\",\n)\nprint(job.job_id)" - }, - "java": { - "method": "folders().job().get", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.job.JobGetParams;\nimport io.imagekit.models.folders.job.JobGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n JobGetResponse job = client.folders().job().get(\"jobId\");\n }\n}" - }, - "kotlin": { - "method": "folders().job().get", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.job.JobGetParams\nimport com.imagekit.api.models.folders.job.JobGetResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val job: JobGetResponse = client.folders().job().get(\"jobId\")\n}" - }, - "go": { - "method": "client.Folders.Job.Get", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tjob, err := client.Folders.Job.Get(context.TODO(), \"jobId\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", job.JobID)\n}\n" - }, - "ruby": { - "method": "folders.job.get", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\njob = image_kit.folders.job.get(\"jobId\")\n\nputs(job)" - }, - "cli": { - "method": "job get", - "example": "imagekit folders:job get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --job-id jobId" - }, - "php": { - "method": "folders->job->get", - "example": "folders->job->get('jobId');\n\nvar_dump($job);" - }, - "csharp": { - "method": "Folders.Job.Get", - "example": "JobGetParams parameters = new() { JobID = \"jobId\" };\n\nvar job = await client.Folders.Job.Get(parameters);\n\nConsole.WriteLine(job);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/bulkJobs/$JOB_ID \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'get', + endpoint: '/v1/bulkJobs/{jobId}', + httpMethod: 'get', + summary: 'Bulk job status', + description: 'This API returns the status of a bulk job like copy and move folder operations.\n', + stainlessPath: '(resource) folders.job > (method) get', + qualified: 'client.folders.job.get', + params: ['jobId: string;'], + response: + "{ jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }", + markdown: + "## get\n\n`client.folders.job.get(jobId: string): { jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }`\n\n**get** `/v1/bulkJobs/{jobId}`\n\nThis API returns the status of a bulk job like copy and move folder operations.\n\n\n### Parameters\n\n- `jobId: string`\n\n### Returns\n\n- `{ jobId?: string; purgeRequestId?: string; status?: 'Pending' | 'Completed'; type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'; }`\n\n - `jobId?: string`\n - `purgeRequestId?: string`\n - `status?: 'Pending' | 'Completed'`\n - `type?: 'COPY_FOLDER' | 'MOVE_FOLDER' | 'RENAME_FOLDER'`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst job = await client.folders.job.get('jobId');\n\nconsole.log(job);\n```", + perLanguage: { + typescript: { + method: 'client.folders.job.get', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst job = await client.folders.job.get('jobId');\n\nconsole.log(job.jobId);", + }, + python: { + method: 'folders.job.get', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\njob = client.folders.job.get(\n "jobId",\n)\nprint(job.job_id)', + }, + java: { + method: 'folders().job().get', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.folders.job.JobGetParams;\nimport io.imagekit.models.folders.job.JobGetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n JobGetResponse job = client.folders().job().get("jobId");\n }\n}', + }, + kotlin: { + method: 'folders().job().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.folders.job.JobGetParams\nimport com.imagekit.api.models.folders.job.JobGetResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val job: JobGetResponse = client.folders().job().get("jobId")\n}', + }, + go: { + method: 'client.Folders.Job.Get', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tjob, err := client.Folders.Job.Get(context.TODO(), "jobId")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", job.JobID)\n}\n', + }, + ruby: { + method: 'folders.job.get', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\njob = image_kit.folders.job.get("jobId")\n\nputs(job)', + }, + cli: { + method: 'job get', + example: + "imagekit folders:job get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --job-id jobId", + }, + php: { + method: 'folders->job->get', + example: + "folders->job->get('jobId');\n\nvar_dump($job);", + }, + csharp: { + method: 'Folders.Job.Get', + example: + 'JobGetParams parameters = new() { JobID = "jobId" };\n\nvar job = await client.Folders.Job.Get(parameters);\n\nConsole.WriteLine(job);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/bulkJobs/$JOB_ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "get", - "endpoint": "/v1/accounts/usage", - "httpMethod": "get", - "summary": "Get account usage information", - "description": "Get the account usage information between two dates. Note that the API response includes data from the start date while excluding data from the end date. In other words, the data covers the period starting from the specified start date up to, but not including, the end date.\n", - "stainlessPath": "(resource) accounts.usage > (method) get", - "qualified": "client.accounts.usage.get", - "params": [ - "endDate: string;", - "startDate: string;" - ], - "response": "{ bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }", - "markdown": "## get\n\n`client.accounts.usage.get(endDate: string, startDate: string): { bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }`\n\n**get** `/v1/accounts/usage`\n\nGet the account usage information between two dates. Note that the API response includes data from the start date while excluding data from the end date. In other words, the data covers the period starting from the specified start date up to, but not including, the end date.\n\n\n### Parameters\n\n- `endDate: string`\n Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. The difference between `startDate` and `endDate` should be less than 90 days.\n\n- `startDate: string`\n Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. The difference between `startDate` and `endDate` should be less than 90 days.\n\n### Returns\n\n- `{ bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }`\n\n - `bandwidthBytes?: number`\n - `extensionUnitsCount?: number`\n - `mediaLibraryStorageBytes?: number`\n - `originalCacheStorageBytes?: number`\n - `videoProcessingUnitsCount?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst usage = await client.accounts.usage.get({ endDate: '2019-12-27', startDate: '2019-12-27' });\n\nconsole.log(usage);\n```", - "perLanguage": { - "typescript": { - "method": "client.accounts.usage.get", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst usage = await client.accounts.usage.get({ endDate: '2019-12-27', startDate: '2019-12-27' });\n\nconsole.log(usage.bandwidthBytes);" - }, - "python": { - "method": "accounts.usage.get", - "example": "import os\nfrom datetime import date\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nusage = client.accounts.usage.get(\n end_date=date.fromisoformat(\"2019-12-27\"),\n start_date=date.fromisoformat(\"2019-12-27\"),\n)\nprint(usage.bandwidth_bytes)" - }, - "java": { - "method": "accounts().usage().get", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.usage.UsageGetParams;\nimport io.imagekit.models.accounts.usage.UsageGetResponse;\nimport java.time.LocalDate;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UsageGetParams params = UsageGetParams.builder()\n .endDate(LocalDate.parse(\"2019-12-27\"))\n .startDate(LocalDate.parse(\"2019-12-27\"))\n .build();\n UsageGetResponse usage = client.accounts().usage().get(params);\n }\n}" - }, - "kotlin": { - "method": "accounts().usage().get", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.usage.UsageGetParams\nimport com.imagekit.api.models.accounts.usage.UsageGetResponse\nimport java.time.LocalDate\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UsageGetParams = UsageGetParams.builder()\n .endDate(LocalDate.parse(\"2019-12-27\"))\n .startDate(LocalDate.parse(\"2019-12-27\"))\n .build()\n val usage: UsageGetResponse = client.accounts().usage().get(params)\n}" - }, - "go": { - "method": "client.Accounts.Usage.Get", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tusage, err := client.Accounts.Usage.Get(context.TODO(), imagekit.AccountUsageGetParams{\n\t\tEndDate: time.Now(),\n\t\tStartDate: time.Now(),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", usage.BandwidthBytes)\n}\n" - }, - "ruby": { - "method": "accounts.usage.get", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nusage = image_kit.accounts.usage.get(end_date: \"2019-12-27\", start_date: \"2019-12-27\")\n\nputs(usage)" - }, - "cli": { - "method": "usage get", - "example": "imagekit accounts:usage get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --end-date \"'2019-12-27'\" \\\n --start-date \"'2019-12-27'\"" - }, - "php": { - "method": "accounts->usage->get", - "example": "accounts->usage->get(\n endDate: '2019-12-27', startDate: '2019-12-27'\n);\n\nvar_dump($usage);" - }, - "csharp": { - "method": "Accounts.Usage.Get", - "example": "UsageGetParams parameters = new()\n{\n EndDate = \"2019-12-27\",\n StartDate = \"2019-12-27\",\n};\n\nvar usage = await client.Accounts.Usage.Get(parameters);\n\nConsole.WriteLine(usage);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/accounts/usage \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'get', + endpoint: '/v1/accounts/usage', + httpMethod: 'get', + summary: 'Get account usage information', + description: + 'Get the account usage information between two dates. Note that the API response includes data from the start date while excluding data from the end date. In other words, the data covers the period starting from the specified start date up to, but not including, the end date.\n', + stainlessPath: '(resource) accounts.usage > (method) get', + qualified: 'client.accounts.usage.get', + params: ['endDate: string;', 'startDate: string;'], + response: + '{ bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }', + markdown: + "## get\n\n`client.accounts.usage.get(endDate: string, startDate: string): { bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }`\n\n**get** `/v1/accounts/usage`\n\nGet the account usage information between two dates. Note that the API response includes data from the start date while excluding data from the end date. In other words, the data covers the period starting from the specified start date up to, but not including, the end date.\n\n\n### Parameters\n\n- `endDate: string`\n Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. The difference between `startDate` and `endDate` should be less than 90 days.\n\n- `startDate: string`\n Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. The difference between `startDate` and `endDate` should be less than 90 days.\n\n### Returns\n\n- `{ bandwidthBytes?: number; extensionUnitsCount?: number; mediaLibraryStorageBytes?: number; originalCacheStorageBytes?: number; videoProcessingUnitsCount?: number; }`\n\n - `bandwidthBytes?: number`\n - `extensionUnitsCount?: number`\n - `mediaLibraryStorageBytes?: number`\n - `originalCacheStorageBytes?: number`\n - `videoProcessingUnitsCount?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst usage = await client.accounts.usage.get({ endDate: '2019-12-27', startDate: '2019-12-27' });\n\nconsole.log(usage);\n```", + perLanguage: { + typescript: { + method: 'client.accounts.usage.get', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst usage = await client.accounts.usage.get({ endDate: '2019-12-27', startDate: '2019-12-27' });\n\nconsole.log(usage.bandwidthBytes);", + }, + python: { + method: 'accounts.usage.get', + example: + 'import os\nfrom datetime import date\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nusage = client.accounts.usage.get(\n end_date=date.fromisoformat("2019-12-27"),\n start_date=date.fromisoformat("2019-12-27"),\n)\nprint(usage.bandwidth_bytes)', + }, + java: { + method: 'accounts().usage().get', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.usage.UsageGetParams;\nimport io.imagekit.models.accounts.usage.UsageGetResponse;\nimport java.time.LocalDate;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UsageGetParams params = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build();\n UsageGetResponse usage = client.accounts().usage().get(params);\n }\n}', + }, + kotlin: { + method: 'accounts().usage().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.usage.UsageGetParams\nimport com.imagekit.api.models.accounts.usage.UsageGetResponse\nimport java.time.LocalDate\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UsageGetParams = UsageGetParams.builder()\n .endDate(LocalDate.parse("2019-12-27"))\n .startDate(LocalDate.parse("2019-12-27"))\n .build()\n val usage: UsageGetResponse = client.accounts().usage().get(params)\n}', + }, + go: { + method: 'client.Accounts.Usage.Get', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tusage, err := client.Accounts.Usage.Get(context.TODO(), imagekit.AccountUsageGetParams{\n\t\tEndDate: time.Now(),\n\t\tStartDate: time.Now(),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", usage.BandwidthBytes)\n}\n', + }, + ruby: { + method: 'accounts.usage.get', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nusage = image_kit.accounts.usage.get(end_date: "2019-12-27", start_date: "2019-12-27")\n\nputs(usage)', + }, + cli: { + method: 'usage get', + example: + "imagekit accounts:usage get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --end-date \"'2019-12-27'\" \\\n --start-date \"'2019-12-27'\"", + }, + php: { + method: 'accounts->usage->get', + example: + "accounts->usage->get(\n endDate: '2019-12-27', startDate: '2019-12-27'\n);\n\nvar_dump($usage);", + }, + csharp: { + method: 'Accounts.Usage.Get', + example: + 'UsageGetParams parameters = new()\n{\n EndDate = "2019-12-27",\n StartDate = "2019-12-27",\n};\n\nvar usage = await client.Accounts.Usage.Get(parameters);\n\nConsole.WriteLine(usage);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/usage \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "list", - "endpoint": "/v1/accounts/origins", - "httpMethod": "get", - "summary": "List origins", - "description": "**Note:** This API is currently in beta. \nReturns an array of all configured origins for the current account.\n", - "stainlessPath": "(resource) accounts.origins > (method) list", - "qualified": "client.accounts.origins.list", - "response": "object | object | object | object | object | object | object | object[]", - "markdown": "## list\n\n`client.accounts.origins.list(): object | object | object | object | object | object | object | object[]`\n\n**get** `/v1/accounts/origins`\n\n**Note:** This API is currently in beta. \nReturns an array of all configured origins for the current account.\n\n\n### Returns\n\n- `{ id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst originResponses = await client.accounts.origins.list();\n\nconsole.log(originResponses);\n```", - "perLanguage": { - "typescript": { - "method": "client.accounts.origins.list", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponses = await client.accounts.origins.list();\n\nconsole.log(originResponses);" - }, - "python": { - "method": "accounts.origins.list", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\norigin_responses = client.accounts.origins.list()\nprint(origin_responses)" - }, - "java": { - "method": "accounts().origins().list", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginListParams;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List originResponses = client.accounts().origins().list();\n }\n}" - }, - "kotlin": { - "method": "accounts().origins().list", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginListParams\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val originResponses: List = client.accounts().origins().list()\n}" - }, - "go": { - "method": "client.Accounts.Origins.List", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\toriginResponses, err := client.Accounts.Origins.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", originResponses)\n}\n" - }, - "ruby": { - "method": "accounts.origins.list", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\norigin_responses = image_kit.accounts.origins.list\n\nputs(origin_responses)" - }, - "cli": { - "method": "origins list", - "example": "imagekit accounts:origins list \\\n --private-key 'My Private Key' \\\n --password 'My Password'" - }, - "php": { - "method": "accounts->origins->list", - "example": "accounts->origins->list();\n\nvar_dump($originResponses);" - }, - "csharp": { - "method": "Accounts.Origins.List", - "example": "OriginListParams parameters = new();\n\nvar originResponses = await client.Accounts.Origins.List(parameters);\n\nConsole.WriteLine(originResponses);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/accounts/origins \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'list', + endpoint: '/v1/accounts/origins', + httpMethod: 'get', + summary: 'List origins', + description: + '**Note:** This API is currently in beta. \nReturns an array of all configured origins for the current account.\n', + stainlessPath: '(resource) accounts.origins > (method) list', + qualified: 'client.accounts.origins.list', + response: 'object | object | object | object | object | object | object | object[]', + markdown: + "## list\n\n`client.accounts.origins.list(): object | object | object | object | object | object | object | object[]`\n\n**get** `/v1/accounts/origins`\n\n**Note:** This API is currently in beta. \nReturns an array of all configured origins for the current account.\n\n\n### Returns\n\n- `{ id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst originResponses = await client.accounts.origins.list();\n\nconsole.log(originResponses);\n```", + perLanguage: { + typescript: { + method: 'client.accounts.origins.list', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponses = await client.accounts.origins.list();\n\nconsole.log(originResponses);", + }, + python: { + method: 'accounts.origins.list', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_responses = client.accounts.origins.list()\nprint(origin_responses)', + }, + java: { + method: 'accounts().origins().list', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginListParams;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List originResponses = client.accounts().origins().list();\n }\n}', + }, + kotlin: { + method: 'accounts().origins().list', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginListParams\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val originResponses: List = client.accounts().origins().list()\n}', + }, + go: { + method: 'client.Accounts.Origins.List', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponses, err := client.Accounts.Origins.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponses)\n}\n', + }, + ruby: { + method: 'accounts.origins.list', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\norigin_responses = image_kit.accounts.origins.list\n\nputs(origin_responses)', + }, + cli: { + method: 'origins list', + example: + "imagekit accounts:origins list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'accounts->origins->list', + example: + "accounts->origins->list();\n\nvar_dump($originResponses);", + }, + csharp: { + method: 'Accounts.Origins.List', + example: + 'OriginListParams parameters = new();\n\nvar originResponses = await client.Accounts.Origins.List(parameters);\n\nConsole.WriteLine(originResponses);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/origins \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "create", - "endpoint": "/v1/accounts/origins", - "httpMethod": "post", - "summary": "Create origin", - "description": "**Note:** This API is currently in beta. \nCreates a new origin and returns the origin object.\n", - "stainlessPath": "(resource) accounts.origins > (method) create", - "qualified": "client.accounts.origins.create", - "params": [ - "OriginRequest: { accessKey: string; bucket: string; name: string; secretKey: string; type: 'S3'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accessKey: string; bucket: string; endpoint: string; name: string; secretKey: string; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; s3ForcePathStyle?: boolean; } | { accessKey: string; bucket: string; name: string; secretKey: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; forwardHostHeaderToOrigin?: boolean; includeCanonicalHeader?: boolean; } | { name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; } | { bucket: string; clientEmail: string; name: string; privateKey: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accountName: string; container: string; name: string; sasToken: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; clientId: string; clientSecret: string; name: string; password: string; type: 'AKENEO_PIM'; username: string; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; };" + name: 'create', + endpoint: '/v1/accounts/origins', + httpMethod: 'post', + summary: 'Create origin', + description: + '**Note:** This API is currently in beta. \nCreates a new origin and returns the origin object.\n', + stainlessPath: '(resource) accounts.origins > (method) create', + qualified: 'client.accounts.origins.create', + params: [ + "OriginRequest: { accessKey: string; bucket: string; name: string; secretKey: string; type: 'S3'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accessKey: string; bucket: string; endpoint: string; name: string; secretKey: string; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; s3ForcePathStyle?: boolean; } | { accessKey: string; bucket: string; name: string; secretKey: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; forwardHostHeaderToOrigin?: boolean; includeCanonicalHeader?: boolean; } | { name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; } | { bucket: string; clientEmail: string; name: string; privateKey: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accountName: string; container: string; name: string; sasToken: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; clientId: string; clientSecret: string; name: string; password: string; type: 'AKENEO_PIM'; username: string; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; };", ], - "response": "object | object | object | object | object | object | object | object", - "perLanguage": { - "typescript": { - "method": "client.accounts.origins.create", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.create({\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'product-images',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'S3',\n});\n\nconsole.log(originResponse);" - }, - "python": { - "method": "accounts.origins.create", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.create(\n access_key=\"AKIAIOSFODNN7EXAMPLE\",\n bucket=\"product-images\",\n name=\"US S3 Storage\",\n secret_key=\"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n type=\"S3\",\n)\nprint(origin_response)" - }, - "java": { - "method": "accounts().origins().create", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginCreateParams;\nimport io.imagekit.models.accounts.origins.OriginRequest;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey(\"AKIATEST123\")\n .bucket(\"test-bucket\")\n .name(\"My S3 Origin\")\n .secretKey(\"secrettest123\")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}" - }, - "kotlin": { - "method": "accounts().origins().create", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginCreateParams\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginRequest.S3 = OriginRequest.S3.builder()\n .accessKey(\"AKIATEST123\")\n .bucket(\"test-bucket\")\n .name(\"My S3 Origin\")\n .secretKey(\"secrettest123\")\n .build()\n val originResponse: OriginResponse = client.accounts().origins().create(params)\n}" - }, - "go": { - "method": "client.Accounts.Origins.New", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.New(context.TODO(), imagekit.AccountOriginNewParams{\n\t\tOriginRequest: imagekit.OriginRequestUnionParam{\n\t\t\tOfS3: &imagekit.OriginRequestS3Param{\n\t\t\t\tAccessKey: \"AKIATEST123\",\n\t\t\t\tBucket: \"test-bucket\",\n\t\t\t\tName: \"My S3 Origin\",\n\t\t\t\tSecretKey: \"secrettest123\",\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", originResponse)\n}\n" - }, - "ruby": { - "method": "accounts.origins.create", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\norigin_response = image_kit.accounts.origins.create(\n origin_request: {accessKey: \"AKIATEST123\", bucket: \"test-bucket\", name: \"My S3 Origin\", secretKey: \"secrettest123\", type: :S3}\n)\n\nputs(origin_response)" - }, - "cli": { - "method": "origins create", - "example": "imagekit accounts:origins create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --access-key AKIAIOSFODNN7EXAMPLE \\\n --bucket product-images \\\n --name 'US S3 Storage' \\\n --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \\\n --type S3 \\\n --endpoint https://s3.eu-central-1.wasabisys.com \\\n --base-url https://images.example.com/assets \\\n --client-email service-account@project.iam.gserviceaccount.com \\\n --private-key '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...' \\\n --account-name account123 \\\n --container images \\\n --sas-token '?sv=2023-01-03&sr=c&sig=abc123' \\\n --client-id akeneo-client-id \\\n --client-secret akeneo-client-secret \\\n --password strongpassword123 \\\n --username integration-user" - }, - "php": { - "method": "accounts->origins->create", - "example": "accounts->origins->create(\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'gcs-media',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'AKENEO_PIM',\n baseURLForCanonicalHeader: 'https://cdn.example.com',\n includeCanonicalHeader: false,\n prefix: 'uploads',\n endpoint: 'https://s3.eu-central-1.wasabisys.com',\n s3ForcePathStyle: true,\n baseURL: 'https://akeneo.company.com',\n forwardHostHeaderToOrigin: false,\n clientEmail: 'service-account@project.iam.gserviceaccount.com',\n privateKey: '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...',\n accountName: 'account123',\n container: 'images',\n sasToken: '?sv=2023-01-03&sr=c&sig=abc123',\n clientID: 'akeneo-client-id',\n clientSecret: 'akeneo-client-secret',\n password: 'strongpassword123',\n username: 'integration-user',\n);\n\nvar_dump($originResponse);" - }, - "csharp": { - "method": "Accounts.Origins.Create", - "example": "OriginCreateParams parameters = new()\n{\n OriginRequest = new S3()\n {\n AccessKey = \"AKIATEST123\",\n Bucket = \"test-bucket\",\n Name = \"My S3 Origin\",\n SecretKey = \"secrettest123\",\n BaseUrlForCanonicalHeader = \"https://cdn.example.com\",\n IncludeCanonicalHeader = false,\n Prefix = \"images\",\n },\n};\n\nvar originResponse = await client.Accounts.Origins.Create(parameters);\n\nConsole.WriteLine(originResponse);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/accounts/origins \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"accessKey\": \"AKIAIOSFODNN7EXAMPLE\",\n \"bucket\": \"product-images\",\n \"name\": \"US S3 Storage\",\n \"secretKey\": \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n \"type\": \"S3\",\n \"baseUrlForCanonicalHeader\": \"https://cdn.example.com\",\n \"prefix\": \"raw-assets\"\n }'" - } - } + response: 'object | object | object | object | object | object | object | object', + perLanguage: { + typescript: { + method: 'client.accounts.origins.create', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.create({\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'product-images',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'S3',\n});\n\nconsole.log(originResponse);", + }, + python: { + method: 'accounts.origins.create', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.create(\n access_key="AKIAIOSFODNN7EXAMPLE",\n bucket="product-images",\n name="US S3 Storage",\n secret_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n type="S3",\n)\nprint(origin_response)', + }, + java: { + method: 'accounts().origins().create', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginCreateParams;\nimport io.imagekit.models.accounts.origins.OriginRequest;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}', + }, + kotlin: { + method: 'accounts().origins().create', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginCreateParams\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginRequest.S3 = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build()\n val originResponse: OriginResponse = client.accounts().origins().create(params)\n}', + }, + go: { + method: 'client.Accounts.Origins.New', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.New(context.TODO(), imagekit.AccountOriginNewParams{\n\t\tOriginRequest: imagekit.OriginRequestUnionParam{\n\t\t\tOfS3: &imagekit.OriginRequestS3Param{\n\t\t\t\tAccessKey: "AKIATEST123",\n\t\t\t\tBucket: "test-bucket",\n\t\t\t\tName: "My S3 Origin",\n\t\t\t\tSecretKey: "secrettest123",\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponse)\n}\n', + }, + ruby: { + method: 'accounts.origins.create', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\norigin_response = image_kit.accounts.origins.create(\n origin_request: {accessKey: "AKIATEST123", bucket: "test-bucket", name: "My S3 Origin", secretKey: "secrettest123", type: :S3}\n)\n\nputs(origin_response)', + }, + cli: { + method: 'origins create', + example: + "imagekit accounts:origins create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --access-key AKIAIOSFODNN7EXAMPLE \\\n --bucket product-images \\\n --name 'US S3 Storage' \\\n --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \\\n --type S3 \\\n --endpoint https://s3.eu-central-1.wasabisys.com \\\n --base-url https://images.example.com/assets \\\n --client-email service-account@project.iam.gserviceaccount.com \\\n --private-key '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...' \\\n --account-name account123 \\\n --container images \\\n --sas-token '?sv=2023-01-03&sr=c&sig=abc123' \\\n --client-id akeneo-client-id \\\n --client-secret akeneo-client-secret \\\n --password strongpassword123 \\\n --username integration-user", + }, + php: { + method: 'accounts->origins->create', + example: + "accounts->origins->create(\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'gcs-media',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'AKENEO_PIM',\n baseURLForCanonicalHeader: 'https://cdn.example.com',\n includeCanonicalHeader: false,\n prefix: 'uploads',\n endpoint: 'https://s3.eu-central-1.wasabisys.com',\n s3ForcePathStyle: true,\n baseURL: 'https://akeneo.company.com',\n forwardHostHeaderToOrigin: false,\n clientEmail: 'service-account@project.iam.gserviceaccount.com',\n privateKey: '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...',\n accountName: 'account123',\n container: 'images',\n sasToken: '?sv=2023-01-03&sr=c&sig=abc123',\n clientID: 'akeneo-client-id',\n clientSecret: 'akeneo-client-secret',\n password: 'strongpassword123',\n username: 'integration-user',\n);\n\nvar_dump($originResponse);", + }, + csharp: { + method: 'Accounts.Origins.Create', + example: + 'OriginCreateParams parameters = new()\n{\n OriginRequest = new S3()\n {\n AccessKey = "AKIATEST123",\n Bucket = "test-bucket",\n Name = "My S3 Origin",\n SecretKey = "secrettest123",\n BaseUrlForCanonicalHeader = "https://cdn.example.com",\n IncludeCanonicalHeader = false,\n Prefix = "images",\n },\n};\n\nvar originResponse = await client.Accounts.Origins.Create(parameters);\n\nConsole.WriteLine(originResponse);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/origins \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "accessKey": "AKIAIOSFODNN7EXAMPLE",\n "bucket": "product-images",\n "name": "US S3 Storage",\n "secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n "type": "S3",\n "baseUrlForCanonicalHeader": "https://cdn.example.com",\n "prefix": "raw-assets"\n }\'', + }, + }, }, { - "name": "get", - "endpoint": "/v1/accounts/origins/{id}", - "httpMethod": "get", - "summary": "Get origin", - "description": "**Note:** This API is currently in beta. \nRetrieves the origin identified by `id`.\n", - "stainlessPath": "(resource) accounts.origins > (method) get", - "qualified": "client.accounts.origins.get", - "params": [ - "id: string;" - ], - "response": "object | object | object | object | object | object | object | object", - "markdown": "## get\n\n`client.accounts.origins.get(id: string): { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }`\n\n**get** `/v1/accounts/origins/{id}`\n\n**Note:** This API is currently in beta. \nRetrieves the origin identified by `id`.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the origin. This is generated by ImageKit when you create a new origin.\n\n### Returns\n\n- `{ id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }`\n Origin object as returned by the API (sensitive fields removed).\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst originResponse = await client.accounts.origins.get('id');\n\nconsole.log(originResponse);\n```", - "perLanguage": { - "typescript": { - "method": "client.accounts.origins.get", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.get('id');\n\nconsole.log(originResponse);" - }, - "python": { - "method": "accounts.origins.get", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.get(\n \"id\",\n)\nprint(origin_response)" - }, - "java": { - "method": "accounts().origins().get", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginGetParams;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginResponse originResponse = client.accounts().origins().get(\"id\");\n }\n}" - }, - "kotlin": { - "method": "accounts().origins().get", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginGetParams\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val originResponse: OriginResponse = client.accounts().origins().get(\"id\")\n}" - }, - "go": { - "method": "client.Accounts.Origins.Get", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.Get(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", originResponse)\n}\n" - }, - "ruby": { - "method": "accounts.origins.get", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\norigin_response = image_kit.accounts.origins.get(\"id\")\n\nputs(origin_response)" - }, - "cli": { - "method": "origins get", - "example": "imagekit accounts:origins get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" - }, - "php": { - "method": "accounts->origins->get", - "example": "accounts->origins->get('id');\n\nvar_dump($originResponse);" - }, - "csharp": { - "method": "Accounts.Origins.Get", - "example": "OriginGetParams parameters = new() { ID = \"id\" };\n\nvar originResponse = await client.Accounts.Origins.Get(parameters);\n\nConsole.WriteLine(originResponse);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'get', + endpoint: '/v1/accounts/origins/{id}', + httpMethod: 'get', + summary: 'Get origin', + description: '**Note:** This API is currently in beta. \nRetrieves the origin identified by `id`.\n', + stainlessPath: '(resource) accounts.origins > (method) get', + qualified: 'client.accounts.origins.get', + params: ['id: string;'], + response: 'object | object | object | object | object | object | object | object', + markdown: + "## get\n\n`client.accounts.origins.get(id: string): { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }`\n\n**get** `/v1/accounts/origins/{id}`\n\n**Note:** This API is currently in beta. \nRetrieves the origin identified by `id`.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the origin. This is generated by ImageKit when you create a new origin.\n\n### Returns\n\n- `{ id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'S3'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; endpoint: string; includeCanonicalHeader: boolean; name: string; prefix: string; s3ForcePathStyle: boolean; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; forwardHostHeaderToOrigin: boolean; includeCanonicalHeader: boolean; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; } | { id: string; includeCanonicalHeader: boolean; name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; } | { id: string; bucket: string; clientEmail: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; } | { id: string; accountName: string; container: string; includeCanonicalHeader: boolean; name: string; prefix: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; } | { id: string; baseUrl: string; includeCanonicalHeader: boolean; name: string; type: 'AKENEO_PIM'; baseUrlForCanonicalHeader?: string; }`\n Origin object as returned by the API (sensitive fields removed).\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst originResponse = await client.accounts.origins.get('id');\n\nconsole.log(originResponse);\n```", + perLanguage: { + typescript: { + method: 'client.accounts.origins.get', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.get('id');\n\nconsole.log(originResponse);", + }, + python: { + method: 'accounts.origins.get', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.get(\n "id",\n)\nprint(origin_response)', + }, + java: { + method: 'accounts().origins().get', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginGetParams;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginResponse originResponse = client.accounts().origins().get("id");\n }\n}', + }, + kotlin: { + method: 'accounts().origins().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginGetParams\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val originResponse: OriginResponse = client.accounts().origins().get("id")\n}', + }, + go: { + method: 'client.Accounts.Origins.Get', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.Get(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponse)\n}\n', + }, + ruby: { + method: 'accounts.origins.get', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\norigin_response = image_kit.accounts.origins.get("id")\n\nputs(origin_response)', + }, + cli: { + method: 'origins get', + example: + "imagekit accounts:origins get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'accounts->origins->get', + example: + "accounts->origins->get('id');\n\nvar_dump($originResponse);", + }, + csharp: { + method: 'Accounts.Origins.Get', + example: + 'OriginGetParams parameters = new() { ID = "id" };\n\nvar originResponse = await client.Accounts.Origins.Get(parameters);\n\nConsole.WriteLine(originResponse);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "update", - "endpoint": "/v1/accounts/origins/{id}", - "httpMethod": "put", - "summary": "Update origin", - "description": "**Note:** This API is currently in beta. \nUpdates the origin identified by `id` and returns the updated origin object.\n", - "stainlessPath": "(resource) accounts.origins > (method) update", - "qualified": "client.accounts.origins.update", - "params": [ - "id: string;", - "OriginRequest: { accessKey: string; bucket: string; name: string; secretKey: string; type: 'S3'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accessKey: string; bucket: string; endpoint: string; name: string; secretKey: string; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; s3ForcePathStyle?: boolean; } | { accessKey: string; bucket: string; name: string; secretKey: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; forwardHostHeaderToOrigin?: boolean; includeCanonicalHeader?: boolean; } | { name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; } | { bucket: string; clientEmail: string; name: string; privateKey: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accountName: string; container: string; name: string; sasToken: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; clientId: string; clientSecret: string; name: string; password: string; type: 'AKENEO_PIM'; username: string; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; };" + name: 'update', + endpoint: '/v1/accounts/origins/{id}', + httpMethod: 'put', + summary: 'Update origin', + description: + '**Note:** This API is currently in beta. \nUpdates the origin identified by `id` and returns the updated origin object.\n', + stainlessPath: '(resource) accounts.origins > (method) update', + qualified: 'client.accounts.origins.update', + params: [ + 'id: string;', + "OriginRequest: { accessKey: string; bucket: string; name: string; secretKey: string; type: 'S3'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accessKey: string; bucket: string; endpoint: string; name: string; secretKey: string; type: 'S3_COMPATIBLE'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; s3ForcePathStyle?: boolean; } | { accessKey: string; bucket: string; name: string; secretKey: string; type: 'CLOUDINARY_BACKUP'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; name: string; type: 'WEB_FOLDER'; baseUrlForCanonicalHeader?: string; forwardHostHeaderToOrigin?: boolean; includeCanonicalHeader?: boolean; } | { name: string; type: 'WEB_PROXY'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; } | { bucket: string; clientEmail: string; name: string; privateKey: string; type: 'GCS'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { accountName: string; container: string; name: string; sasToken: string; type: 'AZURE_BLOB'; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; prefix?: string; } | { baseUrl: string; clientId: string; clientSecret: string; name: string; password: string; type: 'AKENEO_PIM'; username: string; baseUrlForCanonicalHeader?: string; includeCanonicalHeader?: boolean; };", ], - "response": "object | object | object | object | object | object | object | object", - "perLanguage": { - "typescript": { - "method": "client.accounts.origins.update", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.update('id', {\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'product-images',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'S3',\n});\n\nconsole.log(originResponse);" - }, - "python": { - "method": "accounts.origins.update", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.update(\n id=\"id\",\n access_key=\"AKIAIOSFODNN7EXAMPLE\",\n bucket=\"product-images\",\n name=\"US S3 Storage\",\n secret_key=\"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n type=\"S3\",\n)\nprint(origin_response)" - }, - "java": { - "method": "accounts().origins().update", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginRequest;\nimport io.imagekit.models.accounts.origins.OriginResponse;\nimport io.imagekit.models.accounts.origins.OriginUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginUpdateParams params = OriginUpdateParams.builder()\n .id(\"id\")\n .originRequest(OriginRequest.S3.builder()\n .accessKey(\"AKIATEST123\")\n .bucket(\"test-bucket\")\n .name(\"My S3 Origin\")\n .secretKey(\"secrettest123\")\n .build())\n .build();\n OriginResponse originResponse = client.accounts().origins().update(params);\n }\n}" - }, - "kotlin": { - "method": "accounts().origins().update", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\nimport com.imagekit.api.models.accounts.origins.OriginUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginUpdateParams = OriginUpdateParams.builder()\n .id(\"id\")\n .originRequest(OriginRequest.S3.builder()\n .accessKey(\"AKIATEST123\")\n .bucket(\"test-bucket\")\n .name(\"My S3 Origin\")\n .secretKey(\"secrettest123\")\n .build())\n .build()\n val originResponse: OriginResponse = client.accounts().origins().update(params)\n}" - }, - "go": { - "method": "client.Accounts.Origins.Update", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.Update(\n\t\tcontext.TODO(),\n\t\t\"id\",\n\t\timagekit.AccountOriginUpdateParams{\n\t\t\tOriginRequest: imagekit.OriginRequestUnionParam{\n\t\t\t\tOfS3: &imagekit.OriginRequestS3Param{\n\t\t\t\t\tAccessKey: \"AKIATEST123\",\n\t\t\t\t\tBucket: \"test-bucket\",\n\t\t\t\t\tName: \"My S3 Origin\",\n\t\t\t\t\tSecretKey: \"secrettest123\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", originResponse)\n}\n" - }, - "ruby": { - "method": "accounts.origins.update", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\norigin_response = image_kit.accounts.origins.update(\n \"id\",\n origin_request: {accessKey: \"AKIATEST123\", bucket: \"test-bucket\", name: \"My S3 Origin\", secretKey: \"secrettest123\", type: :S3}\n)\n\nputs(origin_response)" - }, - "cli": { - "method": "origins update", - "example": "imagekit accounts:origins update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id \\\n --access-key AKIAIOSFODNN7EXAMPLE \\\n --bucket product-images \\\n --name 'US S3 Storage' \\\n --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \\\n --type S3 \\\n --endpoint https://s3.eu-central-1.wasabisys.com \\\n --base-url https://images.example.com/assets \\\n --client-email service-account@project.iam.gserviceaccount.com \\\n --private-key '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...' \\\n --account-name account123 \\\n --container images \\\n --sas-token '?sv=2023-01-03&sr=c&sig=abc123' \\\n --client-id akeneo-client-id \\\n --client-secret akeneo-client-secret \\\n --password strongpassword123 \\\n --username integration-user" - }, - "php": { - "method": "accounts->origins->update", - "example": "accounts->origins->update(\n 'id',\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'gcs-media',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'AKENEO_PIM',\n baseURLForCanonicalHeader: 'https://cdn.example.com',\n includeCanonicalHeader: false,\n prefix: 'uploads',\n endpoint: 'https://s3.eu-central-1.wasabisys.com',\n s3ForcePathStyle: true,\n baseURL: 'https://akeneo.company.com',\n forwardHostHeaderToOrigin: false,\n clientEmail: 'service-account@project.iam.gserviceaccount.com',\n privateKey: '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...',\n accountName: 'account123',\n container: 'images',\n sasToken: '?sv=2023-01-03&sr=c&sig=abc123',\n clientID: 'akeneo-client-id',\n clientSecret: 'akeneo-client-secret',\n password: 'strongpassword123',\n username: 'integration-user',\n);\n\nvar_dump($originResponse);" - }, - "csharp": { - "method": "Accounts.Origins.Update", - "example": "OriginUpdateParams parameters = new()\n{\n ID = \"id\",\n OriginRequest = new S3()\n {\n AccessKey = \"AKIATEST123\",\n Bucket = \"test-bucket\",\n Name = \"My S3 Origin\",\n SecretKey = \"secrettest123\",\n BaseUrlForCanonicalHeader = \"https://cdn.example.com\",\n IncludeCanonicalHeader = false,\n Prefix = \"images\",\n },\n};\n\nvar originResponse = await client.Accounts.Origins.Update(parameters);\n\nConsole.WriteLine(originResponse);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X PUT \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"accessKey\": \"AKIAIOSFODNN7EXAMPLE\",\n \"bucket\": \"product-images\",\n \"name\": \"US S3 Storage\",\n \"secretKey\": \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n \"type\": \"S3\",\n \"baseUrlForCanonicalHeader\": \"https://cdn.example.com\",\n \"prefix\": \"raw-assets\"\n }'" - } - } + response: 'object | object | object | object | object | object | object | object', + perLanguage: { + typescript: { + method: 'client.accounts.origins.update', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst originResponse = await client.accounts.origins.update('id', {\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'product-images',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'S3',\n});\n\nconsole.log(originResponse);", + }, + python: { + method: 'accounts.origins.update', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\norigin_response = client.accounts.origins.update(\n id="id",\n access_key="AKIAIOSFODNN7EXAMPLE",\n bucket="product-images",\n name="US S3 Storage",\n secret_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n type="S3",\n)\nprint(origin_response)', + }, + java: { + method: 'accounts().origins().update', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginRequest;\nimport io.imagekit.models.accounts.origins.OriginResponse;\nimport io.imagekit.models.accounts.origins.OriginUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginUpdateParams params = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build();\n OriginResponse originResponse = client.accounts().origins().update(params);\n }\n}', + }, + kotlin: { + method: 'accounts().origins().update', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\nimport com.imagekit.api.models.accounts.origins.OriginUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginUpdateParams = OriginUpdateParams.builder()\n .id("id")\n .originRequest(OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build())\n .build()\n val originResponse: OriginResponse = client.accounts().origins().update(params)\n}', + }, + go: { + method: 'client.Accounts.Origins.Update', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\toriginResponse, err := client.Accounts.Origins.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.AccountOriginUpdateParams{\n\t\t\tOriginRequest: imagekit.OriginRequestUnionParam{\n\t\t\t\tOfS3: &imagekit.OriginRequestS3Param{\n\t\t\t\t\tAccessKey: "AKIATEST123",\n\t\t\t\t\tBucket: "test-bucket",\n\t\t\t\t\tName: "My S3 Origin",\n\t\t\t\t\tSecretKey: "secrettest123",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", originResponse)\n}\n', + }, + ruby: { + method: 'accounts.origins.update', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\norigin_response = image_kit.accounts.origins.update(\n "id",\n origin_request: {accessKey: "AKIATEST123", bucket: "test-bucket", name: "My S3 Origin", secretKey: "secrettest123", type: :S3}\n)\n\nputs(origin_response)', + }, + cli: { + method: 'origins update', + example: + "imagekit accounts:origins update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id \\\n --access-key AKIAIOSFODNN7EXAMPLE \\\n --bucket product-images \\\n --name 'US S3 Storage' \\\n --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY \\\n --type S3 \\\n --endpoint https://s3.eu-central-1.wasabisys.com \\\n --base-url https://images.example.com/assets \\\n --client-email service-account@project.iam.gserviceaccount.com \\\n --private-key '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...' \\\n --account-name account123 \\\n --container images \\\n --sas-token '?sv=2023-01-03&sr=c&sig=abc123' \\\n --client-id akeneo-client-id \\\n --client-secret akeneo-client-secret \\\n --password strongpassword123 \\\n --username integration-user", + }, + php: { + method: 'accounts->origins->update', + example: + "accounts->origins->update(\n 'id',\n accessKey: 'AKIAIOSFODNN7EXAMPLE',\n bucket: 'gcs-media',\n name: 'US S3 Storage',\n secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',\n type: 'AKENEO_PIM',\n baseURLForCanonicalHeader: 'https://cdn.example.com',\n includeCanonicalHeader: false,\n prefix: 'uploads',\n endpoint: 'https://s3.eu-central-1.wasabisys.com',\n s3ForcePathStyle: true,\n baseURL: 'https://akeneo.company.com',\n forwardHostHeaderToOrigin: false,\n clientEmail: 'service-account@project.iam.gserviceaccount.com',\n privateKey: '-----BEGIN PRIVATE KEY-----\\\\nMIIEv...',\n accountName: 'account123',\n container: 'images',\n sasToken: '?sv=2023-01-03&sr=c&sig=abc123',\n clientID: 'akeneo-client-id',\n clientSecret: 'akeneo-client-secret',\n password: 'strongpassword123',\n username: 'integration-user',\n);\n\nvar_dump($originResponse);", + }, + csharp: { + method: 'Accounts.Origins.Update', + example: + 'OriginUpdateParams parameters = new()\n{\n ID = "id",\n OriginRequest = new S3()\n {\n AccessKey = "AKIATEST123",\n Bucket = "test-bucket",\n Name = "My S3 Origin",\n SecretKey = "secrettest123",\n BaseUrlForCanonicalHeader = "https://cdn.example.com",\n IncludeCanonicalHeader = false,\n Prefix = "images",\n },\n};\n\nvar originResponse = await client.Accounts.Origins.Update(parameters);\n\nConsole.WriteLine(originResponse);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "accessKey": "AKIAIOSFODNN7EXAMPLE",\n "bucket": "product-images",\n "name": "US S3 Storage",\n "secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n "type": "S3",\n "baseUrlForCanonicalHeader": "https://cdn.example.com",\n "prefix": "raw-assets"\n }\'', + }, + }, }, { - "name": "delete", - "endpoint": "/v1/accounts/origins/{id}", - "httpMethod": "delete", - "summary": "Delete origin", - "description": "**Note:** This API is currently in beta. \nPermanently removes the origin identified by `id`. If the origin is in use by any URL‑endpoints, the API will return an error.\n", - "stainlessPath": "(resource) accounts.origins > (method) delete", - "qualified": "client.accounts.origins.delete", - "params": [ - "id: string;" - ], - "markdown": "## delete\n\n`client.accounts.origins.delete(id: string): void`\n\n**delete** `/v1/accounts/origins/{id}`\n\n**Note:** This API is currently in beta. \nPermanently removes the origin identified by `id`. If the origin is in use by any URL‑endpoints, the API will return an error.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the origin. This is generated by ImageKit when you create a new origin.\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.accounts.origins.delete('id')\n```", - "perLanguage": { - "typescript": { - "method": "client.accounts.origins.delete", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.accounts.origins.delete('id');" - }, - "python": { - "method": "accounts.origins.delete", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nclient.accounts.origins.delete(\n \"id\",\n)" - }, - "java": { - "method": "accounts().origins().delete", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().origins().delete(\"id\");\n }\n}" - }, - "kotlin": { - "method": "accounts().origins().delete", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.accounts().origins().delete(\"id\")\n}" - }, - "go": { - "method": "client.Accounts.Origins.Delete", - "example": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\terr := client.Accounts.Origins.Delete(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n" - }, - "ruby": { - "method": "accounts.origins.delete", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresult = image_kit.accounts.origins.delete(\"id\")\n\nputs(result)" - }, - "cli": { - "method": "origins delete", - "example": "imagekit accounts:origins delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" - }, - "php": { - "method": "accounts->origins->delete", - "example": "accounts->origins->delete('id');\n\nvar_dump($result);" - }, - "csharp": { - "method": "Accounts.Origins.Delete", - "example": "OriginDeleteParams parameters = new() { ID = \"id\" };\n\nawait client.Accounts.Origins.Delete(parameters);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'delete', + endpoint: '/v1/accounts/origins/{id}', + httpMethod: 'delete', + summary: 'Delete origin', + description: + '**Note:** This API is currently in beta. \nPermanently removes the origin identified by `id`. If the origin is in use by any URL‑endpoints, the API will return an error.\n', + stainlessPath: '(resource) accounts.origins > (method) delete', + qualified: 'client.accounts.origins.delete', + params: ['id: string;'], + markdown: + "## delete\n\n`client.accounts.origins.delete(id: string): void`\n\n**delete** `/v1/accounts/origins/{id}`\n\n**Note:** This API is currently in beta. \nPermanently removes the origin identified by `id`. If the origin is in use by any URL‑endpoints, the API will return an error.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the origin. This is generated by ImageKit when you create a new origin.\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.accounts.origins.delete('id')\n```", + perLanguage: { + typescript: { + method: 'client.accounts.origins.delete', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.accounts.origins.delete('id');", + }, + python: { + method: 'accounts.origins.delete', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.accounts.origins.delete(\n "id",\n)', + }, + java: { + method: 'accounts().origins().delete', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().origins().delete("id");\n }\n}', + }, + kotlin: { + method: 'accounts().origins().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.accounts().origins().delete("id")\n}', + }, + go: { + method: 'client.Accounts.Origins.Delete', + example: + 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Accounts.Origins.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', + }, + ruby: { + method: 'accounts.origins.delete', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.accounts.origins.delete("id")\n\nputs(result)', + }, + cli: { + method: 'origins delete', + example: + "imagekit accounts:origins delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'accounts->origins->delete', + example: + "accounts->origins->delete('id');\n\nvar_dump($result);", + }, + csharp: { + method: 'Accounts.Origins.Delete', + example: + 'OriginDeleteParams parameters = new() { ID = "id" };\n\nawait client.Accounts.Origins.Delete(parameters);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "list", - "endpoint": "/v1/accounts/url-endpoints", - "httpMethod": "get", - "summary": "List URL‑endpoints", - "description": "**Note:** This API is currently in beta. \nReturns an array of all URL‑endpoints configured including the default URL-endpoint generated by ImageKit during account creation.\n", - "stainlessPath": "(resource) accounts.urlEndpoints > (method) list", - "qualified": "client.accounts.urlEndpoints.list", - "response": "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }[]", - "markdown": "## list\n\n`client.accounts.urlEndpoints.list(): object[]`\n\n**get** `/v1/accounts/url-endpoints`\n\n**Note:** This API is currently in beta. \nReturns an array of all URL‑endpoints configured including the default URL-endpoint generated by ImageKit during account creation.\n\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponses = await client.accounts.urlEndpoints.list();\n\nconsole.log(urlEndpointResponses);\n```", - "perLanguage": { - "typescript": { - "method": "client.accounts.urlEndpoints.list", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponses = await client.accounts.urlEndpoints.list();\n\nconsole.log(urlEndpointResponses);" - }, - "python": { - "method": "accounts.url_endpoints.list", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nurl_endpoint_responses = client.accounts.url_endpoints.list()\nprint(url_endpoint_responses)" - }, - "java": { - "method": "accounts().urlEndpoints().list", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointListParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List urlEndpointResponses = client.accounts().urlEndpoints().list();\n }\n}" - }, - "kotlin": { - "method": "accounts().urlEndpoints().list", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val urlEndpointResponses: List = client.accounts().urlEndpoints().list()\n}" - }, - "go": { - "method": "client.Accounts.URLEndpoints.List", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\turlEndpointResponses, err := client.Accounts.URLEndpoints.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", urlEndpointResponses)\n}\n" - }, - "ruby": { - "method": "accounts.url_endpoints.list", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nurl_endpoint_responses = image_kit.accounts.url_endpoints.list\n\nputs(url_endpoint_responses)" - }, - "cli": { - "method": "urlEndpoints list", - "example": "imagekit accounts:url-endpoints list \\\n --private-key 'My Private Key' \\\n --password 'My Password'" - }, - "php": { - "method": "accounts->urlEndpoints->list", - "example": "accounts->urlEndpoints->list();\n\nvar_dump($urlEndpointResponses);" - }, - "csharp": { - "method": "Accounts.UrlEndpoints.List", - "example": "UrlEndpointListParams parameters = new();\n\nvar urlEndpointResponses = await client.Accounts.UrlEndpoints.List(parameters);\n\nConsole.WriteLine(urlEndpointResponses);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/accounts/url-endpoints \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'list', + endpoint: '/v1/accounts/url-endpoints', + httpMethod: 'get', + summary: 'List URL‑endpoints', + description: + '**Note:** This API is currently in beta. \nReturns an array of all URL‑endpoints configured including the default URL-endpoint generated by ImageKit during account creation.\n', + stainlessPath: '(resource) accounts.urlEndpoints > (method) list', + qualified: 'client.accounts.urlEndpoints.list', + response: + "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }[]", + markdown: + "## list\n\n`client.accounts.urlEndpoints.list(): object[]`\n\n**get** `/v1/accounts/url-endpoints`\n\n**Note:** This API is currently in beta. \nReturns an array of all URL‑endpoints configured including the default URL-endpoint generated by ImageKit during account creation.\n\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }[]`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponses = await client.accounts.urlEndpoints.list();\n\nconsole.log(urlEndpointResponses);\n```", + perLanguage: { + typescript: { + method: 'client.accounts.urlEndpoints.list', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponses = await client.accounts.urlEndpoints.list();\n\nconsole.log(urlEndpointResponses);", + }, + python: { + method: 'accounts.url_endpoints.list', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_responses = client.accounts.url_endpoints.list()\nprint(url_endpoint_responses)', + }, + java: { + method: 'accounts().urlEndpoints().list', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointListParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n List urlEndpointResponses = client.accounts().urlEndpoints().list();\n }\n}', + }, + kotlin: { + method: 'accounts().urlEndpoints().list', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val urlEndpointResponses: List = client.accounts().urlEndpoints().list()\n}', + }, + go: { + method: 'client.Accounts.URLEndpoints.List', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponses, err := client.Accounts.URLEndpoints.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponses)\n}\n', + }, + ruby: { + method: 'accounts.url_endpoints.list', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nurl_endpoint_responses = image_kit.accounts.url_endpoints.list\n\nputs(url_endpoint_responses)', + }, + cli: { + method: 'urlEndpoints list', + example: + "imagekit accounts:url-endpoints list \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'accounts->urlEndpoints->list', + example: + "accounts->urlEndpoints->list();\n\nvar_dump($urlEndpointResponses);", + }, + csharp: { + method: 'Accounts.UrlEndpoints.List', + example: + 'UrlEndpointListParams parameters = new();\n\nvar urlEndpointResponses = await client.Accounts.UrlEndpoints.List(parameters);\n\nConsole.WriteLine(urlEndpointResponses);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/url-endpoints \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "create", - "endpoint": "/v1/accounts/url-endpoints", - "httpMethod": "post", - "summary": "Create URL‑endpoint", - "description": "**Note:** This API is currently in beta. \nCreates a new URL‑endpoint and returns the resulting object.\n", - "stainlessPath": "(resource) accounts.urlEndpoints > (method) create", - "qualified": "client.accounts.urlEndpoints.create", - "params": [ - "description: string;", - "origins?: string[];", - "urlPrefix?: string;", - "urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; };" + name: 'create', + endpoint: '/v1/accounts/url-endpoints', + httpMethod: 'post', + summary: 'Create URL‑endpoint', + description: + '**Note:** This API is currently in beta. \nCreates a new URL‑endpoint and returns the resulting object.\n', + stainlessPath: '(resource) accounts.urlEndpoints > (method) create', + qualified: 'client.accounts.urlEndpoints.create', + params: [ + 'description: string;', + 'origins?: string[];', + 'urlPrefix?: string;', + "urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; };", ], - "response": "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }", - "markdown": "## create\n\n`client.accounts.urlEndpoints.create(description: string, origins?: string[], urlPrefix?: string, urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**post** `/v1/accounts/url-endpoints`\n\n**Note:** This API is currently in beta. \nCreates a new URL‑endpoint and returns the resulting object.\n\n\n### Parameters\n\n- `description: string`\n Description of the URL endpoint.\n\n- `origins?: string[]`\n Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint.\n\n- `urlPrefix?: string`\n Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint).\n\n- `urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n Configuration for third-party URL rewriting.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.create({ description: 'My custom URL endpoint' });\n\nconsole.log(urlEndpointResponse);\n```", - "perLanguage": { - "typescript": { - "method": "client.accounts.urlEndpoints.create", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.create({\n description: 'My custom URL endpoint',\n});\n\nconsole.log(urlEndpointResponse.id);" - }, - "python": { - "method": "accounts.url_endpoints.create", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.create(\n description=\"My custom URL endpoint\",\n)\nprint(url_endpoint_response.id)" - }, - "java": { - "method": "accounts().urlEndpoints().create", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description(\"My custom URL endpoint\")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}" - }, - "kotlin": { - "method": "accounts().urlEndpoints().create", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointRequest = UrlEndpointRequest.builder()\n .description(\"My custom URL endpoint\")\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().create(params)\n}" - }, - "go": { - "method": "client.Accounts.URLEndpoints.New", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.New(context.TODO(), imagekit.AccountURLEndpointNewParams{\n\t\tURLEndpointRequest: imagekit.URLEndpointRequestParam{\n\t\t\tDescription: \"My custom URL endpoint\",\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", urlEndpointResponse.ID)\n}\n" - }, - "ruby": { - "method": "accounts.url_endpoints.create", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.create(description: \"My custom URL endpoint\")\n\nputs(url_endpoint_response)" - }, - "cli": { - "method": "urlEndpoints create", - "example": "imagekit accounts:url-endpoints create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --description 'My custom URL endpoint'" - }, - "php": { - "method": "accounts->urlEndpoints->create", - "example": "accounts->urlEndpoints->create(\n description: 'My custom URL endpoint',\n origins: ['origin-id-1'],\n urlPrefix: 'product-images',\n urlRewriter: ['type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true],\n);\n\nvar_dump($urlEndpointResponse);" - }, - "csharp": { - "method": "Accounts.UrlEndpoints.Create", - "example": "UrlEndpointCreateParams parameters = new()\n{\n Description = \"My custom URL endpoint\"\n};\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Create(parameters);\n\nConsole.WriteLine(urlEndpointResponse);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/accounts/url-endpoints \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"description\": \"My custom URL endpoint\",\n \"origins\": [\n \"origin-id-1\"\n ],\n \"urlPrefix\": \"product-images\"\n }'" - } - } + response: + "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }", + markdown: + "## create\n\n`client.accounts.urlEndpoints.create(description: string, origins?: string[], urlPrefix?: string, urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**post** `/v1/accounts/url-endpoints`\n\n**Note:** This API is currently in beta. \nCreates a new URL‑endpoint and returns the resulting object.\n\n\n### Parameters\n\n- `description: string`\n Description of the URL endpoint.\n\n- `origins?: string[]`\n Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint.\n\n- `urlPrefix?: string`\n Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint).\n\n- `urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n Configuration for third-party URL rewriting.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.create({ description: 'My custom URL endpoint' });\n\nconsole.log(urlEndpointResponse);\n```", + perLanguage: { + typescript: { + method: 'client.accounts.urlEndpoints.create', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.create({\n description: 'My custom URL endpoint',\n});\n\nconsole.log(urlEndpointResponse.id);", + }, + python: { + method: 'accounts.url_endpoints.create', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.create(\n description="My custom URL endpoint",\n)\nprint(url_endpoint_response.id)', + }, + java: { + method: 'accounts().urlEndpoints().create', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}', + }, + kotlin: { + method: 'accounts().urlEndpoints().create', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointRequest = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().create(params)\n}', + }, + go: { + method: 'client.Accounts.URLEndpoints.New', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.New(context.TODO(), imagekit.AccountURLEndpointNewParams{\n\t\tURLEndpointRequest: imagekit.URLEndpointRequestParam{\n\t\t\tDescription: "My custom URL endpoint",\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponse.ID)\n}\n', + }, + ruby: { + method: 'accounts.url_endpoints.create', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.create(description: "My custom URL endpoint")\n\nputs(url_endpoint_response)', + }, + cli: { + method: 'urlEndpoints create', + example: + "imagekit accounts:url-endpoints create \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --description 'My custom URL endpoint'", + }, + php: { + method: 'accounts->urlEndpoints->create', + example: + "accounts->urlEndpoints->create(\n description: 'My custom URL endpoint',\n origins: ['origin-id-1'],\n urlPrefix: 'product-images',\n urlRewriter: ['type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true],\n);\n\nvar_dump($urlEndpointResponse);", + }, + csharp: { + method: 'Accounts.UrlEndpoints.Create', + example: + 'UrlEndpointCreateParams parameters = new()\n{\n Description = "My custom URL endpoint"\n};\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Create(parameters);\n\nConsole.WriteLine(urlEndpointResponse);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/url-endpoints \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "description": "My custom URL endpoint",\n "origins": [\n "origin-id-1"\n ],\n "urlPrefix": "product-images"\n }\'', + }, + }, }, { - "name": "get", - "endpoint": "/v1/accounts/url-endpoints/{id}", - "httpMethod": "get", - "summary": "Get URL‑endpoint", - "description": "**Note:** This API is currently in beta. \nRetrieves the URL‑endpoint identified by `id`.\n", - "stainlessPath": "(resource) accounts.urlEndpoints > (method) get", - "qualified": "client.accounts.urlEndpoints.get", - "params": [ - "id: string;" - ], - "response": "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }", - "markdown": "## get\n\n`client.accounts.urlEndpoints.get(id: string): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**get** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nRetrieves the URL‑endpoint identified by `id`.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.get('id');\n\nconsole.log(urlEndpointResponse);\n```", - "perLanguage": { - "typescript": { - "method": "client.accounts.urlEndpoints.get", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.get('id');\n\nconsole.log(urlEndpointResponse.id);" - }, - "python": { - "method": "accounts.url_endpoints.get", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.get(\n \"id\",\n)\nprint(url_endpoint_response.id)" - }, - "java": { - "method": "accounts().urlEndpoints().get", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get(\"id\");\n }\n}" - }, - "kotlin": { - "method": "accounts().urlEndpoints().get", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().get(\"id\")\n}" - }, - "go": { - "method": "client.Accounts.URLEndpoints.Get", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.Get(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", urlEndpointResponse.ID)\n}\n" - }, - "ruby": { - "method": "accounts.url_endpoints.get", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.get(\"id\")\n\nputs(url_endpoint_response)" - }, - "cli": { - "method": "urlEndpoints get", - "example": "imagekit accounts:url-endpoints get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" - }, - "php": { - "method": "accounts->urlEndpoints->get", - "example": "accounts->urlEndpoints->get('id');\n\nvar_dump($urlEndpointResponse);" - }, - "csharp": { - "method": "Accounts.UrlEndpoints.Get", - "example": "UrlEndpointGetParams parameters = new() { ID = \"id\" };\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Get(parameters);\n\nConsole.WriteLine(urlEndpointResponse);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'get', + endpoint: '/v1/accounts/url-endpoints/{id}', + httpMethod: 'get', + summary: 'Get URL‑endpoint', + description: + '**Note:** This API is currently in beta. \nRetrieves the URL‑endpoint identified by `id`.\n', + stainlessPath: '(resource) accounts.urlEndpoints > (method) get', + qualified: 'client.accounts.urlEndpoints.get', + params: ['id: string;'], + response: + "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }", + markdown: + "## get\n\n`client.accounts.urlEndpoints.get(id: string): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**get** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nRetrieves the URL‑endpoint identified by `id`.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.get('id');\n\nconsole.log(urlEndpointResponse);\n```", + perLanguage: { + typescript: { + method: 'client.accounts.urlEndpoints.get', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.get('id');\n\nconsole.log(urlEndpointResponse.id);", + }, + python: { + method: 'accounts.url_endpoints.get', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.get(\n "id",\n)\nprint(url_endpoint_response.id)', + }, + java: { + method: 'accounts().urlEndpoints().get', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointGetParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().get("id");\n }\n}', + }, + kotlin: { + method: 'accounts().urlEndpoints().get', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().get("id")\n}', + }, + go: { + method: 'client.Accounts.URLEndpoints.Get', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.Get(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponse.ID)\n}\n', + }, + ruby: { + method: 'accounts.url_endpoints.get', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.get("id")\n\nputs(url_endpoint_response)', + }, + cli: { + method: 'urlEndpoints get', + example: + "imagekit accounts:url-endpoints get \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'accounts->urlEndpoints->get', + example: + "accounts->urlEndpoints->get('id');\n\nvar_dump($urlEndpointResponse);", + }, + csharp: { + method: 'Accounts.UrlEndpoints.Get', + example: + 'UrlEndpointGetParams parameters = new() { ID = "id" };\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Get(parameters);\n\nConsole.WriteLine(urlEndpointResponse);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "update", - "endpoint": "/v1/accounts/url-endpoints/{id}", - "httpMethod": "put", - "summary": "Update URL‑endpoint", - "description": "**Note:** This API is currently in beta. \nUpdates the URL‑endpoint identified by `id` and returns the updated object.\n", - "stainlessPath": "(resource) accounts.urlEndpoints > (method) update", - "qualified": "client.accounts.urlEndpoints.update", - "params": [ - "id: string;", - "description: string;", - "origins?: string[];", - "urlPrefix?: string;", - "urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; };" + name: 'update', + endpoint: '/v1/accounts/url-endpoints/{id}', + httpMethod: 'put', + summary: 'Update URL‑endpoint', + description: + '**Note:** This API is currently in beta. \nUpdates the URL‑endpoint identified by `id` and returns the updated object.\n', + stainlessPath: '(resource) accounts.urlEndpoints > (method) update', + qualified: 'client.accounts.urlEndpoints.update', + params: [ + 'id: string;', + 'description: string;', + 'origins?: string[];', + 'urlPrefix?: string;', + "urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; };", ], - "response": "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }", - "markdown": "## update\n\n`client.accounts.urlEndpoints.update(id: string, description: string, origins?: string[], urlPrefix?: string, urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**put** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nUpdates the URL‑endpoint identified by `id` and returns the updated object.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n- `description: string`\n Description of the URL endpoint.\n\n- `origins?: string[]`\n Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint.\n\n- `urlPrefix?: string`\n Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint).\n\n- `urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n Configuration for third-party URL rewriting.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.update('id', { description: 'My custom URL endpoint' });\n\nconsole.log(urlEndpointResponse);\n```", - "perLanguage": { - "typescript": { - "method": "client.accounts.urlEndpoints.update", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.update('id', {\n description: 'My custom URL endpoint',\n});\n\nconsole.log(urlEndpointResponse.id);" - }, - "python": { - "method": "accounts.url_endpoints.update", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.update(\n id=\"id\",\n description=\"My custom URL endpoint\",\n)\nprint(url_endpoint_response.id)" - }, - "java": { - "method": "accounts().urlEndpoints().update", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointUpdateParams params = UrlEndpointUpdateParams.builder()\n .id(\"id\")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description(\"My custom URL endpoint\")\n .build())\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().update(params);\n }\n}" - }, - "kotlin": { - "method": "accounts().urlEndpoints().update", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointUpdateParams = UrlEndpointUpdateParams.builder()\n .id(\"id\")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description(\"My custom URL endpoint\")\n .build())\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().update(params)\n}" - }, - "go": { - "method": "client.Accounts.URLEndpoints.Update", - "example": "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.Update(\n\t\tcontext.TODO(),\n\t\t\"id\",\n\t\timagekit.AccountURLEndpointUpdateParams{\n\t\t\tURLEndpointRequest: imagekit.URLEndpointRequestParam{\n\t\t\t\tDescription: \"My custom URL endpoint\",\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", urlEndpointResponse.ID)\n}\n" - }, - "ruby": { - "method": "accounts.url_endpoints.update", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.update(\"id\", description: \"My custom URL endpoint\")\n\nputs(url_endpoint_response)" - }, - "cli": { - "method": "urlEndpoints update", - "example": "imagekit accounts:url-endpoints update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id \\\n --description 'My custom URL endpoint'" - }, - "php": { - "method": "accounts->urlEndpoints->update", - "example": "accounts->urlEndpoints->update(\n 'id',\n description: 'My custom URL endpoint',\n origins: ['origin-id-1'],\n urlPrefix: 'product-images',\n urlRewriter: ['type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true],\n);\n\nvar_dump($urlEndpointResponse);" - }, - "csharp": { - "method": "Accounts.UrlEndpoints.Update", - "example": "UrlEndpointUpdateParams parameters = new()\n{\n ID = \"id\",\n Description = \"My custom URL endpoint\",\n};\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Update(parameters);\n\nConsole.WriteLine(urlEndpointResponse);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -X PUT \\\n -H 'Content-Type: application/json' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -d '{\n \"description\": \"My custom URL endpoint\",\n \"origins\": [\n \"origin-id-1\"\n ],\n \"urlPrefix\": \"product-images\"\n }'" - } - } + response: + "{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }", + markdown: + "## update\n\n`client.accounts.urlEndpoints.update(id: string, description: string, origins?: string[], urlPrefix?: string, urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }): { id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: object | object | object; }`\n\n**put** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nUpdates the URL‑endpoint identified by `id` and returns the updated object.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n- `description: string`\n Description of the URL endpoint.\n\n- `origins?: string[]`\n Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks them in the sequence provided. Origin must be created before it can be used in a URL endpoint.\n\n- `urlPrefix?: string`\n Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens only — or empty for the default endpoint).\n\n- `urlRewriter?: { type: 'CLOUDINARY'; preserveAssetDeliveryTypes?: boolean; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n Configuration for third-party URL rewriting.\n\n### Returns\n\n- `{ id: string; description: string; origins: string[]; urlPrefix: string; urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }; }`\n URL‑endpoint object as returned by the API.\n\n - `id: string`\n - `description: string`\n - `origins: string[]`\n - `urlPrefix: string`\n - `urlRewriter?: { preserveAssetDeliveryTypes: boolean; type: 'CLOUDINARY'; } | { type: 'IMGIX'; } | { type: 'AKAMAI'; }`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.update('id', { description: 'My custom URL endpoint' });\n\nconsole.log(urlEndpointResponse);\n```", + perLanguage: { + typescript: { + method: 'client.accounts.urlEndpoints.update', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst urlEndpointResponse = await client.accounts.urlEndpoints.update('id', {\n description: 'My custom URL endpoint',\n});\n\nconsole.log(urlEndpointResponse.id);", + }, + python: { + method: 'accounts.url_endpoints.update', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nurl_endpoint_response = client.accounts.url_endpoints.update(\n id="id",\n description="My custom URL endpoint",\n)\nprint(url_endpoint_response.id)', + }, + java: { + method: 'accounts().urlEndpoints().update', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointUpdateParams params = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().update(params);\n }\n}', + }, + kotlin: { + method: 'accounts().urlEndpoints().update', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointUpdateParams = UrlEndpointUpdateParams.builder()\n .id("id")\n .urlEndpointRequest(UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build())\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().update(params)\n}', + }, + go: { + method: 'client.Accounts.URLEndpoints.Update', + example: + 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\turlEndpointResponse, err := client.Accounts.URLEndpoints.Update(\n\t\tcontext.TODO(),\n\t\t"id",\n\t\timagekit.AccountURLEndpointUpdateParams{\n\t\t\tURLEndpointRequest: imagekit.URLEndpointRequestParam{\n\t\t\t\tDescription: "My custom URL endpoint",\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", urlEndpointResponse.ID)\n}\n', + }, + ruby: { + method: 'accounts.url_endpoints.update', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nurl_endpoint_response = image_kit.accounts.url_endpoints.update("id", description: "My custom URL endpoint")\n\nputs(url_endpoint_response)', + }, + cli: { + method: 'urlEndpoints update', + example: + "imagekit accounts:url-endpoints update \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id \\\n --description 'My custom URL endpoint'", + }, + php: { + method: 'accounts->urlEndpoints->update', + example: + "accounts->urlEndpoints->update(\n 'id',\n description: 'My custom URL endpoint',\n origins: ['origin-id-1'],\n urlPrefix: 'product-images',\n urlRewriter: ['type' => 'CLOUDINARY', 'preserveAssetDeliveryTypes' => true],\n);\n\nvar_dump($urlEndpointResponse);", + }, + csharp: { + method: 'Accounts.UrlEndpoints.Update', + example: + 'UrlEndpointUpdateParams parameters = new()\n{\n ID = "id",\n Description = "My custom URL endpoint",\n};\n\nvar urlEndpointResponse = await client.Accounts.UrlEndpoints.Update(parameters);\n\nConsole.WriteLine(urlEndpointResponse);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "description": "My custom URL endpoint",\n "origins": [\n "origin-id-1"\n ],\n "urlPrefix": "product-images"\n }\'', + }, + }, }, { - "name": "delete", - "endpoint": "/v1/accounts/url-endpoints/{id}", - "httpMethod": "delete", - "summary": "Delete URL‑endpoint", - "description": "**Note:** This API is currently in beta. \nDeletes the URL‑endpoint identified by `id`. You cannot delete the default URL‑endpoint created by ImageKit during account creation.\n", - "stainlessPath": "(resource) accounts.urlEndpoints > (method) delete", - "qualified": "client.accounts.urlEndpoints.delete", - "params": [ - "id: string;" - ], - "markdown": "## delete\n\n`client.accounts.urlEndpoints.delete(id: string): void`\n\n**delete** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nDeletes the URL‑endpoint identified by `id`. You cannot delete the default URL‑endpoint created by ImageKit during account creation.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.accounts.urlEndpoints.delete('id')\n```", - "perLanguage": { - "typescript": { - "method": "client.accounts.urlEndpoints.delete", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.accounts.urlEndpoints.delete('id');" - }, - "python": { - "method": "accounts.url_endpoints.delete", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nclient.accounts.url_endpoints.delete(\n \"id\",\n)" - }, - "java": { - "method": "accounts().urlEndpoints().delete", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().urlEndpoints().delete(\"id\");\n }\n}" - }, - "kotlin": { - "method": "accounts().urlEndpoints().delete", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.accounts().urlEndpoints().delete(\"id\")\n}" - }, - "go": { - "method": "client.Accounts.URLEndpoints.Delete", - "example": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\terr := client.Accounts.URLEndpoints.Delete(context.TODO(), \"id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n" - }, - "ruby": { - "method": "accounts.url_endpoints.delete", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresult = image_kit.accounts.url_endpoints.delete(\"id\")\n\nputs(result)" - }, - "cli": { - "method": "urlEndpoints delete", - "example": "imagekit accounts:url-endpoints delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id" - }, - "php": { - "method": "accounts->urlEndpoints->delete", - "example": "accounts->urlEndpoints->delete('id');\n\nvar_dump($result);" - }, - "csharp": { - "method": "Accounts.UrlEndpoints.Delete", - "example": "UrlEndpointDeleteParams parameters = new() { ID = \"id\" };\n\nawait client.Accounts.UrlEndpoints.Delete(parameters);" - }, - "http": { - "example": "curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -X DELETE \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\"" - } - } + name: 'delete', + endpoint: '/v1/accounts/url-endpoints/{id}', + httpMethod: 'delete', + summary: 'Delete URL‑endpoint', + description: + '**Note:** This API is currently in beta. \nDeletes the URL‑endpoint identified by `id`. You cannot delete the default URL‑endpoint created by ImageKit during account creation.\n', + stainlessPath: '(resource) accounts.urlEndpoints > (method) delete', + qualified: 'client.accounts.urlEndpoints.delete', + params: ['id: string;'], + markdown: + "## delete\n\n`client.accounts.urlEndpoints.delete(id: string): void`\n\n**delete** `/v1/accounts/url-endpoints/{id}`\n\n**Note:** This API is currently in beta. \nDeletes the URL‑endpoint identified by `id`. You cannot delete the default URL‑endpoint created by ImageKit during account creation.\n\n\n### Parameters\n\n- `id: string`\n Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new URL-endpoint. For the default URL-endpoint, this is always `default`.\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nawait client.accounts.urlEndpoints.delete('id')\n```", + perLanguage: { + typescript: { + method: 'client.accounts.urlEndpoints.delete', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.accounts.urlEndpoints.delete('id');", + }, + python: { + method: 'accounts.url_endpoints.delete', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.accounts.url_endpoints.delete(\n "id",\n)', + }, + java: { + method: 'accounts().urlEndpoints().delete', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.accounts().urlEndpoints().delete("id");\n }\n}', + }, + kotlin: { + method: 'accounts().urlEndpoints().delete', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.accounts().urlEndpoints().delete("id")\n}', + }, + go: { + method: 'client.Accounts.URLEndpoints.Delete', + example: + 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Accounts.URLEndpoints.Delete(context.TODO(), "id")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', + }, + ruby: { + method: 'accounts.url_endpoints.delete', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.accounts.url_endpoints.delete("id")\n\nputs(result)', + }, + cli: { + method: 'urlEndpoints delete', + example: + "imagekit accounts:url-endpoints delete \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --id id", + }, + php: { + method: 'accounts->urlEndpoints->delete', + example: + "accounts->urlEndpoints->delete('id');\n\nvar_dump($result);", + }, + csharp: { + method: 'Accounts.UrlEndpoints.Delete', + example: + 'UrlEndpointDeleteParams parameters = new() { ID = "id" };\n\nawait client.Accounts.UrlEndpoints.Delete(parameters);', + }, + http: { + example: + 'curl https://api.imagekit.io/v1/accounts/url-endpoints/$ID \\\n -X DELETE \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS"', + }, + }, }, { - "name": "upload", - "endpoint": "/api/v2/files/upload", - "httpMethod": "post", - "summary": "Upload file V2", - "description": "The V2 API enhances security by verifying the entire payload using JWT. This API is in beta.\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) about how to implement secure client-side file upload.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files, and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n", - "stainlessPath": "(resource) beta.v2.files > (method) upload", - "qualified": "client.beta.v2.files.upload", - "params": [ - "file: string;", - "fileName: string;", - "token?: string;", - "checks?: string;", - "customCoordinates?: string;", - "customMetadata?: object;", - "description?: string;", + name: 'upload', + endpoint: '/api/v2/files/upload', + httpMethod: 'post', + summary: 'Upload file V2', + description: + 'The V2 API enhances security by verifying the entire payload using JWT. This API is in beta.\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) about how to implement secure client-side file upload.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files, and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n', + stainlessPath: '(resource) beta.v2.files > (method) upload', + qualified: 'client.beta.v2.files.upload', + params: [ + 'file: string;', + 'fileName: string;', + 'token?: string;', + 'checks?: string;', + 'customCoordinates?: string;', + 'customMetadata?: object;', + 'description?: string;', "extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[];", - "folder?: string;", - "isPrivateFile?: boolean;", - "isPublished?: boolean;", - "overwriteAITags?: boolean;", - "overwriteCustomMetadata?: boolean;", - "overwriteFile?: boolean;", - "overwriteTags?: boolean;", - "responseFields?: string[];", - "tags?: string[];", + 'folder?: string;', + 'isPrivateFile?: boolean;', + 'isPublished?: boolean;', + 'overwriteAITags?: boolean;', + 'overwriteCustomMetadata?: boolean;', + 'overwriteFile?: boolean;', + 'overwriteTags?: boolean;', + 'responseFields?: string[];', + 'tags?: string[];', "transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; };", - "useUniqueFileName?: boolean;", - "webhookUrl?: string;" + 'useUniqueFileName?: boolean;', + 'webhookUrl?: string;', ], - "response": "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", - "markdown": "## upload\n\n`client.beta.v2.files.upload(file: string, fileName: string, token?: string, checks?: string, customCoordinates?: string, customMetadata?: object, description?: string, extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[], folder?: string, isPrivateFile?: boolean, isPublished?: boolean, overwriteAITags?: boolean, overwriteCustomMetadata?: boolean, overwriteFile?: boolean, overwriteTags?: boolean, responseFields?: string[], tags?: string[], transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }, useUniqueFileName?: boolean, webhookUrl?: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: object; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: metadata; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**post** `/api/v2/files/upload`\n\nThe V2 API enhances security by verifying the entire payload using JWT. This API is in beta.\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) about how to implement secure client-side file upload.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files, and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n\n\n### Parameters\n\n- `file: string`\n The API accepts any of the following:\n\n- **Binary data** – send the raw bytes as `multipart/form-data`.\n- **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.\n- **Base64 string** – the file encoded as a Base64 data URI or plain Base64.\n\nWhen supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.\n\n\n- `fileName: string`\n The name with which the file has to be uploaded.\n\n\n- `token?: string`\n This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses it to authenticate and check that the upload request parameters have not been tampered with after the token has been generated. Learn how to create the token on the page below. This field is only required for authentication when uploading a file from the client side.\n\n\n**Note**: Sending a JWT that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new token.\n\n\n**⚠️Warning**: JWT must be generated on the server-side because it is generated using your account's private API key. This field is required for authentication when uploading a file from the client-side.\n\n\n- `checks?: string`\n Server-side checks to run on the asset.\nRead more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks).\n\n\n- `customCoordinates?: string`\n Define an important area in the image. This is only relevant for image type files.\n\n - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100`\n - Can be used with fo-customtransformation.\n - If this field is not specified and the file is overwritten, then customCoordinates will be removed.\n\n\n- `customMetadata?: object`\n JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.\n\n\n- `description?: string`\n Optional text to describe the contents of the file.\n\n\n- `extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[]`\n Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.\n\n\n- `folder?: string`\n The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created. Using multiple `/` creates a nested folder.\n\n\n- `isPrivateFile?: boolean`\n Whether to mark the file as private or not.\n\nIf `true`, the file is marked as private and is accessible only using named transformation or signed URL.\n\n\n- `isPublished?: boolean`\n Whether to upload file as published or not.\n\nIf `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published.\n\nThe option to upload in draft state is only available in custom enterprise pricing plans.\n\n\n- `overwriteAITags?: boolean`\n If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags.\n\n\n- `overwriteCustomMetadata?: boolean`\n If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed.\n\n\n- `overwriteFile?: boolean`\n If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately.\n\n\n- `overwriteTags?: boolean`\n If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed.\n\n\n- `responseFields?: string[]`\n Array of response field keys to include in the API response body.\n\n\n- `tags?: string[]`\n Set the tags while uploading the file.\nProvide an array of tag strings (e.g. `[\"tag1\", \"tag2\", \"tag3\"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed.\nIf this field is not specified and the file is overwritten, the existing tags will be removed.\n\n\n- `transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }`\n Configure pre-processing (`pre`) and post-processing (`post`) transformations.\n\n- `pre` — applied before the file is uploaded to the Media Library. \n Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress).\n\n- `post` — applied immediately after upload. \n Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay.\n\nYou can mix and match any combination of post-processing types.\n\n - `post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]`\n List of transformations to apply *after* the file is uploaded. \nEach item must match one of the following types:\n`transformation`, `gif-to-video`, `thumbnail`, `abs`.\n\n - `pre?: string`\n Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion.\n\n\n- `useUniqueFileName?: boolean`\n Whether to use a unique filename for this file or not.\n\nIf `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename.\n\nIf `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced.\n\n\n- `webhookUrl?: string`\n The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure.\n\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a successful upload.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnailUrl?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.beta.v2.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'fileName' });\n\nconsole.log(response);\n```", - "perLanguage": { - "typescript": { - "method": "client.beta.v2.files.upload", - "example": "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.beta.v2.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);" - }, - "python": { - "method": "beta.v2.files.upload", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nresponse = client.beta.v2.files.upload(\n file=b\"Example data\",\n file_name=\"fileName\",\n)\nprint(response.video_codec)" - }, - "java": { - "method": "beta().v2().files().upload", - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.beta.v2.files.FileUploadParams;\nimport io.imagekit.models.beta.v2.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream(\"Example data\".getBytes()))\n .fileName(\"fileName\")\n .build();\n FileUploadResponse response = client.beta().v2().files().upload(params);\n }\n}" - }, - "kotlin": { - "method": "beta().v2().files().upload", - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.beta.v2.files.FileUploadParams\nimport com.imagekit.api.models.beta.v2.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUploadParams = FileUploadParams.builder()\n .file(\"Example data\".byteInputStream())\n .fileName(\"fileName\")\n .build()\n val response: FileUploadResponse = client.beta().v2().files().upload(params)\n}" - }, - "go": { - "method": "client.Beta.V2.Files.Upload", - "example": "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\tresponse, err := client.Beta.V2.Files.Upload(context.TODO(), imagekit.BetaV2FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t\tFileName: \"fileName\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.VideoCodec)\n}\n" - }, - "ruby": { - "method": "beta.v2.files.upload", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresponse = image_kit.beta.v2.files.upload(file: StringIO.new(\"Example data\"), file_name: \"fileName\")\n\nputs(response)" - }, - "cli": { - "method": "files upload", - "example": "imagekit beta:v2:files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name fileName" - }, - "php": { - "method": "beta->v2->files->upload", - "example": "beta->v2->files->upload(\n file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),\n fileName: 'fileName',\n token: 'token',\n checks: \"\\\"request.folder\\\" : \\\"marketing/\\\"\\n\",\n customCoordinates: 'customCoordinates',\n customMetadata: ['brand' => 'bar', 'color' => 'bar'],\n description: 'Running shoes',\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n folder: 'folder',\n isPrivateFile: true,\n isPublished: true,\n overwriteAITags: true,\n overwriteCustomMetadata: true,\n overwriteFile: true,\n overwriteTags: true,\n responseFields: ['tags', 'customCoordinates', 'isPrivateFile'],\n tags: ['t-shirt', 'round-neck', 'men'],\n transformation: [\n 'post' => [\n ['type' => 'thumbnail', 'value' => 'w-150,h-150'],\n [\n 'protocol' => 'dash',\n 'type' => 'abs',\n 'value' => 'sr-240_360_480_720_1080',\n ],\n ],\n 'pre' => 'w-300,h-300,q-80',\n ],\n useUniqueFileName: true,\n webhookURL: 'https://example.com',\n);\n\nvar_dump($response);" - }, - "csharp": { - "method": "Beta.V2.Files.Upload", - "example": "FileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes(\"Example data\"),\n FileName = \"fileName\",\n};\n\nvar response = await client.Beta.V2.Files.Upload(parameters);\n\nConsole.WriteLine(response);" - }, - "http": { - "example": "curl https://upload.imagekit.io/api/v2/files/upload \\\n -H 'Content-Type: multipart/form-data' \\\n -u \"$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS\" \\\n -F 'file=@/path/to/file' \\\n -F fileName=fileName \\\n -F checks='\"request.folder\" : \"marketing/\"\n ' \\\n -F customMetadata='{\"brand\":\"bar\",\"color\":\"bar\"}' \\\n -F description='Running shoes' \\\n -F extensions='[{\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true}},{\"maxTags\":5,\"minConfidence\":95,\"name\":\"google-auto-tagging\"},{\"name\":\"ai-auto-description\"},{\"name\":\"ai-tasks\",\"tasks\":[{\"instruction\":\"What types of clothing items are visible in this image?\",\"type\":\"select_tags\",\"vocabulary\":[\"shirt\",\"tshirt\",\"dress\",\"trousers\",\"jacket\"]},{\"instruction\":\"Is this a luxury or high-end fashion item?\",\"type\":\"yes_no\",\"on_yes\":{\"add_tags\":[\"luxury\",\"premium\"]}}]},{\"id\":\"ext_abc123\",\"name\":\"saved-extension\"}]' \\\n -F responseFields='[\"tags\",\"customCoordinates\",\"isPrivateFile\"]' \\\n -F tags='[\"t-shirt\",\"round-neck\",\"men\"]' \\\n -F transformation='{\"post\":[{\"type\":\"thumbnail\",\"value\":\"w-150,h-150\"},{\"protocol\":\"dash\",\"type\":\"abs\",\"value\":\"sr-240_360_480_720_1080\"}]}'" - } - } + response: + "{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }", + markdown: + "## upload\n\n`client.beta.v2.files.upload(file: string, fileName: string, token?: string, checks?: string, customCoordinates?: string, customMetadata?: object, description?: string, extensions?: { name: 'remove-bg'; options?: object; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: object | object | object[]; } | { id: string; name: 'saved-extension'; }[], folder?: string, isPrivateFile?: boolean, isPublished?: boolean, overwriteAITags?: boolean, overwriteCustomMetadata?: boolean, overwriteFile?: boolean, overwriteTags?: boolean, responseFields?: string[], tags?: string[], transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }, useUniqueFileName?: boolean, webhookUrl?: string): { AITags?: object[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: object; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: metadata; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: object; videoCodec?: string; width?: number; }`\n\n**post** `/api/v2/files/upload`\n\nThe V2 API enhances security by verifying the entire payload using JWT. This API is in beta.\n\nImageKit.io allows you to upload files directly from both the server and client sides. For server-side uploads, private API key authentication is used. For client-side uploads, generate a one-time `token` from your secure backend using private API. [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) about how to implement secure client-side file upload.\n\n**File size limit** \\\nOn the free plan, the maximum upload file sizes are 25MB for images, audio, and raw files, and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further increased with enterprise plans.\n\n**Version limit** \\\nA file can have a maximum of 100 versions.\n\n**Demo applications**\n\n- A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.\n- [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.\n\n\n### Parameters\n\n- `file: string`\n The API accepts any of the following:\n\n- **Binary data** – send the raw bytes as `multipart/form-data`.\n- **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.\n- **Base64 string** – the file encoded as a Base64 data URI or plain Base64.\n\nWhen supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.\n\n\n- `fileName: string`\n The name with which the file has to be uploaded.\n\n\n- `token?: string`\n This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses it to authenticate and check that the upload request parameters have not been tampered with after the token has been generated. Learn how to create the token on the page below. This field is only required for authentication when uploading a file from the client side.\n\n\n**Note**: Sending a JWT that has been used in the past will result in a validation error. Even if your previous request resulted in an error, you should always send a new token.\n\n\n**⚠️Warning**: JWT must be generated on the server-side because it is generated using your account's private API key. This field is required for authentication when uploading a file from the client-side.\n\n\n- `checks?: string`\n Server-side checks to run on the asset.\nRead more about [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks).\n\n\n- `customCoordinates?: string`\n Define an important area in the image. This is only relevant for image type files.\n\n - To be passed as a string with the x and y coordinates of the top-left corner, and width and height of the area of interest in the format `x,y,width,height`. For example - `10,10,100,100`\n - Can be used with fo-customtransformation.\n - If this field is not specified and the file is overwritten, then customCoordinates will be removed.\n\n\n- `customMetadata?: object`\n JSON key-value pairs to associate with the asset. Create the custom metadata fields before setting these values.\n\n\n- `description?: string`\n Optional text to describe the contents of the file.\n\n\n- `extensions?: { name: 'remove-bg'; options?: { add_shadow?: boolean; bg_color?: string; bg_image_url?: string; semitransparency?: boolean; }; } | { maxTags: number; minConfidence: number; name: 'google-auto-tagging' | 'aws-auto-tagging'; } | { name: 'ai-auto-description'; } | { name: 'ai-tasks'; tasks: { instruction: string; type: 'select_tags'; max_selections?: number; min_selections?: number; vocabulary?: string[]; } | { field: string; instruction: string; type: 'select_metadata'; max_selections?: number; min_selections?: number; vocabulary?: string | number | boolean[]; } | { instruction: string; type: 'yes_no'; on_no?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_unknown?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; on_yes?: { add_tags?: string[]; remove_tags?: string[]; set_metadata?: object[]; unset_metadata?: object[]; }; }[]; } | { id: string; name: 'saved-extension'; }[]`\n Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.\n\n\n- `folder?: string`\n The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, a new folder(s) is created. Using multiple `/` creates a nested folder.\n\n\n- `isPrivateFile?: boolean`\n Whether to mark the file as private or not.\n\nIf `true`, the file is marked as private and is accessible only using named transformation or signed URL.\n\n\n- `isPublished?: boolean`\n Whether to upload file as published or not.\n\nIf `false`, the file is marked as unpublished, which restricts access to the file only via the media library. Files in draft or unpublished state can only be publicly accessed after being published.\n\nThe option to upload in draft state is only available in custom enterprise pricing plans.\n\n\n- `overwriteAITags?: boolean`\n If set to `true` and a file already exists at the exact location, its AITags will be removed. Set `overwriteAITags` to `false` to preserve AITags.\n\n\n- `overwriteCustomMetadata?: boolean`\n If the request does not have `customMetadata`, and a file already exists at the exact location, existing customMetadata will be removed.\n\n\n- `overwriteFile?: boolean`\n If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact location, upload API will return an error immediately.\n\n\n- `overwriteTags?: boolean`\n If the request does not have `tags`, and a file already exists at the exact location, existing tags will be removed.\n\n\n- `responseFields?: string[]`\n Array of response field keys to include in the API response body.\n\n\n- `tags?: string[]`\n Set the tags while uploading the file.\nProvide an array of tag strings (e.g. `[\"tag1\", \"tag2\", \"tag3\"]`). The combined length of all tag characters must not exceed 500, and the `%` character is not allowed.\nIf this field is not specified and the file is overwritten, the existing tags will be removed.\n\n\n- `transformation?: { post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]; pre?: string; }`\n Configure pre-processing (`pre`) and post-processing (`post`) transformations.\n\n- `pre` — applied before the file is uploaded to the Media Library. \n Useful for reducing file size or applying basic optimizations upfront (e.g., resize, compress).\n\n- `post` — applied immediately after upload. \n Ideal for generating transformed versions (like video encodes or thumbnails) in advance, so they're ready for delivery without delay.\n\nYou can mix and match any combination of post-processing types.\n\n - `post?: { type: 'transformation'; value: string; } | { type: 'gif-to-video'; value?: string; } | { type: 'thumbnail'; value?: string; } | { protocol: 'hls' | 'dash'; type: 'abs'; value: string; }[]`\n List of transformations to apply *after* the file is uploaded. \nEach item must match one of the following types:\n`transformation`, `gif-to-video`, `thumbnail`, `abs`.\n\n - `pre?: string`\n Transformation string to apply before uploading the file to the Media Library. Useful for optimizing files at ingestion.\n\n\n- `useUniqueFileName?: boolean`\n Whether to use a unique filename for this file or not.\n\nIf `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique filename.\n\nIf `false`, then the image is uploaded with the provided filename parameter, and any existing file with the same name is replaced.\n\n\n- `webhookUrl?: string`\n The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure.\n\n\n### Returns\n\n- `{ AITags?: { confidence?: number; name?: string; source?: string; }[]; audioCodec?: string; bitRate?: number; customCoordinates?: string; customMetadata?: object; description?: string; duration?: number; embeddedMetadata?: object; extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }; fileId?: string; filePath?: string; fileType?: string; height?: number; isPrivateFile?: boolean; isPublished?: boolean; metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: object; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }; name?: string; selectedFieldsSchema?: object; size?: number; tags?: string[]; thumbnailUrl?: string; url?: string; versionInfo?: { id?: string; name?: string; }; videoCodec?: string; width?: number; }`\n Object containing details of a successful upload.\n\n - `AITags?: { confidence?: number; name?: string; source?: string; }[]`\n - `audioCodec?: string`\n - `bitRate?: number`\n - `customCoordinates?: string`\n - `customMetadata?: object`\n - `description?: string`\n - `duration?: number`\n - `embeddedMetadata?: object`\n - `extensionStatus?: { ai-auto-description?: 'success' | 'pending' | 'failed'; ai-tasks?: 'success' | 'pending' | 'failed'; aws-auto-tagging?: 'success' | 'pending' | 'failed'; google-auto-tagging?: 'success' | 'pending' | 'failed'; remove-bg?: 'success' | 'pending' | 'failed'; }`\n - `fileId?: string`\n - `filePath?: string`\n - `fileType?: string`\n - `height?: number`\n - `isPrivateFile?: boolean`\n - `isPublished?: boolean`\n - `metadata?: { audioCodec?: string; bitRate?: number; density?: number; duration?: number; exif?: { exif?: { ApertureValue?: number; ColorSpace?: number; CreateDate?: string; CustomRendered?: number; DateTimeOriginal?: string; ExifImageHeight?: number; ExifImageWidth?: number; ExifVersion?: string; ExposureCompensation?: number; ExposureMode?: number; ExposureProgram?: number; ExposureTime?: number; Flash?: number; FlashpixVersion?: string; FNumber?: number; FocalLength?: number; FocalPlaneResolutionUnit?: number; FocalPlaneXResolution?: number; FocalPlaneYResolution?: number; InteropOffset?: number; ISO?: number; MeteringMode?: number; SceneCaptureType?: number; ShutterSpeedValue?: number; SubSecTime?: string; WhiteBalance?: number; }; gps?: { GPSVersionID?: number[]; }; image?: { ExifOffset?: number; GPSInfo?: number; Make?: string; Model?: string; ModifyDate?: string; Orientation?: number; ResolutionUnit?: number; Software?: string; XResolution?: number; YCbCrPositioning?: number; YResolution?: number; }; interoperability?: { InteropIndex?: string; InteropVersion?: string; }; makernote?: object; thumbnail?: { Compression?: number; ResolutionUnit?: number; ThumbnailLength?: number; ThumbnailOffset?: number; XResolution?: number; YResolution?: number; }; }; format?: string; hasColorProfile?: boolean; hasTransparency?: boolean; height?: number; pHash?: string; quality?: number; size?: number; videoCodec?: string; width?: number; }`\n - `name?: string`\n - `selectedFieldsSchema?: object`\n - `size?: number`\n - `tags?: string[]`\n - `thumbnailUrl?: string`\n - `url?: string`\n - `versionInfo?: { id?: string; name?: string; }`\n - `videoCodec?: string`\n - `width?: number`\n\n### Example\n\n```typescript\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\nconst response = await client.beta.v2.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'fileName' });\n\nconsole.log(response);\n```", + perLanguage: { + typescript: { + method: 'client.beta.v2.files.upload', + example: + "import fs from 'fs';\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.beta.v2.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'fileName',\n});\n\nconsole.log(response.videoCodec);", + }, + python: { + method: 'beta.v2.files.upload', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nresponse = client.beta.v2.files.upload(\n file=b"Example data",\n file_name="fileName",\n)\nprint(response.video_codec)', + }, + java: { + method: 'beta().v2().files().upload', + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.beta.v2.files.FileUploadParams;\nimport io.imagekit.models.beta.v2.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n FileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("Example data".getBytes()))\n .fileName("fileName")\n .build();\n FileUploadResponse response = client.beta().v2().files().upload(params);\n }\n}', + }, + kotlin: { + method: 'beta().v2().files().upload', + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.beta.v2.files.FileUploadParams\nimport com.imagekit.api.models.beta.v2.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: FileUploadParams = FileUploadParams.builder()\n .file("Example data".byteInputStream())\n .fileName("fileName")\n .build()\n val response: FileUploadResponse = client.beta().v2().files().upload(params)\n}', + }, + go: { + method: 'client.Beta.V2.Files.Upload', + example: + 'package main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\tresponse, err := client.Beta.V2.Files.Upload(context.TODO(), imagekit.BetaV2FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("Example data"))),\n\t\tFileName: "fileName",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n', + }, + ruby: { + method: 'beta.v2.files.upload', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresponse = image_kit.beta.v2.files.upload(file: StringIO.new("Example data"), file_name: "fileName")\n\nputs(response)', + }, + cli: { + method: 'files upload', + example: + "imagekit beta:v2:files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name fileName", + }, + php: { + method: 'beta->v2->files->upload', + example: + "beta->v2->files->upload(\n file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),\n fileName: 'fileName',\n token: 'token',\n checks: \"\\\"request.folder\\\" : \\\"marketing/\\\"\\n\",\n customCoordinates: 'customCoordinates',\n customMetadata: ['brand' => 'bar', 'color' => 'bar'],\n description: 'Running shoes',\n extensions: [\n [\n 'name' => 'remove-bg',\n 'options' => [\n 'addShadow' => true,\n 'bgColor' => 'bg_color',\n 'bgImageURL' => 'bg_image_url',\n 'semitransparency' => true,\n ],\n ],\n ['maxTags' => 5, 'minConfidence' => 95, 'name' => 'google-auto-tagging'],\n ['name' => 'ai-auto-description'],\n [\n 'name' => 'ai-tasks',\n 'tasks' => [\n [\n 'instruction' => 'What types of clothing items are visible in this image?',\n 'type' => 'select_tags',\n 'maxSelections' => 1,\n 'minSelections' => 0,\n 'vocabulary' => ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'],\n ],\n [\n 'instruction' => 'Is this a luxury or high-end fashion item?',\n 'type' => 'yes_no',\n 'onNo' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onUnknown' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n 'onYes' => [\n 'addTags' => ['luxury', 'premium'],\n 'removeTags' => ['budget', 'affordable'],\n 'setMetadata' => [['field' => 'price_range', 'value' => 'premium']],\n 'unsetMetadata' => [['field' => 'price_range']],\n ],\n ],\n ],\n ],\n ['id' => 'ext_abc123', 'name' => 'saved-extension'],\n ],\n folder: 'folder',\n isPrivateFile: true,\n isPublished: true,\n overwriteAITags: true,\n overwriteCustomMetadata: true,\n overwriteFile: true,\n overwriteTags: true,\n responseFields: ['tags', 'customCoordinates', 'isPrivateFile'],\n tags: ['t-shirt', 'round-neck', 'men'],\n transformation: [\n 'post' => [\n ['type' => 'thumbnail', 'value' => 'w-150,h-150'],\n [\n 'protocol' => 'dash',\n 'type' => 'abs',\n 'value' => 'sr-240_360_480_720_1080',\n ],\n ],\n 'pre' => 'w-300,h-300,q-80',\n ],\n useUniqueFileName: true,\n webhookURL: 'https://example.com',\n);\n\nvar_dump($response);", + }, + csharp: { + method: 'Beta.V2.Files.Upload', + example: + 'FileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes("Example data"),\n FileName = "fileName",\n};\n\nvar response = await client.Beta.V2.Files.Upload(parameters);\n\nConsole.WriteLine(response);', + }, + http: { + example: + 'curl https://upload.imagekit.io/api/v2/files/upload \\\n -H \'Content-Type: multipart/form-data\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -F \'file=@/path/to/file\' \\\n -F fileName=fileName \\\n -F checks=\'"request.folder" : "marketing/"\n \' \\\n -F customMetadata=\'{"brand":"bar","color":"bar"}\' \\\n -F description=\'Running shoes\' \\\n -F extensions=\'[{"name":"remove-bg","options":{"add_shadow":true}},{"maxTags":5,"minConfidence":95,"name":"google-auto-tagging"},{"name":"ai-auto-description"},{"name":"ai-tasks","tasks":[{"instruction":"What types of clothing items are visible in this image?","type":"select_tags","vocabulary":["shirt","tshirt","dress","trousers","jacket"]},{"instruction":"Is this a luxury or high-end fashion item?","type":"yes_no","on_yes":{"add_tags":["luxury","premium"]}}]},{"id":"ext_abc123","name":"saved-extension"}]\' \\\n -F responseFields=\'["tags","customCoordinates","isPrivateFile"]\' \\\n -F tags=\'["t-shirt","round-neck","men"]\' \\\n -F transformation=\'{"post":[{"type":"thumbnail","value":"w-150,h-150"},{"protocol":"dash","type":"abs","value":"sr-240_360_480_720_1080"}]}\'', + }, + }, }, { - "name": "unwrap", - "endpoint": "", - "httpMethod": "", - "summary": "", - "description": "", - "stainlessPath": "(resource) webhooks > (method) unwrap", - "qualified": "client.webhooks.unwrap", - "perLanguage": { - "typescript": { - "method": "client.webhooks.unwrap", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.webhooks.unwrap();" - }, - "python": { - "method": "webhooks.unwrap", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nclient.webhooks.unwrap()" - }, - "java": { - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.webhooks.WebhookUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unwrap();\n }\n}" - }, - "kotlin": { - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.webhooks.WebhookUnwrapParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.webhooks().unwrap()\n}" - }, - "go": { - "method": "client.Webhooks.Unwrap", - "example": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\terr := client.Webhooks.Unwrap(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n" - }, - "ruby": { - "method": "webhooks.unwrap", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresult = image_kit.webhooks.unwrap\n\nputs(result)" - }, - "cli": { - "example": "imagekit webhooks unwrap \\\n --private-key 'My Private Key' \\\n --password 'My Password'" - }, - "php": { - "method": "webhooks->unwrap", - "example": "webhooks->unwrap();\n\nvar_dump($result);" - }, - "csharp": { - "example": "WebhookUnwrapParams parameters = new();\n\nawait client.Webhooks.Unwrap(parameters);" - } - } + name: 'unwrap', + endpoint: '', + httpMethod: '', + summary: '', + description: '', + stainlessPath: '(resource) webhooks > (method) unwrap', + qualified: 'client.webhooks.unwrap', + perLanguage: { + typescript: { + method: 'client.webhooks.unwrap', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.webhooks.unwrap();", + }, + python: { + method: 'webhooks.unwrap', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.webhooks.unwrap()', + }, + java: { + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.webhooks.WebhookUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unwrap();\n }\n}', + }, + kotlin: { + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.webhooks.WebhookUnwrapParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.webhooks().unwrap()\n}', + }, + go: { + method: 'client.Webhooks.Unwrap', + example: + 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Webhooks.Unwrap(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', + }, + ruby: { + method: 'webhooks.unwrap', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.webhooks.unwrap\n\nputs(result)', + }, + cli: { + example: + "imagekit webhooks unwrap \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'webhooks->unwrap', + example: + "webhooks->unwrap();\n\nvar_dump($result);", + }, + csharp: { + example: 'WebhookUnwrapParams parameters = new();\n\nawait client.Webhooks.Unwrap(parameters);', + }, + }, }, { - "name": "unsafe_unwrap", - "endpoint": "", - "httpMethod": "", - "summary": "", - "description": "", - "stainlessPath": "(resource) webhooks > (method) unsafe_unwrap", - "qualified": "client.webhooks.unsafeUnwrap", - "perLanguage": { - "typescript": { - "method": "client.webhooks.unsafeUnwrap", - "example": "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.webhooks.unsafeUnwrap();" - }, - "python": { - "method": "webhooks.unsafe_unwrap", - "example": "import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\nclient.webhooks.unsafe_unwrap()" - }, - "java": { - "example": "package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.webhooks.WebhookUnsafeUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unsafeUnwrap();\n }\n}" - }, - "kotlin": { - "example": "package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.webhooks.WebhookUnsafeUnwrapParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.webhooks().unsafeUnwrap()\n}" - }, - "go": { - "method": "client.Webhooks.UnsafeUnwrap", - "example": "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"),\n\t\toption.WithPassword(\"My Password\"),\n\t)\n\terr := client.Webhooks.UnsafeUnwrap(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n" - }, - "ruby": { - "method": "webhooks.unsafe_unwrap", - "example": "require \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(private_key: \"My Private Key\", password: \"My Password\")\n\nresult = image_kit.webhooks.unsafe_unwrap\n\nputs(result)" - }, - "cli": { - "example": "imagekit webhooks unsafe-unwrap \\\n --private-key 'My Private Key' \\\n --password 'My Password'" - }, - "php": { - "method": "webhooks->unsafeUnwrap", - "example": "webhooks->unsafeUnwrap();\n\nvar_dump($result);" - }, - "csharp": { - "example": "WebhookUnsafeUnwrapParams parameters = new();\n\nawait client.Webhooks.UnsafeUnwrap(parameters);" - } - } - } + name: 'unsafe_unwrap', + endpoint: '', + httpMethod: '', + summary: '', + description: '', + stainlessPath: '(resource) webhooks > (method) unsafe_unwrap', + qualified: 'client.webhooks.unsafeUnwrap', + perLanguage: { + typescript: { + method: 'client.webhooks.unsafeUnwrap', + example: + "import ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nawait client.webhooks.unsafeUnwrap();", + }, + python: { + method: 'webhooks.unsafe_unwrap', + example: + 'import os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\nclient.webhooks.unsafe_unwrap()', + }, + java: { + example: + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.webhooks.WebhookUnsafeUnwrapParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n client.webhooks().unsafeUnwrap();\n }\n}', + }, + kotlin: { + example: + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.webhooks.WebhookUnsafeUnwrapParams\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n client.webhooks().unsafeUnwrap()\n}', + }, + go: { + method: 'client.Webhooks.UnsafeUnwrap', + example: + 'package main\n\nimport (\n\t"context"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"),\n\t\toption.WithPassword("My Password"),\n\t)\n\terr := client.Webhooks.UnsafeUnwrap(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', + }, + ruby: { + method: 'webhooks.unsafe_unwrap', + example: + 'require "imagekitio"\n\nimage_kit = Imagekitio::Client.new(private_key: "My Private Key", password: "My Password")\n\nresult = image_kit.webhooks.unsafe_unwrap\n\nputs(result)', + }, + cli: { + example: + "imagekit webhooks unsafe-unwrap \\\n --private-key 'My Private Key' \\\n --password 'My Password'", + }, + php: { + method: 'webhooks->unsafeUnwrap', + example: + "webhooks->unsafeUnwrap();\n\nvar_dump($result);", + }, + csharp: { + example: + 'WebhookUnsafeUnwrapParams parameters = new();\n\nawait client.Webhooks.UnsafeUnwrap(parameters);', + }, + }, + }, ]; const EMBEDDED_READMES: { language: string; content: string }[] = [ { - "language": "cli", - "content": "# Image Kit CLI\n\nThe official CLI for the [Image Kit REST API](https://imagekit.io/docs/api-reference).\n\n## Installation\n\n### Installing with Go\n\nTo test or install the CLI locally, you need [Go](https://go.dev/doc/install) version 1.22 or later installed.\n\n~~~sh\ngo install 'github.com/stainless-sdks/imagekit-cli/cmd/imagekit@latest'\n~~~\n\nOnce you have run `go install`, the binary is placed in your Go bin directory:\n\n- **Default location**: `$HOME/go/bin` (or `$GOPATH/bin` if GOPATH is set)\n- **Check your path**: Run `go env GOPATH` to see the base directory\n\nIf commands aren't found after installation, add the Go bin directory to your PATH:\n\n~~~sh\n# Add to your shell profile (.zshrc, .bashrc, etc.)\nexport PATH=\"$PATH:$(go env GOPATH)/bin\"\n~~~\n\n### Running Locally\n\nAfter cloning the git repository for this project, you can use the\n`scripts/run` script to run the tool locally:\n\n~~~sh\n./scripts/run args...\n~~~\n\n## Usage\n\nThe CLI follows a resource-based command structure:\n\n~~~sh\nimagekit [resource] [flags...]\n~~~\n\n~~~sh\nimagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name file-name.jpg\n~~~\n\nFor details about specific commands, use the `--help` flag.\n\n### Environment variables\n\n| Environment variable | Description | Required | Default value |\n| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------- |\n| `IMAGEKIT_PRIVATE_KEY` | Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n | yes | |\n| `OPTIONAL_IMAGEKIT_IGNORES_THIS` | ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n | no | `\"do_not_set\"` |\n| `IMAGEKIT_WEBHOOK_SECRET` | Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n | no | `null` |\n\n### Global flags\n\n- `--private-key` - Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n (can also be set with `IMAGEKIT_PRIVATE_KEY` env var)\n- `--password` - ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n (can also be set with `OPTIONAL_IMAGEKIT_IGNORES_THIS` env var)\n- `--webhook-secret` - Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n (can also be set with `IMAGEKIT_WEBHOOK_SECRET` env var)\n- `--help` - Show command line usage\n- `--debug` - Enable debug logging (includes HTTP request/response details)\n- `--version`, `-v` - Show the CLI version\n- `--base-url` - Use a custom API backend URL\n- `--format` - Change the output format (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--format-error` - Change the output format for errors (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--transform` - Transform the data output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n- `--transform-error` - Transform the error output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n\n### Passing files as arguments\n\nTo pass files to your API, you can use the `@myfile.ext` syntax:\n\n~~~bash\nimagekit --arg @abe.jpg\n~~~\n\nFiles can also be passed inside JSON or YAML blobs:\n\n~~~bash\nimagekit --arg '{image: \"@abe.jpg\"}'\n# Equivalent:\nimagekit < --username '\\@abe'\n~~~\n\n#### Explicit encoding\n\nFor JSON endpoints, the CLI tool does filetype sniffing to determine whether the\nfile contents should be sent as a string literal (for plain text files) or as a\nbase64-encoded string literal (for binary files). If you need to explicitly send\nthe file as either plain text or base64-encoded data, you can use\n`@file://myfile.txt` (for string encoding) or `@data://myfile.dat` (for\nbase64-encoding). Note that absolute paths will begin with `@file://` or\n`@data://`, followed by a third `/` (for example, `@file:///tmp/file.txt`).\n\n~~~bash\nimagekit --arg @data://file.txt\n~~~\n\n## Linking different Go SDK versions\n\nYou can link the CLI against a different version of the Image Kit Go SDK\nfor development purposes using the `./scripts/link` script.\n\nTo link to a specific version from a repository (version can be a branch,\ngit tag, or commit hash):\n\n~~~bash\n./scripts/link github.com/org/repo@version\n~~~\n\nTo link to a local copy of the SDK:\n\n~~~bash\n./scripts/link ../path/to/imagekit-go\n~~~\n\nIf you run the link script without any arguments, it will default to `../imagekit-go`.\n" + language: 'cli', + content: + "# Image Kit CLI\n\nThe official CLI for the [Image Kit REST API](https://imagekit.io/docs/api-reference).\n\n## Installation\n\n### Installing with Go\n\nTo test or install the CLI locally, you need [Go](https://go.dev/doc/install) version 1.22 or later installed.\n\n~~~sh\ngo install 'github.com/stainless-sdks/imagekit-cli/cmd/imagekit@latest'\n~~~\n\nOnce you have run `go install`, the binary is placed in your Go bin directory:\n\n- **Default location**: `$HOME/go/bin` (or `$GOPATH/bin` if GOPATH is set)\n- **Check your path**: Run `go env GOPATH` to see the base directory\n\nIf commands aren't found after installation, add the Go bin directory to your PATH:\n\n~~~sh\n# Add to your shell profile (.zshrc, .bashrc, etc.)\nexport PATH=\"$PATH:$(go env GOPATH)/bin\"\n~~~\n\n### Running Locally\n\nAfter cloning the git repository for this project, you can use the\n`scripts/run` script to run the tool locally:\n\n~~~sh\n./scripts/run args...\n~~~\n\n## Usage\n\nThe CLI follows a resource-based command structure:\n\n~~~sh\nimagekit [resource] [flags...]\n~~~\n\n~~~sh\nimagekit files upload \\\n --private-key 'My Private Key' \\\n --password 'My Password' \\\n --file 'Example data' \\\n --file-name file-name.jpg\n~~~\n\nFor details about specific commands, use the `--help` flag.\n\n### Environment variables\n\n| Environment variable | Description | Required | Default value |\n| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------- |\n| `IMAGEKIT_PRIVATE_KEY` | Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n | yes | |\n| `OPTIONAL_IMAGEKIT_IGNORES_THIS` | ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n | no | `\"do_not_set\"` |\n| `IMAGEKIT_WEBHOOK_SECRET` | Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n | no | `null` |\n\n### Global flags\n\n- `--private-key` - Your ImageKit private API key (starts with `private_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n (can also be set with `IMAGEKIT_PRIVATE_KEY` env var)\n- `--password` - ImageKit uses your API key as username and ignores the password. \nThe SDK sets a dummy value. You can ignore this field.\n (can also be set with `OPTIONAL_IMAGEKIT_IGNORES_THIS` env var)\n- `--webhook-secret` - Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n (can also be set with `IMAGEKIT_WEBHOOK_SECRET` env var)\n- `--help` - Show command line usage\n- `--debug` - Enable debug logging (includes HTTP request/response details)\n- `--version`, `-v` - Show the CLI version\n- `--base-url` - Use a custom API backend URL\n- `--format` - Change the output format (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--format-error` - Change the output format for errors (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`)\n- `--transform` - Transform the data output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n- `--transform-error` - Transform the error output using [GJSON syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md)\n\n### Passing files as arguments\n\nTo pass files to your API, you can use the `@myfile.ext` syntax:\n\n~~~bash\nimagekit --arg @abe.jpg\n~~~\n\nFiles can also be passed inside JSON or YAML blobs:\n\n~~~bash\nimagekit --arg '{image: \"@abe.jpg\"}'\n# Equivalent:\nimagekit < --username '\\@abe'\n~~~\n\n#### Explicit encoding\n\nFor JSON endpoints, the CLI tool does filetype sniffing to determine whether the\nfile contents should be sent as a string literal (for plain text files) or as a\nbase64-encoded string literal (for binary files). If you need to explicitly send\nthe file as either plain text or base64-encoded data, you can use\n`@file://myfile.txt` (for string encoding) or `@data://myfile.dat` (for\nbase64-encoding). Note that absolute paths will begin with `@file://` or\n`@data://`, followed by a third `/` (for example, `@file:///tmp/file.txt`).\n\n~~~bash\nimagekit --arg @data://file.txt\n~~~\n\n## Linking different Go SDK versions\n\nYou can link the CLI against a different version of the Image Kit Go SDK\nfor development purposes using the `./scripts/link` script.\n\nTo link to a specific version from a repository (version can be a branch,\ngit tag, or commit hash):\n\n~~~bash\n./scripts/link github.com/org/repo@version\n~~~\n\nTo link to a local copy of the SDK:\n\n~~~bash\n./scripts/link ../path/to/imagekit-go\n~~~\n\nIf you run the link script without any arguments, it will default to `../imagekit-go`.\n", }, { - "language": "csharp", - "content": "# Image Kit C# API Library\n\nThe Image Kit C# SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in C#.\n\n## Installation\n\n```bash\ngit clone git@github.com:stainless-sdks/imagekit-csharp.git\ndotnet add reference imagekit-csharp/src/ImageKit\n```\n\n## Requirements\n\nThis library requires .NET Standard 2.0 or later.\n\n## Usage\n\nSee the [`examples`](examples) directory for complete and runnable examples.\n\n```csharp\nImageKitClient client = new();\n\nFileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes(\"https://www.example.com/public-url.jpg\"),\n FileName = \"file-name.jpg\",\n};\n\nvar response = await client.Files.Upload(parameters);\n\nConsole.WriteLine(response);\n```" + language: 'csharp', + content: + '# Image Kit C# API Library\n\nThe Image Kit C# SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in C#.\n\n## Installation\n\n```bash\ngit clone git@github.com:stainless-sdks/imagekit-csharp.git\ndotnet add reference imagekit-csharp/src/ImageKit\n```\n\n## Requirements\n\nThis library requires .NET Standard 2.0 or later.\n\n## Usage\n\nSee the [`examples`](examples) directory for complete and runnable examples.\n\n```csharp\nImageKitClient client = new();\n\nFileUploadParams parameters = new()\n{\n File = Encoding.UTF8.GetBytes("https://www.example.com/public-url.jpg"),\n FileName = "file-name.jpg",\n};\n\nvar response = await client.Files.Upload(parameters);\n\nConsole.WriteLine(response);\n```', }, { - "language": "go", - "content": "# Image Kit Go API Library\n\n\"Go\n\nThe Image Kit Go library provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference)\nfrom applications written in Go.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n\n\n```go\nimport (\n\t\"github.com/imagekit-developer/imagekit-go\" // imported as SDK_PackageName\n)\n```\n\n\n\nOr to pin the version:\n\n\n\n```sh\ngo get -u 'github.com/imagekit-developer/imagekit-go@v0.0.1'\n```\n\n\n\n## Requirements\n\nThis library requires Go 1.22+.\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```go\npackage main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/imagekit-developer/imagekit-go\"\n\t\"github.com/imagekit-developer/imagekit-go/option\"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey(\"My Private Key\"), // defaults to os.LookupEnv(\"IMAGEKIT_PRIVATE_KEY\")\n\t\toption.WithPassword(\"My Password\"), // defaults to os.LookupEnv(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\")\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"https://www.example.com/public-url.jpg\"))),\n\t\tFileName: \"file-name.jpg\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.VideoCodec)\n}\n\n```\n\n### Request fields\n\nAll request parameters are wrapped in a generic `Field` type,\nwhich we use to distinguish zero values from null or omitted fields.\n\nThis prevents accidentally sending a zero value if you forget a required parameter,\nand enables explicitly sending `null`, `false`, `''`, or `0` on optional parameters.\nAny field not specified is not sent.\n\nTo construct fields with values, use the helpers `String()`, `Int()`, `Float()`, or most commonly, the generic `F[T]()`.\nTo send a null, use `Null[T]()`, and to send a nonconforming value, use `Raw[T](any)`. For example:\n\n```go\nparams := FooParams{\n\tName: SDK_PackageName.F(\"hello\"),\n\n\t// Explicitly send `\"description\": null`\n\tDescription: SDK_PackageName.Null[string](),\n\n\tPoint: SDK_PackageName.F(SDK_PackageName.Point{\n\t\tX: SDK_PackageName.Int(0),\n\t\tY: SDK_PackageName.Int(1),\n\n\t\t// In cases where the API specifies a given type,\n\t\t// but you want to send something else, use `Raw`:\n\t\tZ: SDK_PackageName.Raw[int64](0.01), // sends a float\n\t}),\n}\n```\n\n### Response objects\n\nAll fields in response structs are value types (not pointers or wrappers).\n\nIf a given field is `null`, not present, or invalid, the corresponding field\nwill simply be its zero value.\n\nAll response structs also include a special `JSON` field, containing more detailed\ninformation about each property, which you can use like so:\n\n```go\nif res.Name == \"\" {\n\t// true if `\"name\"` is either not present or explicitly null\n\tres.JSON.Name.IsNull()\n\n\t// true if the `\"name\"` key was not present in the response JSON at all\n\tres.JSON.Name.IsMissing()\n\n\t// When the API returns data that cannot be coerced to the expected type:\n\tif res.JSON.Name.IsInvalid() {\n\t\traw := res.JSON.Name.Raw()\n\n\t\tlegacyName := struct{\n\t\t\tFirst string `json:\"first\"`\n\t\t\tLast string `json:\"last\"`\n\t\t}{}\n\t\tjson.Unmarshal([]byte(raw), &legacyName)\n\t\tname = legacyName.First + \" \" + legacyName.Last\n\t}\n}\n```\n\nThese `.JSON` structs also include an `Extras` map containing\nany properties in the json response that were not specified\nin the struct. This can be useful for API features not yet\npresent in the SDK.\n\n```go\nbody := res.JSON.ExtraFields[\"my_unexpected_field\"].Raw()\n```\n\n### RequestOptions\n\nThis library uses the functional options pattern. Functions defined in the\n`SDK_PackageOptionName` package return a `RequestOption`, which is a closure that mutates a\n`RequestConfig`. These options can be supplied to the client or at individual\nrequests. For example:\n\n```go\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\t// Adds a header to every request made by the client\n\tSDK_PackageOptionName.WithHeader(\"X-Some-Header\", \"custom_header_info\"),\n)\n\nclient.Files.Upload(context.TODO(), ...,\n\t// Override the header\n\tSDK_PackageOptionName.WithHeader(\"X-Some-Header\", \"some_other_custom_header_info\"),\n\t// Add an undocumented field to the request body, using sjson syntax\n\tSDK_PackageOptionName.WithJSONSet(\"some.json.path\", map[string]string{\"my\": \"object\"}),\n)\n```\n\nSee the [full list of request options](https://pkg.go.dev/github.com/imagekit-developer/imagekit-go/SDK_PackageOptionName).\n\n### Pagination\n\nThis library provides some conveniences for working with paginated list endpoints.\n\nYou can use `.ListAutoPaging()` methods to iterate through items across all pages:\n\n\n\nOr you can use simple `.List()` methods to fetch a single page and receive a standard response object\nwith additional helper methods like `.GetNextPage()`, e.g.:\n\n\n\n### Errors\n\nWhen the API returns a non-success status code, we return an error with type\n`*SDK_PackageName.Error`. This contains the `StatusCode`, `*http.Request`, and\n`*http.Response` values of the request, as well as the JSON of the error body\n(much like other response objects in the SDK).\n\nTo handle errors, we recommend that you use the `errors.As` pattern:\n\n```go\n_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\tFile: io.Reader(bytes.NewBuffer([]byte(\"https://www.example.com/public-url.jpg\"))),\n\tFileName: \"file-name.jpg\",\n})\nif err != nil {\n\tvar apierr *imagekit.Error\n\tif errors.As(err, &apierr) {\n\t\tprintln(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request\n\t\tprintln(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response\n\t}\n\tpanic(err.Error()) // GET \"/api/v1/files/upload\": 400 Bad Request { ... }\n}\n```\n\nWhen other errors occur, they are returned unwrapped; for example,\nif HTTP transport fails, you might receive `*url.Error` wrapping `*net.OpError`.\n\n### Timeouts\n\nRequests do not time out by default; use context to configure a timeout for a request lifecycle.\n\nNote that if a request is [retried](#retries), the context timeout does not start over.\nTo set a per-retry timeout, use `SDK_PackageOptionName.WithRequestTimeout()`.\n\n```go\n// This sets the timeout for the request, including all the retries.\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\nclient.Files.Upload(\n\tctx,\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"https://www.example.com/public-url.jpg\"))),\n\t\tFileName: \"file-name.jpg\",\n\t},\n\t// This sets the per-retry timeout\n\toption.WithRequestTimeout(20*time.Second),\n)\n```\n\n### File uploads\n\nRequest parameters that correspond to file uploads in multipart requests are typed as\n`param.Field[io.Reader]`. The contents of the `io.Reader` will by default be sent as a multipart form\npart with the file name of \"anonymous_file\" and content-type of \"application/octet-stream\".\n\nThe file name and content-type can be customized by implementing `Name() string` or `ContentType()\nstring` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a\nfile returned by `os.Open` will be sent with the file name on disk.\n\nWe also provide a helper `SDK_PackageName.FileParam(reader io.Reader, filename string, contentType string)`\nwhich can be used to wrap any `io.Reader` with the appropriate file name and content type.\n\n```go\n// A file from the file system\nfile, err := os.Open(\"/path/to/file\")\nimagekit.FileUploadParams{\n\tFile: file,\n\tFileName: \"fileName\",\n}\n\n// A file from a string\nimagekit.FileUploadParams{\n\tFile: strings.NewReader(\"my file contents\"),\n\tFileName: \"fileName\",\n}\n\n// With a custom filename and contentType\nimagekit.FileUploadParams{\n\tFile: imagekit.NewFile(strings.NewReader(`{\"hello\": \"foo\"}`), \"file.go\", \"application/json\"),\n\tFileName: \"fileName\",\n}\n```\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nWe retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit,\nand >=500 Internal errors.\n\nYou can use the `WithMaxRetries` option to configure or disable this:\n\n```go\n// Configure the default for all requests:\nclient := imagekit.NewClient(\n\toption.WithMaxRetries(0), // default is 2\n)\n\n// Override per-request:\nclient.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"https://www.example.com/public-url.jpg\"))),\n\t\tFileName: \"file-name.jpg\",\n\t},\n\toption.WithMaxRetries(5),\n)\n```\n\n\n### Accessing raw response data (e.g. response headers)\n\nYou can access the raw HTTP response data by using the `option.WithResponseInto()` request option. This is useful when\nyou need to examine response headers, status codes, or other details.\n\n```go\n// Create a variable to store the HTTP response\nvar response *http.Response\nresponse, err := client.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"https://www.example.com/public-url.jpg\"))),\n\t\tFileName: \"file-name.jpg\",\n\t},\n\toption.WithResponseInto(&response),\n)\nif err != nil {\n\t// handle error\n}\nfmt.Printf(\"%+v\\n\", response)\n\nfmt.Printf(\"Status Code: %d\\n\", response.StatusCode)\nfmt.Printf(\"Headers: %+#v\\n\", response.Header)\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.Get`, `client.Post`, and other HTTP verbs.\n`RequestOptions` on the client, such as retries, will be respected when making these requests.\n\n```go\nvar (\n // params can be an io.Reader, a []byte, an encoding/json serializable object,\n // or a \"…Params\" struct defined in this library.\n params map[string]interface{}\n\n // result can be an []byte, *http.Response, a encoding/json deserializable object,\n // or a model defined in this library.\n result *http.Response\n)\nerr := client.Post(context.Background(), \"/unspecified\", params, &result)\nif err != nil {\n …\n}\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use either the `SDK_PackageOptionName.WithQuerySet()`\nor the `SDK_PackageOptionName.WithJSONSet()` methods.\n\n```go\nparams := FooNewParams{\n ID: SDK_PackageName.F(\"id_xxxx\"),\n Data: SDK_PackageName.F(FooNewParamsData{\n FirstName: SDK_PackageName.F(\"John\"),\n }),\n}\nclient.Foo.New(context.Background(), params, SDK_PackageOptionName.WithJSONSet(\"data.last_name\", \"Doe\"))\n```\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may either access the raw JSON of the response as a string\nwith `result.JSON.RawJSON()`, or get the raw JSON of a particular field on the result with\n`result.JSON.Foo.Raw()`.\n\nAny fields that are not present on the response struct will be saved and can be accessed by `result.JSON.ExtraFields()` which returns the extra fields as a `map[string]Field`.\n\n### Middleware\n\nWe provide `SDK_PackageOptionName.WithMiddleware` which applies the given\nmiddleware to requests.\n\n```go\nfunc Logger(req *http.Request, next SDK_PackageOptionName.MiddlewareNext) (res *http.Response, err error) {\n\t// Before the request\n\tstart := time.Now()\n\tLogReq(req)\n\n\t// Forward the request to the next handler\n\tres, err = next(req)\n\n\t// Handle stuff after the request\n\tend := time.Now()\n\tLogRes(res, err, start - end)\n\n return res, err\n}\n\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\tSDK_PackageOptionName.WithMiddleware(Logger),\n)\n```\n\nWhen multiple middlewares are provided as variadic arguments, the middlewares\nare applied left to right. If `SDK_PackageOptionName.WithMiddleware` is given\nmultiple times, for example first in the client then the method, the\nmiddleware in the client will run first and the middleware given in the method\nwill run next.\n\nYou may also replace the default `http.Client` with\n`SDK_PackageOptionName.WithHTTPClient(client)`. Only one http client is\naccepted (this overwrites any previous client) and receives requests after any\nmiddleware has been applied.\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-go/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n" + language: 'go', + content: + '# Image Kit Go API Library\n\nGo Reference\n\nThe Image Kit Go library provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference)\nfrom applications written in Go.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n\n\n```go\nimport (\n\t"github.com/imagekit-developer/imagekit-go" // imported as SDK_PackageName\n)\n```\n\n\n\nOr to pin the version:\n\n\n\n```sh\ngo get -u \'github.com/imagekit-developer/imagekit-go@v0.0.1\'\n```\n\n\n\n## Requirements\n\nThis library requires Go 1.22+.\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```go\npackage main\n\nimport (\n\t"bytes"\n\t"context"\n\t"fmt"\n\t"io"\n\n\t"github.com/imagekit-developer/imagekit-go"\n\t"github.com/imagekit-developer/imagekit-go/option"\n)\n\nfunc main() {\n\tclient := imagekit.NewClient(\n\t\toption.WithPrivateKey("My Private Key"), // defaults to os.LookupEnv("IMAGEKIT_PRIVATE_KEY")\n\t\toption.WithPassword("My Password"), // defaults to os.LookupEnv("OPTIONAL_IMAGEKIT_IGNORES_THIS")\n\t)\n\tresponse, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.VideoCodec)\n}\n\n```\n\n### Request fields\n\nAll request parameters are wrapped in a generic `Field` type,\nwhich we use to distinguish zero values from null or omitted fields.\n\nThis prevents accidentally sending a zero value if you forget a required parameter,\nand enables explicitly sending `null`, `false`, `\'\'`, or `0` on optional parameters.\nAny field not specified is not sent.\n\nTo construct fields with values, use the helpers `String()`, `Int()`, `Float()`, or most commonly, the generic `F[T]()`.\nTo send a null, use `Null[T]()`, and to send a nonconforming value, use `Raw[T](any)`. For example:\n\n```go\nparams := FooParams{\n\tName: SDK_PackageName.F("hello"),\n\n\t// Explicitly send `"description": null`\n\tDescription: SDK_PackageName.Null[string](),\n\n\tPoint: SDK_PackageName.F(SDK_PackageName.Point{\n\t\tX: SDK_PackageName.Int(0),\n\t\tY: SDK_PackageName.Int(1),\n\n\t\t// In cases where the API specifies a given type,\n\t\t// but you want to send something else, use `Raw`:\n\t\tZ: SDK_PackageName.Raw[int64](0.01), // sends a float\n\t}),\n}\n```\n\n### Response objects\n\nAll fields in response structs are value types (not pointers or wrappers).\n\nIf a given field is `null`, not present, or invalid, the corresponding field\nwill simply be its zero value.\n\nAll response structs also include a special `JSON` field, containing more detailed\ninformation about each property, which you can use like so:\n\n```go\nif res.Name == "" {\n\t// true if `"name"` is either not present or explicitly null\n\tres.JSON.Name.IsNull()\n\n\t// true if the `"name"` key was not present in the response JSON at all\n\tres.JSON.Name.IsMissing()\n\n\t// When the API returns data that cannot be coerced to the expected type:\n\tif res.JSON.Name.IsInvalid() {\n\t\traw := res.JSON.Name.Raw()\n\n\t\tlegacyName := struct{\n\t\t\tFirst string `json:"first"`\n\t\t\tLast string `json:"last"`\n\t\t}{}\n\t\tjson.Unmarshal([]byte(raw), &legacyName)\n\t\tname = legacyName.First + " " + legacyName.Last\n\t}\n}\n```\n\nThese `.JSON` structs also include an `Extras` map containing\nany properties in the json response that were not specified\nin the struct. This can be useful for API features not yet\npresent in the SDK.\n\n```go\nbody := res.JSON.ExtraFields["my_unexpected_field"].Raw()\n```\n\n### RequestOptions\n\nThis library uses the functional options pattern. Functions defined in the\n`SDK_PackageOptionName` package return a `RequestOption`, which is a closure that mutates a\n`RequestConfig`. These options can be supplied to the client or at individual\nrequests. For example:\n\n```go\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\t// Adds a header to every request made by the client\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "custom_header_info"),\n)\n\nclient.Files.Upload(context.TODO(), ...,\n\t// Override the header\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "some_other_custom_header_info"),\n\t// Add an undocumented field to the request body, using sjson syntax\n\tSDK_PackageOptionName.WithJSONSet("some.json.path", map[string]string{"my": "object"}),\n)\n```\n\nSee the [full list of request options](https://pkg.go.dev/github.com/imagekit-developer/imagekit-go/SDK_PackageOptionName).\n\n### Pagination\n\nThis library provides some conveniences for working with paginated list endpoints.\n\nYou can use `.ListAutoPaging()` methods to iterate through items across all pages:\n\n\n\nOr you can use simple `.List()` methods to fetch a single page and receive a standard response object\nwith additional helper methods like `.GetNextPage()`, e.g.:\n\n\n\n### Errors\n\nWhen the API returns a non-success status code, we return an error with type\n`*SDK_PackageName.Error`. This contains the `StatusCode`, `*http.Request`, and\n`*http.Response` values of the request, as well as the JSON of the error body\n(much like other response objects in the SDK).\n\nTo handle errors, we recommend that you use the `errors.As` pattern:\n\n```go\n_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{\n\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\tFileName: "file-name.jpg",\n})\nif err != nil {\n\tvar apierr *imagekit.Error\n\tif errors.As(err, &apierr) {\n\t\tprintln(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request\n\t\tprintln(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response\n\t}\n\tpanic(err.Error()) // GET "/api/v1/files/upload": 400 Bad Request { ... }\n}\n```\n\nWhen other errors occur, they are returned unwrapped; for example,\nif HTTP transport fails, you might receive `*url.Error` wrapping `*net.OpError`.\n\n### Timeouts\n\nRequests do not time out by default; use context to configure a timeout for a request lifecycle.\n\nNote that if a request is [retried](#retries), the context timeout does not start over.\nTo set a per-retry timeout, use `SDK_PackageOptionName.WithRequestTimeout()`.\n\n```go\n// This sets the timeout for the request, including all the retries.\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\nclient.Files.Upload(\n\tctx,\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\t// This sets the per-retry timeout\n\toption.WithRequestTimeout(20*time.Second),\n)\n```\n\n### File uploads\n\nRequest parameters that correspond to file uploads in multipart requests are typed as\n`param.Field[io.Reader]`. The contents of the `io.Reader` will by default be sent as a multipart form\npart with the file name of "anonymous_file" and content-type of "application/octet-stream".\n\nThe file name and content-type can be customized by implementing `Name() string` or `ContentType()\nstring` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a\nfile returned by `os.Open` will be sent with the file name on disk.\n\nWe also provide a helper `SDK_PackageName.FileParam(reader io.Reader, filename string, contentType string)`\nwhich can be used to wrap any `io.Reader` with the appropriate file name and content type.\n\n```go\n// A file from the file system\nfile, err := os.Open("/path/to/file")\nimagekit.FileUploadParams{\n\tFile: file,\n\tFileName: "fileName",\n}\n\n// A file from a string\nimagekit.FileUploadParams{\n\tFile: strings.NewReader("my file contents"),\n\tFileName: "fileName",\n}\n\n// With a custom filename and contentType\nimagekit.FileUploadParams{\n\tFile: imagekit.NewFile(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"),\n\tFileName: "fileName",\n}\n```\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nWe retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit,\nand >=500 Internal errors.\n\nYou can use the `WithMaxRetries` option to configure or disable this:\n\n```go\n// Configure the default for all requests:\nclient := imagekit.NewClient(\n\toption.WithMaxRetries(0), // default is 2\n)\n\n// Override per-request:\nclient.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithMaxRetries(5),\n)\n```\n\n\n### Accessing raw response data (e.g. response headers)\n\nYou can access the raw HTTP response data by using the `option.WithResponseInto()` request option. This is useful when\nyou need to examine response headers, status codes, or other details.\n\n```go\n// Create a variable to store the HTTP response\nvar response *http.Response\nresponse, err := client.Files.Upload(\n\tcontext.TODO(),\n\timagekit.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),\n\t\tFileName: "file-name.jpg",\n\t},\n\toption.WithResponseInto(&response),\n)\nif err != nil {\n\t// handle error\n}\nfmt.Printf("%+v\\n", response)\n\nfmt.Printf("Status Code: %d\\n", response.StatusCode)\nfmt.Printf("Headers: %+#v\\n", response.Header)\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.Get`, `client.Post`, and other HTTP verbs.\n`RequestOptions` on the client, such as retries, will be respected when making these requests.\n\n```go\nvar (\n // params can be an io.Reader, a []byte, an encoding/json serializable object,\n // or a "…Params" struct defined in this library.\n params map[string]interface{}\n\n // result can be an []byte, *http.Response, a encoding/json deserializable object,\n // or a model defined in this library.\n result *http.Response\n)\nerr := client.Post(context.Background(), "/unspecified", params, &result)\nif err != nil {\n …\n}\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use either the `SDK_PackageOptionName.WithQuerySet()`\nor the `SDK_PackageOptionName.WithJSONSet()` methods.\n\n```go\nparams := FooNewParams{\n ID: SDK_PackageName.F("id_xxxx"),\n Data: SDK_PackageName.F(FooNewParamsData{\n FirstName: SDK_PackageName.F("John"),\n }),\n}\nclient.Foo.New(context.Background(), params, SDK_PackageOptionName.WithJSONSet("data.last_name", "Doe"))\n```\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may either access the raw JSON of the response as a string\nwith `result.JSON.RawJSON()`, or get the raw JSON of a particular field on the result with\n`result.JSON.Foo.Raw()`.\n\nAny fields that are not present on the response struct will be saved and can be accessed by `result.JSON.ExtraFields()` which returns the extra fields as a `map[string]Field`.\n\n### Middleware\n\nWe provide `SDK_PackageOptionName.WithMiddleware` which applies the given\nmiddleware to requests.\n\n```go\nfunc Logger(req *http.Request, next SDK_PackageOptionName.MiddlewareNext) (res *http.Response, err error) {\n\t// Before the request\n\tstart := time.Now()\n\tLogReq(req)\n\n\t// Forward the request to the next handler\n\tres, err = next(req)\n\n\t// Handle stuff after the request\n\tend := time.Now()\n\tLogRes(res, err, start - end)\n\n return res, err\n}\n\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\tSDK_PackageOptionName.WithMiddleware(Logger),\n)\n```\n\nWhen multiple middlewares are provided as variadic arguments, the middlewares\nare applied left to right. If `SDK_PackageOptionName.WithMiddleware` is given\nmultiple times, for example first in the client then the method, the\nmiddleware in the client will run first and the middleware given in the method\nwill run next.\n\nYou may also replace the default `http.Client` with\n`SDK_PackageOptionName.WithHTTPClient(client)`. Only one http client is\naccepted (this overwrites any previous client) and receives requests after any\nmiddleware has been applied.\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-go/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', }, { - "language": "java", - "content": "# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation(\"io.imagekit:image-kit-java:0.0.1\")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream(\"https://www.example.com/public-url.jpg\".getBytes()))\n .fileName(\"file-name.jpg\")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey(\"My Private Key\")\n .password(\"My Password\")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey(\"My Private Key\")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `\"do_not_set\"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `\"https://api.imagekit.io\"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don't create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl(\"https://example.com\");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream(\"https://www.example.com/public-url.jpg\".getBytes()))\n .fileName(\"file-name.jpg\")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.client.ImageKitClientAsync;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream(\"https://www.example.com/public-url.jpg\".getBytes()))\n .fileName(\"file-name.jpg\")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(Paths.get(\"/path/to/file\"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(new URL(\"https://example.com//path/to/file\").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(\"content\".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.MultipartField;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(MultipartField.builder()\n .value(new URL(\"https://example.com//path/to/file\").openStream())\n .filename(\"/path/to/file\")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don't provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.core.http.Headers;\nimport io.imagekit.core.http.HttpResponseFor;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream(\"https://www.example.com/public-url.jpg\".getBytes()))\n .fileName(\"file-name.jpg\")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don't work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n \"https://example.com\", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp's default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader(\"Secret-Header\", \"42\")\n .putAdditionalQueryParam(\"secret_query_param\", \"42\")\n .putAdditionalBodyProperty(\"secretProperty\", JsonValue.from(\"42\"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty(\"secretProperty\", JsonValue.from(\"42\"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName(\"file-name.jpg\")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from(\"Hello World!\");\n\n// Create a JSON array value equivalent to `[\"Hello\", \"World\"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n \"Hello\", \"World\"\n));\n\n// Create a JSON object value equivalent to `{ \"a\": 1, \"b\": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n \"a\", 1,\n \"b\", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// \"a\": [1, 2],\n// \"b\": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n \"a\", List.of(\n 1, 2\n ),\n \"b\", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.JsonMissing;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get(\"secretProperty\");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return \"It's null!\";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return \"It's a boolean!\";\n }\n\n @Override\n public String visitNumber(Number value) {\n return \"It's a number!\";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property's raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don't you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don't want to introduce a breaking change every time we add a field to a class.\n\n### Why don't you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don't play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n" + language: 'java', + content: + '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.client.ImageKitClientAsync;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.MultipartField;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.core.http.Headers;\nimport io.imagekit.core.http.HttpResponseFor;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.JsonMissing;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', }, { - "language": "kotlin", - "content": "# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\nThe Image Kit Kotlin SDK is similar to the Image Kit Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation(\"com.imagekit.api:image-kit-kotlin:0.0.1\")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(\"https://www.example.com/public-url.jpg\".byteInputStream())\n .fileName(\"file-name.jpg\")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey(\"My Private Key\")\n .password(\"My Password\")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey(\"My Private Key\")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `\"do_not_set\"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `\"https://api.imagekit.io\"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don't create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl(\"https://example.com\")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(\"https://www.example.com/public-url.jpg\".byteInputStream())\n .fileName(\"file-name.jpg\")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(\"https://www.example.com/public-url.jpg\".byteInputStream())\n .fileName(\"file-name.jpg\")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(Paths.get(\"/path/to/file\"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(URL(\"https://example.com//path/to/file\").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(\"content\".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(MultipartField.builder()\n .value(URL(\"https://example.com//path/to/file\").openStream())\n .filename(\"/path/to/file\")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don't provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(\"https://www.example.com/public-url.jpg\".byteInputStream())\n .fileName(\"file-name.jpg\")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don't work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n \"https://example.com\", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp's default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader(\"Secret-Header\", \"42\")\n .putAdditionalQueryParam(\"secret_query_param\", \"42\")\n .putAdditionalBodyProperty(\"secretProperty\", JsonValue.from(\"42\"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty(\"secretProperty\", JsonValue.from(\"42\"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName(\"file-name.jpg\")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from(\"Hello World!\")\n\n// Create a JSON array value equivalent to `[\"Hello\", \"World\"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n \"Hello\", \"World\"\n))\n\n// Create a JSON object value equivalent to `{ \"a\": 1, \"b\": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n \"a\" to 1, \"b\" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// \"a\": [1, 2],\n// \"b\": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n \"a\" to listOf(\n 1, 2\n ), \"b\" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName(\"fileName\")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get(\"secretProperty\")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> \"It's null!\"\n is JsonBoolean -> \"It's a boolean!\"\n is JsonNumber -> \"It's a number!\"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> \"It's something else!\"\n}\n```\n\nTo access a property's raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don't you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don't want to introduce a breaking change every time we add a field to a class.\n\n### Why don't you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don't play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n" + language: 'kotlin', + content: + '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\nThe Image Kit Kotlin SDK is similar to the Image Kit Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', }, { - "language": "php", - "content": "# Image Kit PHP API Library\n\nThe Image Kit PHP library provides convenient access to the Image Kit REST API from any PHP 8.1.0+ application.\n\n## Installation\n\nTo use this package, install via Composer by adding the following to your application's `composer.json`:\n\n```json\n{\n \"repositories\": [\n {\n \"type\": \"vcs\",\n \"url\": \"git@github.com:stainless-sdks/imagekit-php.git\"\n }\n ],\n \"require\": {\n \"imagekit/imagekit\": \"dev-main\"\n }\n}\n```\n\n## Usage\n\n```php\nfiles->upload(\n file: FileParam::fromString('https://www.example.com/public-url.jpg', filename: uniqid('file-upload-', true)),\n fileName: 'file-name.jpg',\n);\n\nvar_dump($response->videoCodec);\n```" + language: 'php', + content: + '# Image Kit PHP API Library\n\nThe Image Kit PHP library provides convenient access to the Image Kit REST API from any PHP 8.1.0+ application.\n\n## Installation\n\nTo use this package, install via Composer by adding the following to your application\'s `composer.json`:\n\n```json\n{\n "repositories": [\n {\n "type": "vcs",\n "url": "git@github.com:stainless-sdks/imagekit-php.git"\n }\n ],\n "require": {\n "imagekit/imagekit": "dev-main"\n }\n}\n```\n\n## Usage\n\n```php\nfiles->upload(\n file: FileParam::fromString(\'https://www.example.com/public-url.jpg\', filename: uniqid(\'file-upload-\', true)),\n fileName: \'file-name.jpg\',\n);\n\nvar_dump($response->videoCodec);\n```', }, { - "language": "python", - "content": "# Image Kit Python API library\n\n\n[![PyPI version](https://img.shields.io/pypi/v/imagekitio.svg?label=pypi%20(stable))](https://pypi.org/project/imagekitio/)\n\nThe Image Kit Python library provides convenient access to the Image Kit REST API from any Python 3.9+\napplication. The library includes type definitions for all request params and response fields,\nand offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n## Installation\n\n```sh\n# install from PyPI\npip install imagekitio\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\n\nresponse = client.files.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n)\nprint(response.video_codec)\n```\n\nWhile you can provide a `private_key` keyword argument,\nwe recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nto add `IMAGEKIT_PRIVATE_KEY=\"My Private Key\"` to your `.env` file\nso that your Private Key is not stored in source control.\n\n## Async usage\n\nSimply import `AsyncImageKit` instead of `ImageKit` and use `await` with each API call:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import AsyncImageKit\n\nclient = AsyncImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n)\n\nasync def main() -> None:\n response = await client.files.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n### With aiohttp\n\nBy default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.\n\nYou can enable this by installing `aiohttp`:\n\n```sh\n# install from PyPI\npip install imagekitio[aiohttp]\n```\n\nThen you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import DefaultAioHttpClient\nfrom imagekitio import AsyncImageKit\n\nasync def main() -> None:\n async with AsyncImageKit(\n private_key=os.environ.get(\"IMAGEKIT_PRIVATE_KEY\"), # This is the default and can be omitted\n password=os.environ.get(\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"), # This is the default and can be omitted\n http_client=DefaultAioHttpClient(),\n) as client:\n response = await client.files.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\n\n\n## Using types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:\n\n- Serializing back into JSON, `model.to_json()`\n- Converting to a dictionary, `model.to_dict()`\n\nTyped requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.\n\n\n\n## Nested params\n\nNested parameters are dictionaries, typed using `TypedDict`, for example:\n\n```python\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nresponse = client.files.upload(\n file=b\"Example data\",\n file_name=\"fileName\",\n transformation={\n \"post\": [{\n \"type\": \"thumbnail\",\n \"value\": \"w-150,h-150\",\n }, {\n \"protocol\": \"dash\",\n \"type\": \"abs\",\n \"value\": \"sr-240_360_480_720_1080\",\n }]\n },\n)\nprint(response.transformation)\n```\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.\n\n```python\nfrom pathlib import Path\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nclient.files.upload(\n file=Path(\"/path/to/file\"),\n file_name=\"fileName\",\n)\n```\n\nThe async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.\n\n## Handling errors\n\nWhen the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `imagekitio.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (that is, 4xx or 5xx\nresponse), a subclass of `imagekitio.APIStatusError` is raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `imagekitio.APIError`.\n\n```python\nimport imagekitio\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\ntry:\n client.files.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n )\nexcept imagekitio.APIConnectionError as e:\n print(\"The server could not be reached\")\n print(e.__cause__) # an underlying Exception, likely raised within httpx.\nexcept imagekitio.RateLimitError as e:\n print(\"A 429 status code was received; we should back off a bit.\")\nexcept imagekitio.APIStatusError as e:\n print(\"Another non-200-range status code was received\")\n print(e.status_code)\n print(e.response)\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors are automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors are all retried by default.\n\nYou can use the `max_retries` option to configure or disable retry settings:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # default is 2\n max_retries=0,\n)\n\n# Or, configure per-request:\nclient.with_options(max_retries = 5).files.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n)\n```\n\n### Timeouts\n\nBy default requests time out after 1 minute. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # 20 seconds (default is 1 minute)\n timeout=20.0,\n)\n\n# More granular control:\nclient = ImageKit(\n timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n)\n\n# Override per-request:\nclient.with_options(timeout = 5.0).files.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n)\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests that time out are [retried twice by default](#retries).\n\n\n\n## Advanced\n\n### Logging\n\nWe use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.\n\nYou can enable logging by setting the environment variable `IMAGE_KIT_LOG` to `info`.\n\n```shell\n$ export IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging.\n\n### How to tell whether `None` means `null` or missing\n\nIn an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:\n\n```py\nif response.my_field is None:\n if 'my_field' not in response.model_fields_set:\n print('Got json like {}, without a \"my_field\" key present at all.')\n else:\n print('Got json like {\"my_field\": null}.')\n```\n\n### Accessing raw response data (e.g. headers)\n\nThe \"raw\" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,\n\n```py\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\nresponse = client.files.with_raw_response.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n)\nprint(response.headers.get('X-My-Header'))\n\nfile = response.parse() # get the object that `files.upload()` would have returned\nprint(file.video_codec)\n```\n\nThese methods return an [`APIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) object.\n\nThe async client returns an [`AsyncAPIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.\n\n#### `.with_streaming_response`\n\nThe above interface eagerly reads the full response body when you make the request, which may not always be what you want.\n\nTo stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.\n\n```python\nwith client.files.with_streaming_response.upload(\n file=b\"https://www.example.com/public-url.jpg\",\n file_name=\"file-name.jpg\",\n) as response :\n print(response.headers.get('X-My-Header'))\n\n for line in response.iter_lines():\n print(line)\n```\n\nThe context manager is required so that the response will reliably be closed.\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API.\n\nIf you need to access undocumented endpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other\nhttp verbs. Options on the client will be respected (such as retries) when making this request.\n\n```py\nimport httpx\n\nresponse = client.post(\n \"/foo\",\n cast_to=httpx.Response,\n body={\"my_param\": True},\n)\n\nprint(response.headers.get(\"x-foo\"))\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You\ncan also get all the extra fields on the Pydantic model as a dict with\n[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).\n\n### Configuring the HTTP client\n\nYou can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:\n\n- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)\n- Custom [transports](https://www.python-httpx.org/advanced/transports/)\n- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality\n\n```python\nimport httpx\nfrom imagekitio import ImageKit, DefaultHttpxClient\n\nclient = ImageKit(\n # Or use the `IMAGE_KIT_BASE_URL` env var\n base_url=\"http://my.test.server.example.com:8083\",\n http_client=DefaultHttpxClient(proxy=\"http://my.test.proxy.example.com\", transport=httpx.HTTPTransport(local_address=\"0.0.0.0\")),\n)\n```\n\nYou can also customize the client on a per-request basis by using `with_options()`:\n\n```python\nclient.with_options(http_client=DefaultHttpxClient(...))\n```\n\n### Managing HTTP resources\n\nBy default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.\n\n```py\nfrom imagekitio import ImageKit\n\nwith ImageKit() as client:\n # make requests here\n ...\n\n# HTTP client is now closed\n```\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you've upgraded to the latest version but aren't seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport imagekitio\nprint(imagekitio.__version__)\n```\n\n## Requirements\n\nPython 3.9 or higher.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n" + language: 'python', + content: + '# Image Kit Python API library\n\n\n[![PyPI version](https://img.shields.io/pypi/v/imagekitio.svg?label=pypi%20(stable))](https://pypi.org/project/imagekitio/)\n\nThe Image Kit Python library provides convenient access to the Image Kit REST API from any Python 3.9+\napplication. The library includes type definitions for all request params and response fields,\nand offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n## Installation\n\n```sh\n# install from PyPI\npip install imagekitio\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```python\nimport os\nfrom imagekitio import ImageKit\n\nclient = ImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nresponse = client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.video_codec)\n```\n\nWhile you can provide a `private_key` keyword argument,\nwe recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nto add `IMAGEKIT_PRIVATE_KEY="My Private Key"` to your `.env` file\nso that your Private Key is not stored in source control.\n\n## Async usage\n\nSimply import `AsyncImageKit` instead of `ImageKit` and use `await` with each API call:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import AsyncImageKit\n\nclient = AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n)\n\nasync def main() -> None:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n### With aiohttp\n\nBy default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.\n\nYou can enable this by installing `aiohttp`:\n\n```sh\n# install from PyPI\npip install imagekitio[aiohttp]\n```\n\nThen you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:\n\n```python\nimport os\nimport asyncio\nfrom imagekitio import DefaultAioHttpClient\nfrom imagekitio import AsyncImageKit\n\nasync def main() -> None:\n async with AsyncImageKit(\n private_key=os.environ.get("IMAGEKIT_PRIVATE_KEY"), # This is the default and can be omitted\n password=os.environ.get("OPTIONAL_IMAGEKIT_IGNORES_THIS"), # This is the default and can be omitted\n http_client=DefaultAioHttpClient(),\n) as client:\n response = await client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\n print(response.video_codec)\n\nasyncio.run(main())\n```\n\n\n\n## Using types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:\n\n- Serializing back into JSON, `model.to_json()`\n- Converting to a dictionary, `model.to_dict()`\n\nTyped requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.\n\n\n\n## Nested params\n\nNested parameters are dictionaries, typed using `TypedDict`, for example:\n\n```python\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nresponse = client.files.upload(\n file=b"Example data",\n file_name="fileName",\n transformation={\n "post": [{\n "type": "thumbnail",\n "value": "w-150,h-150",\n }, {\n "protocol": "dash",\n "type": "abs",\n "value": "sr-240_360_480_720_1080",\n }]\n },\n)\nprint(response.transformation)\n```\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.\n\n```python\nfrom pathlib import Path\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\nclient.files.upload(\n file=Path("/path/to/file"),\n file_name="fileName",\n)\n```\n\nThe async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.\n\n## Handling errors\n\nWhen the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `imagekitio.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (that is, 4xx or 5xx\nresponse), a subclass of `imagekitio.APIStatusError` is raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `imagekitio.APIError`.\n\n```python\nimport imagekitio\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\n\ntry:\n client.files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n )\nexcept imagekitio.APIConnectionError as e:\n print("The server could not be reached")\n print(e.__cause__) # an underlying Exception, likely raised within httpx.\nexcept imagekitio.RateLimitError as e:\n print("A 429 status code was received; we should back off a bit.")\nexcept imagekitio.APIStatusError as e:\n print("Another non-200-range status code was received")\n print(e.status_code)\n print(e.response)\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors are automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors are all retried by default.\n\nYou can use the `max_retries` option to configure or disable retry settings:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # default is 2\n max_retries=0,\n)\n\n# Or, configure per-request:\nclient.with_options(max_retries = 5).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\n### Timeouts\n\nBy default requests time out after 1 minute. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:\n\n```python\nfrom imagekitio import ImageKit\n\n# Configure the default for all requests:\nclient = ImageKit(\n # 20 seconds (default is 1 minute)\n timeout=20.0,\n)\n\n# More granular control:\nclient = ImageKit(\n timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n)\n\n# Override per-request:\nclient.with_options(timeout = 5.0).files.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests that time out are [retried twice by default](#retries).\n\n\n\n## Advanced\n\n### Logging\n\nWe use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.\n\nYou can enable logging by setting the environment variable `IMAGE_KIT_LOG` to `info`.\n\n```shell\n$ export IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging.\n\n### How to tell whether `None` means `null` or missing\n\nIn an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:\n\n```py\nif response.my_field is None:\n if \'my_field\' not in response.model_fields_set:\n print(\'Got json like {}, without a "my_field" key present at all.\')\n else:\n print(\'Got json like {"my_field": null}.\')\n```\n\n### Accessing raw response data (e.g. headers)\n\nThe "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,\n\n```py\nfrom imagekitio import ImageKit\n\nclient = ImageKit()\nresponse = client.files.with_raw_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n)\nprint(response.headers.get(\'X-My-Header\'))\n\nfile = response.parse() # get the object that `files.upload()` would have returned\nprint(file.video_codec)\n```\n\nThese methods return an [`APIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) object.\n\nThe async client returns an [`AsyncAPIResponse`](https://github.com/imagekit-developer/imagekit-python/tree/master/src/imagekitio/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.\n\n#### `.with_streaming_response`\n\nThe above interface eagerly reads the full response body when you make the request, which may not always be what you want.\n\nTo stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.\n\n```python\nwith client.files.with_streaming_response.upload(\n file=b"https://www.example.com/public-url.jpg",\n file_name="file-name.jpg",\n) as response :\n print(response.headers.get(\'X-My-Header\'))\n\n for line in response.iter_lines():\n print(line)\n```\n\nThe context manager is required so that the response will reliably be closed.\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API.\n\nIf you need to access undocumented endpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other\nhttp verbs. Options on the client will be respected (such as retries) when making this request.\n\n```py\nimport httpx\n\nresponse = client.post(\n "/foo",\n cast_to=httpx.Response,\n body={"my_param": True},\n)\n\nprint(response.headers.get("x-foo"))\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You\ncan also get all the extra fields on the Pydantic model as a dict with\n[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).\n\n### Configuring the HTTP client\n\nYou can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:\n\n- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)\n- Custom [transports](https://www.python-httpx.org/advanced/transports/)\n- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality\n\n```python\nimport httpx\nfrom imagekitio import ImageKit, DefaultHttpxClient\n\nclient = ImageKit(\n # Or use the `IMAGE_KIT_BASE_URL` env var\n base_url="http://my.test.server.example.com:8083",\n http_client=DefaultHttpxClient(proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),\n)\n```\n\nYou can also customize the client on a per-request basis by using `with_options()`:\n\n```python\nclient.with_options(http_client=DefaultHttpxClient(...))\n```\n\n### Managing HTTP resources\n\nBy default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.\n\n```py\nfrom imagekitio import ImageKit\n\nwith ImageKit() as client:\n # make requests here\n ...\n\n# HTTP client is now closed\n```\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you\'ve upgraded to the latest version but aren\'t seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport imagekitio\nprint(imagekitio.__version__)\n```\n\n## Requirements\n\nPython 3.9 or higher.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', }, { - "language": "ruby", - "content": "# Image Kit Ruby API library\n\nThe Image Kit Ruby library provides convenient access to the Image Kit REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/imagekit-developer/imagekit-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nDocumentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/imagekitio).\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference).\n\n## Installation\n\nTo use this gem, install via Bundler by adding the following to your application's `Gemfile`:\n\n\n\n```ruby\ngem \"imagekitio\", \"~> 0.0.1\"\n```\n\n\n\n## Usage\n\n```ruby\nrequire \"bundler/setup\"\nrequire \"imagekitio\"\n\nimage_kit = Imagekitio::Client.new(\n private_key: ENV[\"IMAGEKIT_PRIVATE_KEY\"], # This is the default and can be omitted\n password: ENV[\"OPTIONAL_IMAGEKIT_IGNORES_THIS\"] # This is the default and can be omitted\n)\n\nresponse = image_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\"\n)\n\nputs(response.videoCodec)\n```\n\n\n\n\n\n### File uploads\n\nRequest parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, [`StringIO`](https://rubyapi.org/3.2/o/stringio), or more.\n\n```ruby\nrequire \"pathname\"\n\n# Use `Pathname` to send the filename and/or avoid paging a large file into memory:\nresponse = image_kit.files.upload(file: Pathname(\"/path/to/file\"))\n\n# Alternatively, pass file contents or a `StringIO` directly:\nresponse = image_kit.files.upload(file: File.read(\"/path/to/file\"))\n\n# Or, to control the filename and/or content type:\nfile = Imagekitio::FilePart.new(File.read(\"/path/to/file\"), filename: \"/path/to/file\", content_type: \"…\")\nresponse = image_kit.files.upload(file: file)\n\nputs(response.videoCodec)\n```\n\nNote that you can also pass a raw `IO` descriptor, but this disables retries, as the library can't be sure if the descriptor is a file or pipe (which cannot be rewound).\n\n### Handling errors\n\nWhen the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Imagekitio::Errors::APIError` will be thrown:\n\n```ruby\nbegin\n file = image_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\"\n )\nrescue Imagekitio::Errors::APIConnectionError => e\n puts(\"The server could not be reached\")\n puts(e.cause) # an underlying Exception, likely raised within `net/http`\nrescue Imagekitio::Errors::RateLimitError => e\n puts(\"A 429 status code was received; we should back off a bit.\")\nrescue Imagekitio::Errors::APIStatusError => e\n puts(\"Another non-200-range status code was received\")\n puts(e.status)\nend\n```\n\nError codes are as follows:\n\n| Cause | Error Type |\n| ---------------- | -------------------------- |\n| HTTP 400 | `BadRequestError` |\n| HTTP 401 | `AuthenticationError` |\n| HTTP 403 | `PermissionDeniedError` |\n| HTTP 404 | `NotFoundError` |\n| HTTP 409 | `ConflictError` |\n| HTTP 422 | `UnprocessableEntityError` |\n| HTTP 429 | `RateLimitError` |\n| HTTP >= 500 | `InternalServerError` |\n| Other HTTP error | `APIStatusError` |\n| Timeout | `APITimeoutError` |\n| Network error | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\n\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.\n\nYou can use the `max_retries` option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n max_retries: 0 # default is 2\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\",\n request_options: {max_retries: 5}\n)\n```\n\n### Timeouts\n\nBy default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n timeout: nil # default is 60\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\",\n request_options: {timeout: 5}\n)\n```\n\nOn timeout, `Imagekitio::Errors::APITimeoutError` is raised.\n\nNote that requests that time out are retried by default.\n\n## Advanced concepts\n\n### BaseModel\n\nAll parameter and response objects inherit from `Imagekitio::Internal::Type::BaseModel`, which provides several conveniences, including:\n\n1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.\n\n2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.\n\n3. Both instances and the classes themselves can be pretty-printed.\n\n4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.\n\n### Making custom or undocumented requests\n\n#### Undocumented properties\n\nYou can send undocumented parameters to any endpoint, and read undocumented response properties, like so:\n\nNote: the `extra_` parameters of the same name overrides the documented parameters.\n\n```ruby\nresponse =\n image_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\",\n request_options: {\n extra_query: {my_query_parameter: value},\n extra_body: {my_body_parameter: value},\n extra_headers: {\"my-header\": value}\n }\n )\n\nputs(response[:my_undocumented_property])\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:\n\n```ruby\nresponse = client.request(\n method: :post,\n path: '/undocumented/endpoint',\n query: {\"dog\": \"woof\"},\n headers: {\"useful-header\": \"interesting-value\"},\n body: {\"hello\": \"world\"}\n)\n```\n\n### Concurrency & connection pooling\n\nThe `Imagekitio::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.\n\nEach instance of `Imagekitio::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.\n\nWhen all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.\n\nUnless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.\n\n## Sorbet\n\nThis library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.\n\nYou can provide typesafe request parameters like so:\n\n```ruby\nimage_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\"\n)\n```\n\nOr, equivalently:\n\n```ruby\n# Hashes work, but are not typesafe:\nimage_kit.files.upload(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\"\n)\n\n# You can also splat a full Params class:\nparams = Imagekitio::FileUploadParams.new(\n file: StringIO.new(\"https://www.example.com/public-url.jpg\"),\n file_name: \"file-name.jpg\"\n)\nimage_kit.files.upload(**params)\n```\n\n### Enums\n\nSince this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide \"tagged symbols\" instead, which is always a primitive at runtime:\n\n```ruby\n# :all\nputs(Imagekitio::AssetListParams::FileType::ALL)\n\n# Revealed type: `T.all(Imagekitio::AssetListParams::FileType, Symbol)`\nT.reveal_type(Imagekitio::AssetListParams::FileType::ALL)\n```\n\nEnum parameters have a \"relaxed\" type, so you can either pass in enum constants or their literal value:\n\n```ruby\n# Using the enum constants preserves the tagged type information:\nimage_kit.assets.list(\n file_type: Imagekitio::AssetListParams::FileType::ALL,\n # …\n)\n\n# Literal values are also permissible:\nimage_kit.assets.list(\n file_type: :all,\n # …\n)\n```\n\n## Versioning\n\nThis package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.\n\nThis package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.\n\n## Requirements\n\nRuby 3.2.0 or higher.\n\n## Contributing\n\nSee [the contributing documentation](https://github.com/imagekit-developer/imagekit-ruby/tree/master/CONTRIBUTING.md).\n" + language: 'ruby', + content: + '# Image Kit Ruby API library\n\nThe Image Kit Ruby library provides convenient access to the Image Kit REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/imagekit-developer/imagekit-ruby#Sorbet) for usage with Sorbet. The standard library\'s `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nDocumentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/imagekitio).\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference).\n\n## Installation\n\nTo use this gem, install via Bundler by adding the following to your application\'s `Gemfile`:\n\n\n\n```ruby\ngem "imagekitio", "~> 0.0.1"\n```\n\n\n\n## Usage\n\n```ruby\nrequire "bundler/setup"\nrequire "imagekitio"\n\nimage_kit = Imagekitio::Client.new(\n private_key: ENV["IMAGEKIT_PRIVATE_KEY"], # This is the default and can be omitted\n password: ENV["OPTIONAL_IMAGEKIT_IGNORES_THIS"] # This is the default and can be omitted\n)\n\nresponse = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\nputs(response.videoCodec)\n```\n\n\n\n\n\n### File uploads\n\nRequest parameters that correspond to file uploads can be passed as raw contents, a [`Pathname`](https://rubyapi.org/3.2/o/pathname) instance, [`StringIO`](https://rubyapi.org/3.2/o/stringio), or more.\n\n```ruby\nrequire "pathname"\n\n# Use `Pathname` to send the filename and/or avoid paging a large file into memory:\nresponse = image_kit.files.upload(file: Pathname("/path/to/file"))\n\n# Alternatively, pass file contents or a `StringIO` directly:\nresponse = image_kit.files.upload(file: File.read("/path/to/file"))\n\n# Or, to control the filename and/or content type:\nfile = Imagekitio::FilePart.new(File.read("/path/to/file"), filename: "/path/to/file", content_type: "…")\nresponse = image_kit.files.upload(file: file)\n\nputs(response.videoCodec)\n```\n\nNote that you can also pass a raw `IO` descriptor, but this disables retries, as the library can\'t be sure if the descriptor is a file or pipe (which cannot be rewound).\n\n### Handling errors\n\nWhen the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Imagekitio::Errors::APIError` will be thrown:\n\n```ruby\nbegin\n file = image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n )\nrescue Imagekitio::Errors::APIConnectionError => e\n puts("The server could not be reached")\n puts(e.cause) # an underlying Exception, likely raised within `net/http`\nrescue Imagekitio::Errors::RateLimitError => e\n puts("A 429 status code was received; we should back off a bit.")\nrescue Imagekitio::Errors::APIStatusError => e\n puts("Another non-200-range status code was received")\n puts(e.status)\nend\n```\n\nError codes are as follows:\n\n| Cause | Error Type |\n| ---------------- | -------------------------- |\n| HTTP 400 | `BadRequestError` |\n| HTTP 401 | `AuthenticationError` |\n| HTTP 403 | `PermissionDeniedError` |\n| HTTP 404 | `NotFoundError` |\n| HTTP 409 | `ConflictError` |\n| HTTP 422 | `UnprocessableEntityError` |\n| HTTP 429 | `RateLimitError` |\n| HTTP >= 500 | `InternalServerError` |\n| Other HTTP error | `APIStatusError` |\n| Timeout | `APITimeoutError` |\n| Network error | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\n\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.\n\nYou can use the `max_retries` option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n max_retries: 0 # default is 2\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {max_retries: 5}\n)\n```\n\n### Timeouts\n\nBy default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nimage_kit = Imagekitio::Client.new(\n timeout: nil # default is 60\n)\n\n# Or, configure per-request:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {timeout: 5}\n)\n```\n\nOn timeout, `Imagekitio::Errors::APITimeoutError` is raised.\n\nNote that requests that time out are retried by default.\n\n## Advanced concepts\n\n### BaseModel\n\nAll parameter and response objects inherit from `Imagekitio::Internal::Type::BaseModel`, which provides several conveniences, including:\n\n1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.\n\n2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.\n\n3. Both instances and the classes themselves can be pretty-printed.\n\n4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.\n\n### Making custom or undocumented requests\n\n#### Undocumented properties\n\nYou can send undocumented parameters to any endpoint, and read undocumented response properties, like so:\n\nNote: the `extra_` parameters of the same name overrides the documented parameters.\n\n```ruby\nresponse =\n image_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg",\n request_options: {\n extra_query: {my_query_parameter: value},\n extra_body: {my_body_parameter: value},\n extra_headers: {"my-header": value}\n }\n )\n\nputs(response[:my_undocumented_property])\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:\n\n```ruby\nresponse = client.request(\n method: :post,\n path: \'/undocumented/endpoint\',\n query: {"dog": "woof"},\n headers: {"useful-header": "interesting-value"},\n body: {"hello": "world"}\n)\n```\n\n### Concurrency & connection pooling\n\nThe `Imagekitio::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.\n\nEach instance of `Imagekitio::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.\n\nWhen all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.\n\nUnless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.\n\n## Sorbet\n\nThis library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.\n\nYou can provide typesafe request parameters like so:\n\n```ruby\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n```\n\nOr, equivalently:\n\n```ruby\n# Hashes work, but are not typesafe:\nimage_kit.files.upload(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\n\n# You can also splat a full Params class:\nparams = Imagekitio::FileUploadParams.new(\n file: StringIO.new("https://www.example.com/public-url.jpg"),\n file_name: "file-name.jpg"\n)\nimage_kit.files.upload(**params)\n```\n\n### Enums\n\nSince this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:\n\n```ruby\n# :all\nputs(Imagekitio::AssetListParams::FileType::ALL)\n\n# Revealed type: `T.all(Imagekitio::AssetListParams::FileType, Symbol)`\nT.reveal_type(Imagekitio::AssetListParams::FileType::ALL)\n```\n\nEnum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:\n\n```ruby\n# Using the enum constants preserves the tagged type information:\nimage_kit.assets.list(\n file_type: Imagekitio::AssetListParams::FileType::ALL,\n # …\n)\n\n# Literal values are also permissible:\nimage_kit.assets.list(\n file_type: :all,\n # …\n)\n```\n\n## Versioning\n\nThis package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.\n\nThis package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.\n\n## Requirements\n\nRuby 3.2.0 or higher.\n\n## Contributing\n\nSee [the contributing documentation](https://github.com/imagekit-developer/imagekit-ruby/tree/master/CONTRIBUTING.md).\n', }, { - "language": "terraform", - "content": "# Image Kit Terraform Provider\n\nThe [Image Kit Terraform provider](https://registry.terraform.io/providers/stainless-sdks/imagekit/latest/docs) provides convenient access to\nthe [Image Kit REST API](https://imagekit.io/docs/api-reference) from Terraform.\n\n\n\n## Requirements\n\nThis provider requires Terraform CLI 1.0 or later. You can [install it for your system](https://developer.hashicorp.com/terraform/install)\non Hashicorp's website.\n\n## Usage\n\nAdd the following to your `main.tf` file:\n\n\n\n```hcl\n# Declare the provider and version\nterraform {\n required_providers {\n SDK_ProviderTypeName = {\n source = \"stainless-sdks/imagekit\"\n version = \"~> 0.0.1\"\n }\n }\n}\n\n# Initialize the provider\nprovider \"imagekit\" {\n # Your ImageKit private API key (starts with `private_`).\n You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n private_key = \"My Private Key\" # or set IMAGEKIT_PRIVATE_KEY env variable\n # ImageKit uses your API key as username and ignores the password. \n The SDK sets a dummy value. You can ignore this field.\n password = \"My Password\" # or set OPTIONAL_IMAGEKIT_IGNORES_THIS env variable\n # Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\n You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\n Only required if you're using webhooks.\n webhook_secret = \"My Webhook Secret\" # or set IMAGEKIT_WEBHOOK_SECRET env variable\n}\n\n# Configure a resource\nresource \"imagekit_account_origin\" \"example_account_origin\" {\n access_key = \"AKIAIOSFODNN7EXAMPLE\"\n bucket = \"product-images\"\n name = \"US S3 Storage\"\n secret_key = \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\"\n type = \"S3\"\n base_url_for_canonical_header = \"https://cdn.example.com\"\n include_canonical_header = false\n prefix = \"raw-assets\"\n}\n```\n\n\n\nInitialize your project by running `terraform init` in the directory.\n\nAdditional examples can be found in the [./examples](./examples) folder within this repository, and you can\nrefer to the full documentation on [the Terraform Registry](https://registry.terraform.io/providers/stainless-sdks/imagekit/latest/docs).\n\n### Provider Options\nWhen you initialize the provider, the following options are supported. It is recommended to use environment variables for sensitive values like access tokens.\nIf an environment variable is provided, then the option does not need to be set in the terraform source.\n\n| Property | Environment variable | Required | Default value |\n| -------------- | -------------------------------- | -------- | -------------- |\n| private_key | `IMAGEKIT_PRIVATE_KEY` | true | — |\n| webhook_secret | `IMAGEKIT_WEBHOOK_SECRET` | false | — |\n| password | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `\"do_not_set\"` |\n\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-terraform/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n" + language: 'terraform', + content: + '# Image Kit Terraform Provider\n\nThe [Image Kit Terraform provider](https://registry.terraform.io/providers/stainless-sdks/imagekit/latest/docs) provides convenient access to\nthe [Image Kit REST API](https://imagekit.io/docs/api-reference) from Terraform.\n\n\n\n## Requirements\n\nThis provider requires Terraform CLI 1.0 or later. You can [install it for your system](https://developer.hashicorp.com/terraform/install)\non Hashicorp\'s website.\n\n## Usage\n\nAdd the following to your `main.tf` file:\n\n\n\n```hcl\n# Declare the provider and version\nterraform {\n required_providers {\n SDK_ProviderTypeName = {\n source = "stainless-sdks/imagekit"\n version = "~> 0.0.1"\n }\n }\n}\n\n# Initialize the provider\nprovider "imagekit" {\n # Your ImageKit private API key (starts with `private_`).\n You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys).\n private_key = "My Private Key" # or set IMAGEKIT_PRIVATE_KEY env variable\n # ImageKit uses your API key as username and ignores the password. \n The SDK sets a dummy value. You can ignore this field.\n password = "My Password" # or set OPTIONAL_IMAGEKIT_IGNORES_THIS env variable\n # Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\n You can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\n Only required if you\'re using webhooks.\n webhook_secret = "My Webhook Secret" # or set IMAGEKIT_WEBHOOK_SECRET env variable\n}\n\n# Configure a resource\nresource "imagekit_account_origin" "example_account_origin" {\n access_key = "AKIAIOSFODNN7EXAMPLE"\n bucket = "product-images"\n name = "US S3 Storage"\n secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"\n type = "S3"\n base_url_for_canonical_header = "https://cdn.example.com"\n include_canonical_header = false\n prefix = "raw-assets"\n}\n```\n\n\n\nInitialize your project by running `terraform init` in the directory.\n\nAdditional examples can be found in the [./examples](./examples) folder within this repository, and you can\nrefer to the full documentation on [the Terraform Registry](https://registry.terraform.io/providers/stainless-sdks/imagekit/latest/docs).\n\n### Provider Options\nWhen you initialize the provider, the following options are supported. It is recommended to use environment variables for sensitive values like access tokens.\nIf an environment variable is provided, then the option does not need to be set in the terraform source.\n\n| Property | Environment variable | Required | Default value |\n| -------------- | -------------------------------- | -------- | -------------- |\n| private_key | `IMAGEKIT_PRIVATE_KEY` | true | — |\n| webhook_secret | `IMAGEKIT_WEBHOOK_SECRET` | false | — |\n| password | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-terraform/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', }, { - "language": "typescript", - "content": "# Image Kit TypeScript API Library\n\n[![NPM version](https://img.shields.io/npm/v/@imagekit/nodejs.svg?label=npm%20(stable))](https://npmjs.org/package/@imagekit/nodejs) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@imagekit/nodejs)\n\nThis library provides convenient access to the Image Kit REST API from server-side TypeScript or JavaScript.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n```sh\nnpm install @imagekit/nodejs\n```\n\n\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n\n```js\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n});\n\nconsole.log(response.videoCodec);\n```\n\n\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst params: ImageKit.FileUploadParams = {\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n};\nconst response: ImageKit.FileUploadResponse = await client.files.upload(params);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed in many different forms:\n- `File` (or an object with the same structure)\n- a `fetch` `Response` (or an object with the same structure)\n- an `fs.ReadStream`\n- the return value of our `toFile` helper\n\n```ts\nimport fs from 'fs';\nimport ImageKit, { toFile } from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\n// If you have access to Node `fs` we recommend using `fs.createReadStream()`:\nawait client.files.upload({ file: fs.createReadStream('/path/to/file'), fileName: 'fileName' });\n\n// Or if you have the web `File` API you can pass a `File` instance:\nawait client.files.upload({ file: new File(['my bytes'], 'file'), fileName: 'fileName' });\n\n// You can also pass a `fetch` `Response`:\nawait client.files.upload({ file: await fetch('https://somesite/file'), fileName: 'fileName' });\n\n// Finally, if none of the above are convenient, you can use our `toFile` helper:\nawait client.files.upload({\n file: await toFile(Buffer.from('my bytes'), 'file'),\n fileName: 'fileName',\n});\nawait client.files.upload({\n file: await toFile(new Uint8Array([0, 1, 2]), 'file'),\n fileName: 'fileName',\n});\n```\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n\n```ts\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .catch(async (err) => {\n if (err instanceof ImageKit.APIError) {\n console.log(err.status); // 400\n console.log(err.name); // BadRequestError\n console.log(err.headers); // {server: 'nginx', ...}\n } else {\n throw err;\n }\n });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n\n```js\n// Configure the default for all requests:\nconst client = new ImageKit({\n maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n\n```ts\n// Configure the default for all requests:\nconst client = new ImageKit({\n timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n\n\n\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n\n```ts\nconst client = new ImageKit();\n\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: response, response: raw } = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(response.videoCodec);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `IMAGE_KIT_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new ImageKit({\n logger: logger.child({ name: 'ImageKit' }),\n logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.\nOptions on the client, such as retries, will be respected when making these requests.\n\n```ts\nawait client.post('/some/path', {\n body: { some_prop: 'foo' },\n query: { some_query_arg: 'bar' },\n});\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented\nparameter. This library doesn't validate at runtime that the request matches the type, so any extra values you\nsend will be sent as-is.\n\n```ts\nclient.files.upload({\n // ...\n // @ts-expect-error baz is not yet public\n baz: 'undocumented option',\n});\n```\n\nFor requests with the `GET` verb, any extra params will be in the query, all other requests will send the\nextra param in the body.\n\nIf you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may access the response object with `// @ts-expect-error` on\nthe response object, or cast the response object to the requisite type. Like the request params, we do not\nvalidate or strip extra properties from the response from the API.\n\n### Customizing the fetch client\n\nBy default, this library expects a global `fetch` function is defined.\n\nIf you want to use a different `fetch` function, you can either polyfill the global:\n\n```ts\nimport fetch from 'my-fetch';\n\nglobalThis.fetch = fetch;\n```\n\nOr pass it to the client:\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport fetch from 'my-fetch';\n\nconst client = new ImageKit({ fetch });\n```\n\n### Fetch options\n\nIf you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n // `RequestInit` options\n },\n});\n```\n\n#### Configuring proxies\n\nTo modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy\noptions to requests:\n\n **Node** [[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport * as undici from 'undici';\n\nconst proxyAgent = new undici.ProxyAgent('http://localhost:8888');\nconst client = new ImageKit({\n fetchOptions: {\n dispatcher: proxyAgent,\n },\n});\n```\n\n **Bun** [[docs](https://bun.sh/guides/http/proxy)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n proxy: 'http://localhost:8888',\n },\n});\n```\n\n **Deno** [[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]\n\n```ts\nimport ImageKit from 'npm:@imagekit/nodejs';\n\nconst httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });\nconst client = new ImageKit({\n fetchOptions: {\n client: httpClient,\n },\n});\n```\n\n## Frequently Asked Questions\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-nodejs/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n" - } + language: 'typescript', + content: + "# Image Kit TypeScript API Library\n\n[![NPM version](https://img.shields.io/npm/v/@imagekit/nodejs.svg?label=npm%20(stable))](https://npmjs.org/package/@imagekit/nodejs) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@imagekit/nodejs)\n\nThis library provides convenient access to the Image Kit REST API from server-side TypeScript or JavaScript.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). The full API of this library can be found in [api.md](api.md).\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n```sh\nnpm install @imagekit/nodejs\n```\n\n\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n\n```js\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst response = await client.files.upload({\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n});\n\nconsole.log(response.videoCodec);\n```\n\n\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n privateKey: process.env['IMAGEKIT_PRIVATE_KEY'], // This is the default and can be omitted\n password: process.env['OPTIONAL_IMAGEKIT_IGNORES_THIS'], // This is the default and can be omitted\n});\n\nconst params: ImageKit.FileUploadParams = {\n file: fs.createReadStream('path/to/file'),\n fileName: 'file-name.jpg',\n};\nconst response: ImageKit.FileUploadResponse = await client.files.upload(params);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed in many different forms:\n- `File` (or an object with the same structure)\n- a `fetch` `Response` (or an object with the same structure)\n- an `fs.ReadStream`\n- the return value of our `toFile` helper\n\n```ts\nimport fs from 'fs';\nimport ImageKit, { toFile } from '@imagekit/nodejs';\n\nconst client = new ImageKit();\n\n// If you have access to Node `fs` we recommend using `fs.createReadStream()`:\nawait client.files.upload({ file: fs.createReadStream('/path/to/file'), fileName: 'fileName' });\n\n// Or if you have the web `File` API you can pass a `File` instance:\nawait client.files.upload({ file: new File(['my bytes'], 'file'), fileName: 'fileName' });\n\n// You can also pass a `fetch` `Response`:\nawait client.files.upload({ file: await fetch('https://somesite/file'), fileName: 'fileName' });\n\n// Finally, if none of the above are convenient, you can use our `toFile` helper:\nawait client.files.upload({\n file: await toFile(Buffer.from('my bytes'), 'file'),\n fileName: 'fileName',\n});\nawait client.files.upload({\n file: await toFile(new Uint8Array([0, 1, 2]), 'file'),\n fileName: 'fileName',\n});\n```\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n\n```ts\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .catch(async (err) => {\n if (err instanceof ImageKit.APIError) {\n console.log(err.status); // 400\n console.log(err.name); // BadRequestError\n console.log(err.headers); // {server: 'nginx', ...}\n } else {\n throw err;\n }\n });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n\n```js\n// Configure the default for all requests:\nconst client = new ImageKit({\n maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n\n```ts\n// Configure the default for all requests:\nconst client = new ImageKit({\n timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.files.upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' }, {\n timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n\n\n\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n\n```ts\nconst client = new ImageKit();\n\nconst response = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: response, response: raw } = await client.files\n .upload({ file: fs.createReadStream('path/to/file'), fileName: 'file-name.jpg' })\n .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(response.videoCodec);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `IMAGE_KIT_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new ImageKit({\n logger: logger.child({ name: 'ImageKit' }),\n logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.\nOptions on the client, such as retries, will be respected when making these requests.\n\n```ts\nawait client.post('/some/path', {\n body: { some_prop: 'foo' },\n query: { some_query_arg: 'bar' },\n});\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented\nparameter. This library doesn't validate at runtime that the request matches the type, so any extra values you\nsend will be sent as-is.\n\n```ts\nclient.files.upload({\n // ...\n // @ts-expect-error baz is not yet public\n baz: 'undocumented option',\n});\n```\n\nFor requests with the `GET` verb, any extra params will be in the query, all other requests will send the\nextra param in the body.\n\nIf you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may access the response object with `// @ts-expect-error` on\nthe response object, or cast the response object to the requisite type. Like the request params, we do not\nvalidate or strip extra properties from the response from the API.\n\n### Customizing the fetch client\n\nBy default, this library expects a global `fetch` function is defined.\n\nIf you want to use a different `fetch` function, you can either polyfill the global:\n\n```ts\nimport fetch from 'my-fetch';\n\nglobalThis.fetch = fetch;\n```\n\nOr pass it to the client:\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport fetch from 'my-fetch';\n\nconst client = new ImageKit({ fetch });\n```\n\n### Fetch options\n\nIf you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n // `RequestInit` options\n },\n});\n```\n\n#### Configuring proxies\n\nTo modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy\noptions to requests:\n\n **Node** [[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\nimport * as undici from 'undici';\n\nconst proxyAgent = new undici.ProxyAgent('http://localhost:8888');\nconst client = new ImageKit({\n fetchOptions: {\n dispatcher: proxyAgent,\n },\n});\n```\n\n **Bun** [[docs](https://bun.sh/guides/http/proxy)]\n\n```ts\nimport ImageKit from '@imagekit/nodejs';\n\nconst client = new ImageKit({\n fetchOptions: {\n proxy: 'http://localhost:8888',\n },\n});\n```\n\n **Deno** [[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]\n\n```ts\nimport ImageKit from 'npm:@imagekit/nodejs';\n\nconst httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });\nconst client = new ImageKit({\n fetchOptions: {\n client: httpClient,\n },\n});\n```\n\n## Frequently Asked Questions\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-nodejs/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n", + }, ]; const INDEX_OPTIONS = { @@ -2894,21 +3412,18 @@ export class LocalDocsSearch { maxResults?: number; maxLength?: number; }): SearchResult { - const { - query, - language = 'typescript', - detail = 'default', - maxResults = 5, - maxLength = 100_000, - } = props; + const { query, language = 'typescript', detail = 'default', maxResults = 5, maxLength = 100_000 } = props; const useMarkdown = detail === 'verbose' || detail === 'high'; // Search both indices and merge results by score. // Filter prose hits so language-tagged content (READMEs and docs with // frontmatter) only matches the requested language. - const methodHits = this.methodIndex.search(query).map((hit) => ({ ...hit, _kind: 'http_method' as const })); - const proseHits = this.proseIndex.search(query) + const methodHits = this.methodIndex + .search(query) + .map((hit) => ({ ...hit, _kind: 'http_method' as const })); + const proseHits = this.proseIndex + .search(query) .filter((hit) => { const source = ((hit as Record)['_original'] as ProseChunk | undefined)?.source; if (!source) return true; diff --git a/packages/mcp-server/src/methods.ts b/packages/mcp-server/src/methods.ts index c1633d66..a2a4f930 100644 --- a/packages/mcp-server/src/methods.ts +++ b/packages/mcp-server/src/methods.ts @@ -7,244 +7,294 @@ export type SdkMethod = { fullyQualifiedName: string; httpMethod?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'query'; httpPath?: string; -} +}; -export const sdkMethods: SdkMethod[] = [{ - clientCallName: 'client.customMetadataFields.create', - fullyQualifiedName: 'customMetadataFields.create', - httpMethod: 'post', - httpPath: '/v1/customMetadataFields', -},{ - clientCallName: 'client.customMetadataFields.update', - fullyQualifiedName: 'customMetadataFields.update', - httpMethod: 'patch', - httpPath: '/v1/customMetadataFields/{id}', -},{ - clientCallName: 'client.customMetadataFields.list', - fullyQualifiedName: 'customMetadataFields.list', - httpMethod: 'get', - httpPath: '/v1/customMetadataFields', -},{ - clientCallName: 'client.customMetadataFields.delete', - fullyQualifiedName: 'customMetadataFields.delete', - httpMethod: 'delete', - httpPath: '/v1/customMetadataFields/{id}', -},{ - clientCallName: 'client.files.update', - fullyQualifiedName: 'files.update', - httpMethod: 'patch', - httpPath: '/v1/files/{fileId}/details', -},{ - clientCallName: 'client.files.delete', - fullyQualifiedName: 'files.delete', - httpMethod: 'delete', - httpPath: '/v1/files/{fileId}', -},{ - clientCallName: 'client.files.copy', - fullyQualifiedName: 'files.copy', - httpMethod: 'post', - httpPath: '/v1/files/copy', -},{ - clientCallName: 'client.files.get', - fullyQualifiedName: 'files.get', - httpMethod: 'get', - httpPath: '/v1/files/{fileId}/details', -},{ - clientCallName: 'client.files.move', - fullyQualifiedName: 'files.move', - httpMethod: 'post', - httpPath: '/v1/files/move', -},{ - clientCallName: 'client.files.rename', - fullyQualifiedName: 'files.rename', - httpMethod: 'put', - httpPath: '/v1/files/rename', -},{ - clientCallName: 'client.files.upload', - fullyQualifiedName: 'files.upload', - httpMethod: 'post', - httpPath: '/api/v1/files/upload', -},{ - clientCallName: 'client.files.bulk.delete', - fullyQualifiedName: 'files.bulk.delete', - httpMethod: 'post', - httpPath: '/v1/files/batch/deleteByFileIds', -},{ - clientCallName: 'client.files.bulk.addTags', - fullyQualifiedName: 'files.bulk.addTags', - httpMethod: 'post', - httpPath: '/v1/files/addTags', -},{ - clientCallName: 'client.files.bulk.removeAITags', - fullyQualifiedName: 'files.bulk.removeAITags', - httpMethod: 'post', - httpPath: '/v1/files/removeAITags', -},{ - clientCallName: 'client.files.bulk.removeTags', - fullyQualifiedName: 'files.bulk.removeTags', - httpMethod: 'post', - httpPath: '/v1/files/removeTags', -},{ - clientCallName: 'client.files.versions.list', - fullyQualifiedName: 'files.versions.list', - httpMethod: 'get', - httpPath: '/v1/files/{fileId}/versions', -},{ - clientCallName: 'client.files.versions.delete', - fullyQualifiedName: 'files.versions.delete', - httpMethod: 'delete', - httpPath: '/v1/files/{fileId}/versions/{versionId}', -},{ - clientCallName: 'client.files.versions.get', - fullyQualifiedName: 'files.versions.get', - httpMethod: 'get', - httpPath: '/v1/files/{fileId}/versions/{versionId}', -},{ - clientCallName: 'client.files.versions.restore', - fullyQualifiedName: 'files.versions.restore', - httpMethod: 'put', - httpPath: '/v1/files/{fileId}/versions/{versionId}/restore', -},{ - clientCallName: 'client.files.metadata.get', - fullyQualifiedName: 'files.metadata.get', - httpMethod: 'get', - httpPath: '/v1/files/{fileId}/metadata', -},{ - clientCallName: 'client.files.metadata.getFromURL', - fullyQualifiedName: 'files.metadata.getFromURL', - httpMethod: 'get', - httpPath: '/v1/metadata', -},{ - clientCallName: 'client.savedExtensions.create', - fullyQualifiedName: 'savedExtensions.create', - httpMethod: 'post', - httpPath: '/v1/saved-extensions', -},{ - clientCallName: 'client.savedExtensions.update', - fullyQualifiedName: 'savedExtensions.update', - httpMethod: 'patch', - httpPath: '/v1/saved-extensions/{id}', -},{ - clientCallName: 'client.savedExtensions.list', - fullyQualifiedName: 'savedExtensions.list', - httpMethod: 'get', - httpPath: '/v1/saved-extensions', -},{ - clientCallName: 'client.savedExtensions.delete', - fullyQualifiedName: 'savedExtensions.delete', - httpMethod: 'delete', - httpPath: '/v1/saved-extensions/{id}', -},{ - clientCallName: 'client.savedExtensions.get', - fullyQualifiedName: 'savedExtensions.get', - httpMethod: 'get', - httpPath: '/v1/saved-extensions/{id}', -},{ - clientCallName: 'client.assets.list', - fullyQualifiedName: 'assets.list', - httpMethod: 'get', - httpPath: '/v1/files', -},{ - clientCallName: 'client.cache.invalidation.create', - fullyQualifiedName: 'cache.invalidation.create', - httpMethod: 'post', - httpPath: '/v1/files/purge', -},{ - clientCallName: 'client.cache.invalidation.get', - fullyQualifiedName: 'cache.invalidation.get', - httpMethod: 'get', - httpPath: '/v1/files/purge/{requestId}', -},{ - clientCallName: 'client.folders.create', - fullyQualifiedName: 'folders.create', - httpMethod: 'post', - httpPath: '/v1/folder', -},{ - clientCallName: 'client.folders.delete', - fullyQualifiedName: 'folders.delete', - httpMethod: 'delete', - httpPath: '/v1/folder', -},{ - clientCallName: 'client.folders.copy', - fullyQualifiedName: 'folders.copy', - httpMethod: 'post', - httpPath: '/v1/bulkJobs/copyFolder', -},{ - clientCallName: 'client.folders.move', - fullyQualifiedName: 'folders.move', - httpMethod: 'post', - httpPath: '/v1/bulkJobs/moveFolder', -},{ - clientCallName: 'client.folders.rename', - fullyQualifiedName: 'folders.rename', - httpMethod: 'post', - httpPath: '/v1/bulkJobs/renameFolder', -},{ - clientCallName: 'client.folders.job.get', - fullyQualifiedName: 'folders.job.get', - httpMethod: 'get', - httpPath: '/v1/bulkJobs/{jobId}', -},{ - clientCallName: 'client.accounts.usage.get', - fullyQualifiedName: 'accounts.usage.get', - httpMethod: 'get', - httpPath: '/v1/accounts/usage', -},{ - clientCallName: 'client.accounts.origins.create', - fullyQualifiedName: 'accounts.origins.create', - httpMethod: 'post', - httpPath: '/v1/accounts/origins', -},{ - clientCallName: 'client.accounts.origins.update', - fullyQualifiedName: 'accounts.origins.update', - httpMethod: 'put', - httpPath: '/v1/accounts/origins/{id}', -},{ - clientCallName: 'client.accounts.origins.list', - fullyQualifiedName: 'accounts.origins.list', - httpMethod: 'get', - httpPath: '/v1/accounts/origins', -},{ - clientCallName: 'client.accounts.origins.delete', - fullyQualifiedName: 'accounts.origins.delete', - httpMethod: 'delete', - httpPath: '/v1/accounts/origins/{id}', -},{ - clientCallName: 'client.accounts.origins.get', - fullyQualifiedName: 'accounts.origins.get', - httpMethod: 'get', - httpPath: '/v1/accounts/origins/{id}', -},{ - clientCallName: 'client.accounts.urlEndpoints.create', - fullyQualifiedName: 'accounts.urlEndpoints.create', - httpMethod: 'post', - httpPath: '/v1/accounts/url-endpoints', -},{ - clientCallName: 'client.accounts.urlEndpoints.update', - fullyQualifiedName: 'accounts.urlEndpoints.update', - httpMethod: 'put', - httpPath: '/v1/accounts/url-endpoints/{id}', -},{ - clientCallName: 'client.accounts.urlEndpoints.list', - fullyQualifiedName: 'accounts.urlEndpoints.list', - httpMethod: 'get', - httpPath: '/v1/accounts/url-endpoints', -},{ - clientCallName: 'client.accounts.urlEndpoints.delete', - fullyQualifiedName: 'accounts.urlEndpoints.delete', - httpMethod: 'delete', - httpPath: '/v1/accounts/url-endpoints/{id}', -},{ - clientCallName: 'client.accounts.urlEndpoints.get', - fullyQualifiedName: 'accounts.urlEndpoints.get', - httpMethod: 'get', - httpPath: '/v1/accounts/url-endpoints/{id}', -},{ - clientCallName: 'client.beta.v2.files.upload', - fullyQualifiedName: 'beta.v2.files.upload', - httpMethod: 'post', - httpPath: '/api/v2/files/upload', -},{ clientCallName: 'client.webhooks.unsafeUnwrap', fullyQualifiedName: 'webhooks.unsafeUnwrap' },{ clientCallName: 'client.webhooks.unwrap', fullyQualifiedName: 'webhooks.unwrap' }]; +export const sdkMethods: SdkMethod[] = [ + { + clientCallName: 'client.customMetadataFields.create', + fullyQualifiedName: 'customMetadataFields.create', + httpMethod: 'post', + httpPath: '/v1/customMetadataFields', + }, + { + clientCallName: 'client.customMetadataFields.update', + fullyQualifiedName: 'customMetadataFields.update', + httpMethod: 'patch', + httpPath: '/v1/customMetadataFields/{id}', + }, + { + clientCallName: 'client.customMetadataFields.list', + fullyQualifiedName: 'customMetadataFields.list', + httpMethod: 'get', + httpPath: '/v1/customMetadataFields', + }, + { + clientCallName: 'client.customMetadataFields.delete', + fullyQualifiedName: 'customMetadataFields.delete', + httpMethod: 'delete', + httpPath: '/v1/customMetadataFields/{id}', + }, + { + clientCallName: 'client.files.update', + fullyQualifiedName: 'files.update', + httpMethod: 'patch', + httpPath: '/v1/files/{fileId}/details', + }, + { + clientCallName: 'client.files.delete', + fullyQualifiedName: 'files.delete', + httpMethod: 'delete', + httpPath: '/v1/files/{fileId}', + }, + { + clientCallName: 'client.files.copy', + fullyQualifiedName: 'files.copy', + httpMethod: 'post', + httpPath: '/v1/files/copy', + }, + { + clientCallName: 'client.files.get', + fullyQualifiedName: 'files.get', + httpMethod: 'get', + httpPath: '/v1/files/{fileId}/details', + }, + { + clientCallName: 'client.files.move', + fullyQualifiedName: 'files.move', + httpMethod: 'post', + httpPath: '/v1/files/move', + }, + { + clientCallName: 'client.files.rename', + fullyQualifiedName: 'files.rename', + httpMethod: 'put', + httpPath: '/v1/files/rename', + }, + { + clientCallName: 'client.files.upload', + fullyQualifiedName: 'files.upload', + httpMethod: 'post', + httpPath: '/api/v1/files/upload', + }, + { + clientCallName: 'client.files.bulk.delete', + fullyQualifiedName: 'files.bulk.delete', + httpMethod: 'post', + httpPath: '/v1/files/batch/deleteByFileIds', + }, + { + clientCallName: 'client.files.bulk.addTags', + fullyQualifiedName: 'files.bulk.addTags', + httpMethod: 'post', + httpPath: '/v1/files/addTags', + }, + { + clientCallName: 'client.files.bulk.removeAITags', + fullyQualifiedName: 'files.bulk.removeAITags', + httpMethod: 'post', + httpPath: '/v1/files/removeAITags', + }, + { + clientCallName: 'client.files.bulk.removeTags', + fullyQualifiedName: 'files.bulk.removeTags', + httpMethod: 'post', + httpPath: '/v1/files/removeTags', + }, + { + clientCallName: 'client.files.versions.list', + fullyQualifiedName: 'files.versions.list', + httpMethod: 'get', + httpPath: '/v1/files/{fileId}/versions', + }, + { + clientCallName: 'client.files.versions.delete', + fullyQualifiedName: 'files.versions.delete', + httpMethod: 'delete', + httpPath: '/v1/files/{fileId}/versions/{versionId}', + }, + { + clientCallName: 'client.files.versions.get', + fullyQualifiedName: 'files.versions.get', + httpMethod: 'get', + httpPath: '/v1/files/{fileId}/versions/{versionId}', + }, + { + clientCallName: 'client.files.versions.restore', + fullyQualifiedName: 'files.versions.restore', + httpMethod: 'put', + httpPath: '/v1/files/{fileId}/versions/{versionId}/restore', + }, + { + clientCallName: 'client.files.metadata.get', + fullyQualifiedName: 'files.metadata.get', + httpMethod: 'get', + httpPath: '/v1/files/{fileId}/metadata', + }, + { + clientCallName: 'client.files.metadata.getFromURL', + fullyQualifiedName: 'files.metadata.getFromURL', + httpMethod: 'get', + httpPath: '/v1/metadata', + }, + { + clientCallName: 'client.savedExtensions.create', + fullyQualifiedName: 'savedExtensions.create', + httpMethod: 'post', + httpPath: '/v1/saved-extensions', + }, + { + clientCallName: 'client.savedExtensions.update', + fullyQualifiedName: 'savedExtensions.update', + httpMethod: 'patch', + httpPath: '/v1/saved-extensions/{id}', + }, + { + clientCallName: 'client.savedExtensions.list', + fullyQualifiedName: 'savedExtensions.list', + httpMethod: 'get', + httpPath: '/v1/saved-extensions', + }, + { + clientCallName: 'client.savedExtensions.delete', + fullyQualifiedName: 'savedExtensions.delete', + httpMethod: 'delete', + httpPath: '/v1/saved-extensions/{id}', + }, + { + clientCallName: 'client.savedExtensions.get', + fullyQualifiedName: 'savedExtensions.get', + httpMethod: 'get', + httpPath: '/v1/saved-extensions/{id}', + }, + { + clientCallName: 'client.assets.list', + fullyQualifiedName: 'assets.list', + httpMethod: 'get', + httpPath: '/v1/files', + }, + { + clientCallName: 'client.cache.invalidation.create', + fullyQualifiedName: 'cache.invalidation.create', + httpMethod: 'post', + httpPath: '/v1/files/purge', + }, + { + clientCallName: 'client.cache.invalidation.get', + fullyQualifiedName: 'cache.invalidation.get', + httpMethod: 'get', + httpPath: '/v1/files/purge/{requestId}', + }, + { + clientCallName: 'client.folders.create', + fullyQualifiedName: 'folders.create', + httpMethod: 'post', + httpPath: '/v1/folder', + }, + { + clientCallName: 'client.folders.delete', + fullyQualifiedName: 'folders.delete', + httpMethod: 'delete', + httpPath: '/v1/folder', + }, + { + clientCallName: 'client.folders.copy', + fullyQualifiedName: 'folders.copy', + httpMethod: 'post', + httpPath: '/v1/bulkJobs/copyFolder', + }, + { + clientCallName: 'client.folders.move', + fullyQualifiedName: 'folders.move', + httpMethod: 'post', + httpPath: '/v1/bulkJobs/moveFolder', + }, + { + clientCallName: 'client.folders.rename', + fullyQualifiedName: 'folders.rename', + httpMethod: 'post', + httpPath: '/v1/bulkJobs/renameFolder', + }, + { + clientCallName: 'client.folders.job.get', + fullyQualifiedName: 'folders.job.get', + httpMethod: 'get', + httpPath: '/v1/bulkJobs/{jobId}', + }, + { + clientCallName: 'client.accounts.usage.get', + fullyQualifiedName: 'accounts.usage.get', + httpMethod: 'get', + httpPath: '/v1/accounts/usage', + }, + { + clientCallName: 'client.accounts.origins.create', + fullyQualifiedName: 'accounts.origins.create', + httpMethod: 'post', + httpPath: '/v1/accounts/origins', + }, + { + clientCallName: 'client.accounts.origins.update', + fullyQualifiedName: 'accounts.origins.update', + httpMethod: 'put', + httpPath: '/v1/accounts/origins/{id}', + }, + { + clientCallName: 'client.accounts.origins.list', + fullyQualifiedName: 'accounts.origins.list', + httpMethod: 'get', + httpPath: '/v1/accounts/origins', + }, + { + clientCallName: 'client.accounts.origins.delete', + fullyQualifiedName: 'accounts.origins.delete', + httpMethod: 'delete', + httpPath: '/v1/accounts/origins/{id}', + }, + { + clientCallName: 'client.accounts.origins.get', + fullyQualifiedName: 'accounts.origins.get', + httpMethod: 'get', + httpPath: '/v1/accounts/origins/{id}', + }, + { + clientCallName: 'client.accounts.urlEndpoints.create', + fullyQualifiedName: 'accounts.urlEndpoints.create', + httpMethod: 'post', + httpPath: '/v1/accounts/url-endpoints', + }, + { + clientCallName: 'client.accounts.urlEndpoints.update', + fullyQualifiedName: 'accounts.urlEndpoints.update', + httpMethod: 'put', + httpPath: '/v1/accounts/url-endpoints/{id}', + }, + { + clientCallName: 'client.accounts.urlEndpoints.list', + fullyQualifiedName: 'accounts.urlEndpoints.list', + httpMethod: 'get', + httpPath: '/v1/accounts/url-endpoints', + }, + { + clientCallName: 'client.accounts.urlEndpoints.delete', + fullyQualifiedName: 'accounts.urlEndpoints.delete', + httpMethod: 'delete', + httpPath: '/v1/accounts/url-endpoints/{id}', + }, + { + clientCallName: 'client.accounts.urlEndpoints.get', + fullyQualifiedName: 'accounts.urlEndpoints.get', + httpMethod: 'get', + httpPath: '/v1/accounts/url-endpoints/{id}', + }, + { + clientCallName: 'client.beta.v2.files.upload', + fullyQualifiedName: 'beta.v2.files.upload', + httpMethod: 'post', + httpPath: '/api/v2/files/upload', + }, + { clientCallName: 'client.webhooks.unsafeUnwrap', fullyQualifiedName: 'webhooks.unsafeUnwrap' }, + { clientCallName: 'client.webhooks.unwrap', fullyQualifiedName: 'webhooks.unwrap' }, +]; function allowedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] | undefined { if (!options) { @@ -259,9 +309,9 @@ function allowedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] if (options.codeAllowHttpGets) { // Add all methods that map to an HTTP GET - sdkMethods.filter((method) => method.httpMethod === 'get').forEach( - (method) => allowedMethodsSet.add(method) - ); + sdkMethods + .filter((method) => method.httpMethod === 'get') + .forEach((method) => allowedMethodsSet.add(method)); } if (options.codeAllowedMethods) { @@ -270,13 +320,15 @@ function allowedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] try { return new RegExp(pattern); } catch (e) { - throw new Error(`Invalid regex pattern for allowed method: "${pattern}": ${e instanceof Error ? e.message : e}`); + throw new Error( + `Invalid regex pattern for allowed method: "${pattern}": ${e instanceof Error ? e.message : e}`, + ); } }); - sdkMethods.filter((method) => - allowedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName)) - ).forEach((method) => allowedMethodsSet.add(method)); + sdkMethods + .filter((method) => allowedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName))) + .forEach((method) => allowedMethodsSet.add(method)); } allowedMethods = Array.from(allowedMethodsSet); @@ -291,12 +343,14 @@ function allowedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] try { return new RegExp(pattern); } catch (e) { - throw new Error(`Invalid regex pattern for blocked method: "${pattern}": ${e instanceof Error ? e.message : e}`); + throw new Error( + `Invalid regex pattern for blocked method: "${pattern}": ${e instanceof Error ? e.message : e}`, + ); } }); - allowedMethods = allowedMethods.filter((method) => - !blockedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName)) + allowedMethods = allowedMethods.filter( + (method) => !blockedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName)), ); } diff --git a/packages/mcp-server/src/options.ts b/packages/mcp-server/src/options.ts index 873ab8e8..f1518764 100644 --- a/packages/mcp-server/src/options.ts +++ b/packages/mcp-server/src/options.ts @@ -31,31 +31,46 @@ export type McpCodeExecutionMode = 'stainless-sandbox' | 'local'; export function parseCLIOptions(): CLIOptions { const opts = yargs(hideBin(process.argv)) - .option('code-allow-http-gets', { type: 'boolean', description: 'Allow all code tool methods that map to HTTP GET operations. If all code-allow-* flags are unset, then everything is allowed.' }) + .option('code-allow-http-gets', { + type: 'boolean', + description: + 'Allow all code tool methods that map to HTTP GET operations. If all code-allow-* flags are unset, then everything is allowed.', + }) .option('code-allowed-methods', { type: 'string', array: true, - description: 'Methods to explicitly allow for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.', + description: + 'Methods to explicitly allow for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.', }) .option('code-blocked-methods', { type: 'string', array: true, - description: 'Methods to explicitly block for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.', + description: + 'Methods to explicitly block for code tool. Evaluated as regular expressions against method fully qualified names. If all code-allow-* flags are unset, then everything is allowed.', }) .option('code-execution-mode', { type: 'string', choices: ['stainless-sandbox', 'local'], default: 'stainless-sandbox', - description: 'Where to run code execution in code tool; \'stainless-sandbox\' will execute code in Stainless-hosted sandboxes whereas \'local\' will execute code locally on the MCP server machine.', + description: + "Where to run code execution in code tool; 'stainless-sandbox' will execute code in Stainless-hosted sandboxes whereas 'local' will execute code locally on the MCP server machine.", + }) + .option('custom-instructions-path', { + type: 'string', + description: 'Path to custom instructions for the MCP server', }) - .option('custom-instructions-path', { type: 'string', description: 'Path to custom instructions for the MCP server' }) .option('debug', { type: 'boolean', description: 'Enable debug logging' }) - .option('docs-dir', { type: 'string', description: 'Path to a directory of local documentation files (markdown/JSON) to include in local docs search.' }) + .option('docs-dir', { + type: 'string', + description: + 'Path to a directory of local documentation files (markdown/JSON) to include in local docs search.', + }) .option('docs-search-mode', { type: 'string', choices: ['stainless-api', 'local'], default: 'stainless-api', - description: 'Where to search documentation; \'stainless-api\' uses the Stainless-hosted search API whereas \'local\' uses an in-memory search index built from embedded SDK method data and optional local docs files.', + description: + "Where to search documentation; 'stainless-api' uses the Stainless-hosted search API whereas 'local' uses an in-memory search index built from embedded SDK method data and optional local docs files.", }) .option('log-format', { type: 'string', @@ -77,7 +92,8 @@ export function parseCLIOptions(): CLIOptions { .option('stainless-api-key', { type: 'string', default: readEnv('STAINLESS_API_KEY'), - description: 'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.', + description: + 'API key for Stainless. Used to authenticate requests to Stainless-hosted tools endpoints.', }) .option('tools', { type: 'string', @@ -98,15 +114,18 @@ export function parseCLIOptions(): CLIOptions { const argv = opts.parseSync(); const shouldIncludeToolType = (toolType: 'code' | 'docs') => - argv.noTools?.includes(toolType) ? false - : argv.tools?.includes(toolType) ? true - : undefined; + argv.noTools?.includes(toolType) ? false + : argv.tools?.includes(toolType) ? true + : undefined; const includeCodeTool = shouldIncludeToolType('code'); const includeDocsTools = shouldIncludeToolType('docs'); const transport = argv.transport as 'stdio' | 'http'; - const logFormat = argv.logFormat ? argv.logFormat as 'json' | 'pretty' : (process.stderr.isTTY ? 'pretty' : 'json'); + const logFormat = + argv.logFormat ? (argv.logFormat as 'json' | 'pretty') + : process.stderr.isTTY ? 'pretty' + : 'json'; return { ...(includeCodeTool !== undefined && { includeCodeTool }), @@ -147,8 +166,8 @@ export function parseQueryOptions(defaultOptions: McpOptions, query: unknown): M const queryOptions = QueryOptions.parse(queryObject); let codeTool: boolean | undefined = - queryOptions.no_tools && queryOptions.no_tools?.includes("code") ? false - : queryOptions.tools?.includes("code") ? true + queryOptions.no_tools && queryOptions.no_tools?.includes('code') ? false + : queryOptions.tools?.includes('code') ? true : defaultOptions.includeCodeTool; let docsTools: boolean | undefined = diff --git a/packages/mcp-server/src/server.ts b/packages/mcp-server/src/server.ts index 1d4c4b21..4668d948 100644 --- a/packages/mcp-server/src/server.ts +++ b/packages/mcp-server/src/server.ts @@ -3,7 +3,9 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { - CallToolRequestSchema,ListToolsRequestSchema,SetLevelRequestSchema + CallToolRequestSchema, + ListToolsRequestSchema, + SetLevelRequestSchema, } from '@modelcontextprotocol/sdk/types.js'; import { ClientOptions } from '@imagekit/nodejs'; import ImageKit from '@imagekit/nodejs'; @@ -14,24 +16,25 @@ import { LocalDocsSearch } from './local-docs-search'; import { getInstructions } from './instructions'; import { McpOptions } from './options'; import { blockedMethodsForCodeTool } from './methods'; -import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from "./types" +import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from './types'; export const newMcpServer = async ({ stainlessApiKey, customInstructionsPath, }: { - stainlessApiKey?: string | undefined, - customInstructionsPath?: string | undefined, -}) => new McpServer( - { - name: 'imagekit_nodejs_api', - version: '7.5.0', - }, - { - instructions: await getInstructions({stainlessApiKey, customInstructionsPath}), - capabilities: { tools: {}, logging: {} }, - } -); + stainlessApiKey?: string | undefined; + customInstructionsPath?: string | undefined; +}) => + new McpServer( + { + name: 'imagekit_nodejs_api', + version: '7.5.0', + }, + { + instructions: await getInstructions({ stainlessApiKey, customInstructionsPath }), + capabilities: { tools: {}, logging: {} }, + }, + ); /** * Initializes the provided MCP Server with the given tools and handlers. @@ -53,15 +56,15 @@ export async function initMcpServer(params: { (message: string, ...rest: unknown[]) => { void server.sendLoggingMessage({ level, - data: {message, rest}, + data: { message, rest }, }); - } + }; const logger = { - debug: logAtLevel("debug"), - info: logAtLevel("info"), - warn: logAtLevel("warning"), - error: logAtLevel("error"), - } + debug: logAtLevel('debug'), + info: logAtLevel('info'), + warn: logAtLevel('warning'), + error: logAtLevel('error'), + }; if (params.mcpOptions?.docsSearchMode === 'local') { const docsDir = params.mcpOptions?.docsDir; @@ -78,14 +81,13 @@ export async function initMcpServer(params: { if (!_client) { try { _client = new ImageKit({ - - logger, - ...params.clientOptions, - defaultHeaders: { - ...params.clientOptions?.defaultHeaders, - 'X-Stainless-MCP': 'true', - }, -}); + logger, + ...params.clientOptions, + defaultHeaders: { + ...params.clientOptions?.defaultHeaders, + 'X-Stainless-MCP': 'true', + }, + }); if (_logLevel) { _client = _client.withOptions({ logLevel: _logLevel }); } @@ -118,10 +120,12 @@ export async function initMcpServer(params: { client = getClient(); } catch (error) { return { - content: [{ - type: 'text' as const, - text: `Failed to initialize client: ${error instanceof Error ? error.message : String(error)}`, - }], + content: [ + { + type: 'text' as const, + text: `Failed to initialize client: ${error instanceof Error ? error.message : String(error)}`, + }, + ], isError: true, }; } @@ -171,17 +175,16 @@ export async function initMcpServer(params: { /** * Selects the tools to include in the MCP Server based on the provided options. */ -export function selectTools( - options?: McpOptions -): McpTool[] { - +export function selectTools(options?: McpOptions): McpTool[] { const includedTools = []; if (options?.includeCodeTool ?? true) { - includedTools.push(codeTool({ - blockedMethods: blockedMethodsForCodeTool(options), - codeExecutionMode: options?.codeExecutionMode ?? 'stainless-sandbox', - })); + includedTools.push( + codeTool({ + blockedMethods: blockedMethodsForCodeTool(options), + codeExecutionMode: options?.codeExecutionMode ?? 'stainless-sandbox', + }), + ); } if (options?.includeDocsTools ?? true) { includedTools.push(docsSearchTool); @@ -192,13 +195,14 @@ export function selectTools( /** * Runs the provided handler with the given client and arguments. */ -export async function executeHandler( - {handler, reqContext, args}: - { - handler: HandlerFunction; - reqContext: McpRequestContext; - args: Record | undefined; - } -): Promise { - return await handler({reqContext, args: args || {}}); +export async function executeHandler({ + handler, + reqContext, + args, +}: { + handler: HandlerFunction; + reqContext: McpRequestContext; + args: Record | undefined; +}): Promise { + return await handler({ reqContext, args: args || {} }); } diff --git a/packages/mcp-server/src/types.ts b/packages/mcp-server/src/types.ts index 56d44ef4..32be9c01 100644 --- a/packages/mcp-server/src/types.ts +++ b/packages/mcp-server/src/types.ts @@ -4,41 +4,43 @@ import ImageKit from '@imagekit/nodejs'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; type TextContentBlock = { - type: "text", - text: string -} + type: 'text'; + text: string; +}; type ImageContentBlock = { - type: "image", - data: string, - mimeType: string -} + type: 'image'; + data: string; + mimeType: string; +}; type AudioContentBlock = { - type: "audio", - data: string, - mimeType: string -} + type: 'audio'; + data: string; + mimeType: string; +}; type ResourceContentBlock = { - type: "resource", - resource: { - uri: string, - mimeType: string, - text: string - } | { - uri: string, - mimeType: string, - blob: string - } -} + type: 'resource'; + resource: + | { + uri: string; + mimeType: string; + text: string; + } + | { + uri: string; + mimeType: string; + blob: string; + }; +}; export type ContentBlock = TextContentBlock | ImageContentBlock | AudioContentBlock | ResourceContentBlock; export type ToolCallResult = { content: ContentBlock[]; isError?: boolean; -} +}; export type McpRequestContext = { client: ImageKit; @@ -46,7 +48,7 @@ export type McpRequestContext = { upstreamClientEnvs?: Record | undefined; mcpSessionId?: string | undefined; mcpClientInfo?: { name: string; version: string } | undefined; -} +}; export type HandlerFunction = ({ reqContext, @@ -56,9 +58,7 @@ export type HandlerFunction = ({ args: Record | undefined; }) => Promise; -export function asTextContentResult( - result: unknown, -): ToolCallResult { +export function asTextContentResult(result: unknown): ToolCallResult { return { content: [ { @@ -69,24 +69,18 @@ export function asTextContentResult( }; } -export async function asBinaryContentResult( - response: Response, -): Promise { +export async function asBinaryContentResult(response: Response): Promise { const blob = await response.blob(); const mimeType = blob.type; const data = Buffer.from(await blob.arrayBuffer()).toString('base64'); if (mimeType.startsWith('image/')) { return { - content: [ - {type: 'image', mimeType, data} - ] - } + content: [{ type: 'image', mimeType, data }], + }; } else if (mimeType.startsWith('audio/')) { return { - content: [ - {type: 'audio', mimeType, data} - ] - } + content: [{ type: 'audio', mimeType, data }], + }; } else { return { content: [ @@ -104,9 +98,7 @@ export async function asBinaryContentResult( } } -export function asErrorResult( - message: string -): ToolCallResult { +export function asErrorResult(message: string): ToolCallResult { return { content: [ { @@ -128,7 +120,7 @@ export type Metadata = { }; export type McpTool = { - metadata: Metadata, - tool: Tool, - handler: HandlerFunction + metadata: Metadata; + tool: Tool; + handler: HandlerFunction; }; diff --git a/scripts/fast-format b/scripts/fast-format index e1723136..53721ac0 100755 --- a/scripts/fast-format +++ b/scripts/fast-format @@ -31,8 +31,10 @@ if ! [ -z "$ESLINT_FILES" ]; then fi echo "==> Running prettier --write" -PRETTIER_FILES="$(grep '\.\([mc]?tsx?\|[mc]?jsx?\|json\)$' "$FILE_LIST" || true)" +# format things eslint didn't +PRETTIER_FILES="$(grep '\.\(js\|json\)$' "$FILE_LIST" || true)" if ! [ -z "$PRETTIER_FILES" ]; then echo "$PRETTIER_FILES" | xargs ./node_modules/.bin/prettier \ - --write --cache --cache-strategy metadata --no-error-on-unmatched-pattern + --write --cache --cache-strategy metadata --no-error-on-unmatched-pattern \ + '!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs' fi diff --git a/scripts/format b/scripts/format index b1b2c17a..7a756401 100755 --- a/scripts/format +++ b/scripts/format @@ -8,4 +8,5 @@ echo "==> Running eslint --fix" ./node_modules/.bin/eslint --fix . echo "==> Running prettier --write" -./node_modules/.bin/prettier --write --cache --cache-strategy metadata . +# format things eslint didn't +./node_modules/.bin/prettier --write --cache --cache-strategy metadata . '!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs' diff --git a/scripts/lint b/scripts/lint index 1f532548..3ffb78a6 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,9 +4,6 @@ set -e cd "$(dirname "$0")/.." -echo "==> Running prettier --check" -./node_modules/.bin/prettier --check . - echo "==> Running eslint" ./node_modules/.bin/eslint . diff --git a/scripts/utils/postprocess-files.cjs b/scripts/utils/postprocess-files.cjs index deae575e..a8cdeb7c 100644 --- a/scripts/utils/postprocess-files.cjs +++ b/scripts/utils/postprocess-files.cjs @@ -23,12 +23,19 @@ async function postprocess() { // strip out lib="dom", types="node", and types="react" references; these // are needed at build time, but would pollute the user's TS environment - const transformed = code.replace( + let transformed = code.replace( /^ *\/\/\/ * ' '.repeat(match.length - 1) + '\n', ); + // TypeScript's declaration emitter collapses /** @ts-ignore */ onto the same + // line as the type declaration, which doesn't work. So we convert to // @ts-ignore + // on its own line to properly suppresses errors. + if (file.endsWith('.d.ts') || file.endsWith('.d.mts') || file.endsWith('.d.cts')) { + transformed = transformed.replace(/\/\*\* @ts-ignore\b[^*]*\*\/ /gm, '// @ts-ignore\n'); + } + if (transformed !== code) { console.error(`wrote ${path.relative(process.cwd(), file)}`); await fs.promises.writeFile(file, transformed, 'utf8'); diff --git a/src/api-promise.ts b/src/api-promise.ts index 4e701286..8c775ee6 100644 --- a/src/api-promise.ts +++ b/src/api-promise.ts @@ -1,2 +1,2 @@ /** @deprecated Import from ./core/api-promise instead */ -export * from "./core/api-promise" \ No newline at end of file +export * from './core/api-promise'; diff --git a/src/client.ts b/src/client.ts index c9f630e3..77700f16 100644 --- a/src/client.ts +++ b/src/client.ts @@ -18,20 +18,84 @@ import * as Uploads from './core/uploads'; import * as API from './resources/index'; import { APIPromise } from './core/api-promise'; import { AssetListParams, AssetListResponse, Assets } from './resources/assets'; -import { CustomMetadataField, CustomMetadataFieldCreateParams, CustomMetadataFieldDeleteResponse, CustomMetadataFieldListParams, CustomMetadataFieldListResponse, CustomMetadataFieldUpdateParams, CustomMetadataFields } from './resources/custom-metadata-fields'; -import { SavedExtensionCreateParams, SavedExtensionListResponse, SavedExtensionUpdateParams, SavedExtensions } from './resources/saved-extensions'; -import { BaseWebhookEvent, FileCreateEvent, FileDeleteEvent, FileUpdateEvent, FileVersionCreateEvent, FileVersionDeleteEvent, UnsafeUnwrapWebhookEvent, UnwrapWebhookEvent, UploadPostTransformErrorEvent, UploadPostTransformSuccessEvent, UploadPreTransformErrorEvent, UploadPreTransformSuccessEvent, VideoTransformationAcceptedEvent, VideoTransformationErrorEvent, VideoTransformationReadyEvent, Webhooks } from './resources/webhooks'; +import { + CustomMetadataField, + CustomMetadataFieldCreateParams, + CustomMetadataFieldDeleteResponse, + CustomMetadataFieldListParams, + CustomMetadataFieldListResponse, + CustomMetadataFieldUpdateParams, + CustomMetadataFields, +} from './resources/custom-metadata-fields'; +import { + SavedExtensionCreateParams, + SavedExtensionListResponse, + SavedExtensionUpdateParams, + SavedExtensions, +} from './resources/saved-extensions'; +import { + BaseWebhookEvent, + FileCreateEvent, + FileDeleteEvent, + FileUpdateEvent, + FileVersionCreateEvent, + FileVersionDeleteEvent, + UnsafeUnwrapWebhookEvent, + UnwrapWebhookEvent, + UploadPostTransformErrorEvent, + UploadPostTransformSuccessEvent, + UploadPreTransformErrorEvent, + UploadPreTransformSuccessEvent, + VideoTransformationAcceptedEvent, + VideoTransformationErrorEvent, + VideoTransformationReadyEvent, + Webhooks, +} from './resources/webhooks'; import { Accounts } from './resources/accounts/accounts'; import { Beta } from './resources/beta/beta'; import { Cache } from './resources/cache/cache'; -import { File, FileCopyParams, FileCopyResponse, FileMoveParams, FileMoveResponse, FileRenameParams, FileRenameResponse, FileUpdateParams, FileUpdateResponse, FileUploadParams, FileUploadResponse, Files, Folder, Metadata, UpdateFileRequest } from './resources/files/files'; -import { FolderCopyParams, FolderCopyResponse, FolderCreateParams, FolderCreateResponse, FolderDeleteParams, FolderDeleteResponse, FolderMoveParams, FolderMoveResponse, FolderRenameParams, FolderRenameResponse, Folders } from './resources/folders/folders'; +import { + File, + FileCopyParams, + FileCopyResponse, + FileMoveParams, + FileMoveResponse, + FileRenameParams, + FileRenameResponse, + FileUpdateParams, + FileUpdateResponse, + FileUploadParams, + FileUploadResponse, + Files, + Folder, + Metadata, + UpdateFileRequest, +} from './resources/files/files'; +import { + FolderCopyParams, + FolderCopyResponse, + FolderCreateParams, + FolderCreateResponse, + FolderDeleteParams, + FolderDeleteResponse, + FolderMoveParams, + FolderMoveResponse, + FolderRenameParams, + FolderRenameResponse, + Folders, +} from './resources/folders/folders'; import { type Fetch } from './internal/builtin-types'; import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers'; import { FinalRequestOptions, RequestOptions } from './internal/request-options'; import { toBase64 } from './internal/utils/base64'; import { readEnv } from './internal/utils/env'; -import { type LogLevel, type Logger, formatRequestDetails, loggerFor, parseLogLevel } from './internal/utils/log'; +import { + type LogLevel, + type Logger, + formatRequestDetails, + loggerFor, + parseLogLevel, +} from './internal/utils/log'; import { isEmptyObj } from './internal/utils/values'; export interface ClientOptions { @@ -43,7 +107,7 @@ export interface ClientOptions { privateKey?: string | undefined; /** - * ImageKit uses your API key as username and ignores the password. + * ImageKit uses your API key as username and ignores the password. * The SDK sets a dummy value. You can ignore this field. * */ @@ -127,7 +191,7 @@ export interface ClientOptions { } /** - * API Client for interfacing with the Image Kit API. + * API Client for interfacing with the Image Kit API. */ export class ImageKit { privateKey: string; @@ -169,7 +233,7 @@ export class ImageKit { }: ClientOptions = {}) { if (privateKey === undefined) { throw new Errors.ImageKitError( - 'The IMAGEKIT_PRIVATE_KEY environment variable is missing or empty; either provide it, or instantiate the ImageKit client with an privateKey option, like new ImageKit({ privateKey: \'My Private Key\' }).' + "The IMAGEKIT_PRIVATE_KEY environment variable is missing or empty; either provide it, or instantiate the ImageKit client with an privateKey option, like new ImageKit({ privateKey: 'My Private Key' }).", ); } @@ -187,7 +251,10 @@ export class ImageKit { const defaultLogLevel = 'warn'; // Set default logLevel early so that we can log a warning in parseLogLevel. this.logLevel = defaultLogLevel; - this.logLevel = parseLogLevel(options.logLevel, 'ClientOptions.logLevel', this) ?? parseLogLevel(readEnv('IMAGE_KIT_LOG'), 'process.env[\'IMAGE_KIT_LOG\']', this) ?? defaultLogLevel; + this.logLevel = + parseLogLevel(options.logLevel, 'ClientOptions.logLevel', this) ?? + parseLogLevel(readEnv('IMAGE_KIT_LOG'), "process.env['IMAGE_KIT_LOG']", this) ?? + defaultLogLevel; this.fetchOptions = options.fetchOptions; this.maxRetries = options.maxRetries ?? 2; this.fetch = options.fetch ?? Shims.getDefaultFetch(); @@ -216,7 +283,7 @@ export class ImageKit { privateKey: this.privateKey, password: this.password, webhookSecret: this.webhookSecret, - ...options + ...options, }); return client; } @@ -229,7 +296,7 @@ export class ImageKit { } protected defaultQuery(): Record | undefined { - return this._options.defaultQuery + return this._options.defaultQuery; } protected validateHeaders({ values, nulls }: NullableHeaders) { @@ -240,7 +307,9 @@ export class ImageKit { return; } - throw new Error('Could not resolve authentication method. Expected the privateKey or password to be set. Or for the "Authorization" headers to be explicitly omitted') + throw new Error( + 'Could not resolve authentication method. Expected the privateKey or password to be set. Or for the "Authorization" headers to be explicitly omitted', + ); } protected async authHeaders(opts: FinalRequestOptions): Promise { @@ -252,9 +321,9 @@ export class ImageKit { return undefined; } - const credentials = `${this.privateKey}:${this.password}` - const Authorization = `Basic ${toBase64(credentials)}` - return buildHeaders([{ Authorization }]) + const credentials = `${this.privateKey}:${this.password}`; + const Authorization = `Basic ${toBase64(credentials)}`; + return buildHeaders([{ Authorization }]); } /** @@ -281,7 +350,11 @@ export class ImageKit { return Errors.APIError.generate(status, error, message, headers); } - buildURL(path: string, query: Record | null | undefined, defaultBaseURL?: string | undefined): string { + buildURL( + path: string, + query: Record | null | undefined, + defaultBaseURL?: string | undefined, + ): string { const baseURL = (!this.#baseURLOverridden() && defaultBaseURL) || this.baseURL; const url = isAbsoluteURL(path) ? @@ -369,7 +442,9 @@ export class ImageKit { await this.prepareOptions(options); - const { req, url, timeout } = await this.buildRequest(options, { retryCount: maxRetries - retriesRemaining }); + const { req, url, timeout } = await this.buildRequest(options, { + retryCount: maxRetries - retriesRemaining, + }); await this.prepareRequest(req, { url, options }); @@ -378,7 +453,16 @@ export class ImageKit { const retryLogStr = retryOfRequestLogID === undefined ? '' : `, retryOf: ${retryOfRequestLogID}`; const startTime = Date.now(); - loggerFor(this).debug(`[${requestLogID}] sending request`, formatRequestDetails({ retryOfRequestLogID, method: options.method, url, options, headers: req.headers })); + loggerFor(this).debug( + `[${requestLogID}] sending request`, + formatRequestDetails({ + retryOfRequestLogID, + method: options.method, + url, + options, + headers: req.headers, + }), + ); if (options.signal?.aborted) { throw new Errors.APIUserAbortError(); @@ -397,21 +481,45 @@ export class ImageKit { // deno throws "TypeError: error sending request for url (https://example/): client error (Connect): tcp connect error: Operation timed out (os error 60): Operation timed out (os error 60)" // undici throws "TypeError: fetch failed" with cause "ConnectTimeoutError: Connect Timeout Error (attempted address: example:443, timeout: 1ms)" // others do not provide enough information to distinguish timeouts from other connection errors - const isTimeout = isAbortError(response) || /timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : '')) + const isTimeout = + isAbortError(response) || + /timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : '')); if (retriesRemaining) { - loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`) - loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${retryMessage})`, formatRequestDetails({ retryOfRequestLogID, url, durationMs: headersTime - startTime, message: response.message })); + loggerFor(this).info( + `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`, + ); + loggerFor(this).debug( + `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${retryMessage})`, + formatRequestDetails({ + retryOfRequestLogID, + url, + durationMs: headersTime - startTime, + message: response.message, + }), + ); return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID); } - loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - error; no more retries left`) - loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (error; no more retries left)`, formatRequestDetails({ retryOfRequestLogID, url, durationMs: headersTime - startTime, message: response.message })); + loggerFor(this).info( + `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - error; no more retries left`, + ); + loggerFor(this).debug( + `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (error; no more retries left)`, + formatRequestDetails({ + retryOfRequestLogID, + url, + durationMs: headersTime - startTime, + message: response.message, + }), + ); if (isTimeout) { throw new Errors.APIConnectionTimeoutError(); } throw new Errors.APIConnectionError({ cause: response }); } - const responseInfo = `[${requestLogID}${retryLogStr}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`; + const responseInfo = `[${requestLogID}${retryLogStr}] ${req.method} ${url} ${ + response.ok ? 'succeeded' : 'failed' + } with status ${response.status} in ${headersTime - startTime}ms`; if (!response.ok) { const shouldRetry = await this.shouldRetry(response); @@ -420,27 +528,60 @@ export class ImageKit { // We don't need the body of this response. await Shims.CancelReadableStream(response.body); - loggerFor(this).info(`${responseInfo} - ${retryMessage}`) - loggerFor(this).debug(`[${requestLogID}] response error (${retryMessage})`, formatRequestDetails({ retryOfRequestLogID, url: response.url, status: response.status, headers: response.headers, durationMs: headersTime - startTime })); - return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID, response.headers); + loggerFor(this).info(`${responseInfo} - ${retryMessage}`); + loggerFor(this).debug( + `[${requestLogID}] response error (${retryMessage})`, + formatRequestDetails({ + retryOfRequestLogID, + url: response.url, + status: response.status, + headers: response.headers, + durationMs: headersTime - startTime, + }), + ); + return this.retryRequest( + options, + retriesRemaining, + retryOfRequestLogID ?? requestLogID, + response.headers, + ); } const retryMessage = shouldRetry ? `error; no more retries left` : `error; not retryable`; - loggerFor(this).info(`${responseInfo} - ${retryMessage}`) + loggerFor(this).info(`${responseInfo} - ${retryMessage}`); const errText = await response.text().catch((err: any) => castToError(err).message); const errJSON = safeJSON(errText) as any; const errMessage = errJSON ? undefined : errText; - loggerFor(this).debug(`[${requestLogID}] response error (${retryMessage})`, formatRequestDetails({ retryOfRequestLogID, url: response.url, status: response.status, headers: response.headers, message: errMessage, durationMs: Date.now() - startTime })); + loggerFor(this).debug( + `[${requestLogID}] response error (${retryMessage})`, + formatRequestDetails({ + retryOfRequestLogID, + url: response.url, + status: response.status, + headers: response.headers, + message: errMessage, + durationMs: Date.now() - startTime, + }), + ); const err = this.makeStatusError(response.status, errJSON, errMessage, response.headers); throw err; } - loggerFor(this).info(responseInfo) - loggerFor(this).debug(`[${requestLogID}] response start`, formatRequestDetails({ retryOfRequestLogID, url: response.url, status: response.status, headers: response.headers, durationMs: headersTime - startTime })); + loggerFor(this).info(responseInfo); + loggerFor(this).debug( + `[${requestLogID}] response start`, + formatRequestDetails({ + retryOfRequestLogID, + url: response.url, + status: response.status, + headers: response.headers, + durationMs: headersTime - startTime, + }), + ); return { response, options, controller, requestLogID, retryOfRequestLogID, startTime }; } @@ -457,7 +598,9 @@ export class ImageKit { const timeout = setTimeout(abort, ms); - const isReadableBody = ((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) || (typeof options.body === "object" && options.body !== null && Symbol.asyncIterator in options.body); + const isReadableBody = + ((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) || + (typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body); const fetchOptions: RequestInit = { signal: controller.signal as any, @@ -472,7 +615,6 @@ export class ImageKit { } try { - // use undefined this binding; fetch errors if bound to something else in browser/cloudflare return await this.fetch.call(undefined, url, fetchOptions); } finally { @@ -573,11 +715,12 @@ export class ImageKit { const req: FinalizedRequestInit = { method, headers: reqHeaders, - ...(options.signal && { signal: options.signal}), - ...((globalThis as any).ReadableStream && body instanceof (globalThis as any).ReadableStream && { duplex: "half" }), + ...(options.signal && { signal: options.signal }), + ...((globalThis as any).ReadableStream && + body instanceof (globalThis as any).ReadableStream && { duplex: 'half' }), ...(body && { body }), - ...(this.fetchOptions as any ?? {}), - ...(options.fetchOptions as any ?? {}), + ...((this.fetchOptions as any) ?? {}), + ...((options.fetchOptions as any) ?? {}), }; return { req, url, timeout: options.timeout }; @@ -602,15 +745,17 @@ export class ImageKit { const headers = buildHeaders([ idempotencyHeaders, - {Accept: 'application/json', - 'User-Agent': this.getUserAgent(), - 'X-Stainless-Retry-Count': String(retryCount), - ...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}), - ...getPlatformHeaders()}, + { + Accept: 'application/json', + 'User-Agent': this.getUserAgent(), + 'X-Stainless-Retry-Count': String(retryCount), + ...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}), + ...getPlatformHeaders(), + }, await this.authHeaders(options), this._options.defaultHeaders, bodyHeaders, - options.headers + options.headers, ]); this.validateHeaders(headers); @@ -637,11 +782,9 @@ export class ImageKit { ArrayBuffer.isView(body) || body instanceof ArrayBuffer || body instanceof DataView || - ( - typeof body === 'string' && + (typeof body === 'string' && // Preserve legacy string encoding behavior for now - headers.values.has('content-type') - ) || + headers.values.has('content-type')) || // `Blob` is superset of `File` ((globalThis as any).Blob && body instanceof (globalThis as any).Blob) || // `FormData` -> `multipart/form-data` @@ -672,7 +815,7 @@ export class ImageKit { } static ImageKit = this; - static DEFAULT_TIMEOUT = 60000 // 1 minute + static DEFAULT_TIMEOUT = 60000; // 1 minute static ImageKitError = Errors.ImageKitError; static APIError = Errors.APIError; @@ -713,113 +856,107 @@ ImageKit.Beta = Beta; ImageKit.Webhooks = Webhooks; export declare namespace ImageKit { - export type RequestOptions = Opts.RequestOptions; - - export { - CustomMetadataFields as CustomMetadataFields, - type CustomMetadataField as CustomMetadataField, - type CustomMetadataFieldListResponse as CustomMetadataFieldListResponse, - type CustomMetadataFieldDeleteResponse as CustomMetadataFieldDeleteResponse, - type CustomMetadataFieldCreateParams as CustomMetadataFieldCreateParams, - type CustomMetadataFieldUpdateParams as CustomMetadataFieldUpdateParams, - type CustomMetadataFieldListParams as CustomMetadataFieldListParams -}; - -export { - Files as Files, - type File as File, - type Folder as Folder, - type Metadata as Metadata, - type UpdateFileRequest as UpdateFileRequest, - type FileUpdateResponse as FileUpdateResponse, - type FileCopyResponse as FileCopyResponse, - type FileMoveResponse as FileMoveResponse, - type FileRenameResponse as FileRenameResponse, - type FileUploadResponse as FileUploadResponse, - type FileUpdateParams as FileUpdateParams, - type FileCopyParams as FileCopyParams, - type FileMoveParams as FileMoveParams, - type FileRenameParams as FileRenameParams, - type FileUploadParams as FileUploadParams -}; - -export { - SavedExtensions as SavedExtensions, - type SavedExtensionListResponse as SavedExtensionListResponse, - type SavedExtensionCreateParams as SavedExtensionCreateParams, - type SavedExtensionUpdateParams as SavedExtensionUpdateParams -}; - -export { - Assets as Assets, - type AssetListResponse as AssetListResponse, - type AssetListParams as AssetListParams -}; - -export { - Cache as Cache -}; - -export { - Folders as Folders, - type FolderCreateResponse as FolderCreateResponse, - type FolderDeleteResponse as FolderDeleteResponse, - type FolderCopyResponse as FolderCopyResponse, - type FolderMoveResponse as FolderMoveResponse, - type FolderRenameResponse as FolderRenameResponse, - type FolderCreateParams as FolderCreateParams, - type FolderDeleteParams as FolderDeleteParams, - type FolderCopyParams as FolderCopyParams, - type FolderMoveParams as FolderMoveParams, - type FolderRenameParams as FolderRenameParams -}; - -export { - Accounts as Accounts -}; - -export { - Beta as Beta -}; - -export { - Webhooks as Webhooks, - type BaseWebhookEvent as BaseWebhookEvent, - type FileCreateEvent as FileCreateEvent, - type FileDeleteEvent as FileDeleteEvent, - type FileUpdateEvent as FileUpdateEvent, - type FileVersionCreateEvent as FileVersionCreateEvent, - type FileVersionDeleteEvent as FileVersionDeleteEvent, - type UploadPostTransformErrorEvent as UploadPostTransformErrorEvent, - type UploadPostTransformSuccessEvent as UploadPostTransformSuccessEvent, - type UploadPreTransformErrorEvent as UploadPreTransformErrorEvent, - type UploadPreTransformSuccessEvent as UploadPreTransformSuccessEvent, - type VideoTransformationAcceptedEvent as VideoTransformationAcceptedEvent, - type VideoTransformationErrorEvent as VideoTransformationErrorEvent, - type VideoTransformationReadyEvent as VideoTransformationReadyEvent, - type UnsafeUnwrapWebhookEvent as UnsafeUnwrapWebhookEvent, - type UnwrapWebhookEvent as UnwrapWebhookEvent -}; - -export type BaseOverlay = API.BaseOverlay; -export type ExtensionConfig = API.ExtensionConfig; -export type Extensions = API.Extensions; -export type GetImageAttributesOptions = API.GetImageAttributesOptions; -export type ImageOverlay = API.ImageOverlay; -export type Overlay = API.Overlay; -export type OverlayPosition = API.OverlayPosition; -export type OverlayTiming = API.OverlayTiming; -export type ResponsiveImageAttributes = API.ResponsiveImageAttributes; -export type SavedExtension = API.SavedExtension; -export type SolidColorOverlay = API.SolidColorOverlay; -export type SolidColorOverlayTransformation = API.SolidColorOverlayTransformation; -export type SrcOptions = API.SrcOptions; -export type StreamingResolution = API.StreamingResolution; -export type SubtitleOverlay = API.SubtitleOverlay; -export type SubtitleOverlayTransformation = API.SubtitleOverlayTransformation; -export type TextOverlay = API.TextOverlay; -export type TextOverlayTransformation = API.TextOverlayTransformation; -export type Transformation = API.Transformation; -export type TransformationPosition = API.TransformationPosition; -export type VideoOverlay = API.VideoOverlay; - } + export type RequestOptions = Opts.RequestOptions; + + export { + CustomMetadataFields as CustomMetadataFields, + type CustomMetadataField as CustomMetadataField, + type CustomMetadataFieldListResponse as CustomMetadataFieldListResponse, + type CustomMetadataFieldDeleteResponse as CustomMetadataFieldDeleteResponse, + type CustomMetadataFieldCreateParams as CustomMetadataFieldCreateParams, + type CustomMetadataFieldUpdateParams as CustomMetadataFieldUpdateParams, + type CustomMetadataFieldListParams as CustomMetadataFieldListParams, + }; + + export { + Files as Files, + type File as File, + type Folder as Folder, + type Metadata as Metadata, + type UpdateFileRequest as UpdateFileRequest, + type FileUpdateResponse as FileUpdateResponse, + type FileCopyResponse as FileCopyResponse, + type FileMoveResponse as FileMoveResponse, + type FileRenameResponse as FileRenameResponse, + type FileUploadResponse as FileUploadResponse, + type FileUpdateParams as FileUpdateParams, + type FileCopyParams as FileCopyParams, + type FileMoveParams as FileMoveParams, + type FileRenameParams as FileRenameParams, + type FileUploadParams as FileUploadParams, + }; + + export { + SavedExtensions as SavedExtensions, + type SavedExtensionListResponse as SavedExtensionListResponse, + type SavedExtensionCreateParams as SavedExtensionCreateParams, + type SavedExtensionUpdateParams as SavedExtensionUpdateParams, + }; + + export { + Assets as Assets, + type AssetListResponse as AssetListResponse, + type AssetListParams as AssetListParams, + }; + + export { Cache as Cache }; + + export { + Folders as Folders, + type FolderCreateResponse as FolderCreateResponse, + type FolderDeleteResponse as FolderDeleteResponse, + type FolderCopyResponse as FolderCopyResponse, + type FolderMoveResponse as FolderMoveResponse, + type FolderRenameResponse as FolderRenameResponse, + type FolderCreateParams as FolderCreateParams, + type FolderDeleteParams as FolderDeleteParams, + type FolderCopyParams as FolderCopyParams, + type FolderMoveParams as FolderMoveParams, + type FolderRenameParams as FolderRenameParams, + }; + + export { Accounts as Accounts }; + + export { Beta as Beta }; + + export { + Webhooks as Webhooks, + type BaseWebhookEvent as BaseWebhookEvent, + type FileCreateEvent as FileCreateEvent, + type FileDeleteEvent as FileDeleteEvent, + type FileUpdateEvent as FileUpdateEvent, + type FileVersionCreateEvent as FileVersionCreateEvent, + type FileVersionDeleteEvent as FileVersionDeleteEvent, + type UploadPostTransformErrorEvent as UploadPostTransformErrorEvent, + type UploadPostTransformSuccessEvent as UploadPostTransformSuccessEvent, + type UploadPreTransformErrorEvent as UploadPreTransformErrorEvent, + type UploadPreTransformSuccessEvent as UploadPreTransformSuccessEvent, + type VideoTransformationAcceptedEvent as VideoTransformationAcceptedEvent, + type VideoTransformationErrorEvent as VideoTransformationErrorEvent, + type VideoTransformationReadyEvent as VideoTransformationReadyEvent, + type UnsafeUnwrapWebhookEvent as UnsafeUnwrapWebhookEvent, + type UnwrapWebhookEvent as UnwrapWebhookEvent, + }; + + export type BaseOverlay = API.BaseOverlay; + export type ExtensionConfig = API.ExtensionConfig; + export type Extensions = API.Extensions; + export type GetImageAttributesOptions = API.GetImageAttributesOptions; + export type ImageOverlay = API.ImageOverlay; + export type Overlay = API.Overlay; + export type OverlayPosition = API.OverlayPosition; + export type OverlayTiming = API.OverlayTiming; + export type ResponsiveImageAttributes = API.ResponsiveImageAttributes; + export type SavedExtension = API.SavedExtension; + export type SolidColorOverlay = API.SolidColorOverlay; + export type SolidColorOverlayTransformation = API.SolidColorOverlayTransformation; + export type SrcOptions = API.SrcOptions; + export type StreamingResolution = API.StreamingResolution; + export type SubtitleOverlay = API.SubtitleOverlay; + export type SubtitleOverlayTransformation = API.SubtitleOverlayTransformation; + export type TextOverlay = API.TextOverlay; + export type TextOverlayTransformation = API.TextOverlayTransformation; + export type Transformation = API.Transformation; + export type TransformationPosition = API.TransformationPosition; + export type VideoOverlay = API.VideoOverlay; +} diff --git a/src/core/api-promise.ts b/src/core/api-promise.ts index 4ff22d1a..53821f14 100644 --- a/src/core/api-promise.ts +++ b/src/core/api-promise.ts @@ -16,7 +16,10 @@ export class APIPromise extends Promise { constructor( client: ImageKit, private responsePromise: Promise, - private parseResponse: (client: ImageKit, props: APIResponseProps) => PromiseOrValue = defaultParseResponse, + private parseResponse: ( + client: ImageKit, + props: APIResponseProps, + ) => PromiseOrValue = defaultParseResponse, ) { super((resolve) => { // this is maybe a bit weird but this has to be a no-op to not implicitly @@ -28,7 +31,9 @@ export class APIPromise extends Promise { } _thenUnwrap(transform: (data: T, props: APIResponseProps) => U): APIPromise { - return new APIPromise(this.#client, this.responsePromise, async (client, props) => transform(await this.parseResponse(client, props), props)); + return new APIPromise(this.#client, this.responsePromise, async (client, props) => + transform(await this.parseResponse(client, props), props), + ); } /** diff --git a/src/core/error.ts b/src/core/error.ts index 47b07699..47d1cc24 100644 --- a/src/core/error.ts +++ b/src/core/error.ts @@ -2,10 +2,13 @@ import { castToError } from '../internal/errors'; -export class ImageKitError extends Error { -} +export class ImageKitError extends Error {} -export class APIError extends ImageKitError { +export class APIError< + TStatus extends number | undefined = number | undefined, + THeaders extends Headers | undefined = Headers | undefined, + TError extends Object | undefined = Object | undefined, +> extends ImageKitError { /** HTTP status for the response that caused the error */ readonly status: TStatus; /** HTTP headers for the response that caused the error */ @@ -13,9 +16,6 @@ export class APIError { -} +export class BadRequestError extends APIError<400, Headers> {} -export class AuthenticationError extends APIError<401, Headers> { -} +export class AuthenticationError extends APIError<401, Headers> {} -export class PermissionDeniedError extends APIError<403, Headers> { -} +export class PermissionDeniedError extends APIError<403, Headers> {} -export class NotFoundError extends APIError<404, Headers> { -} +export class NotFoundError extends APIError<404, Headers> {} -export class ConflictError extends APIError<409, Headers> { -} +export class ConflictError extends APIError<409, Headers> {} -export class UnprocessableEntityError extends APIError<422, Headers> { -} +export class UnprocessableEntityError extends APIError<422, Headers> {} -export class RateLimitError extends APIError<429, Headers> { -} +export class RateLimitError extends APIError<429, Headers> {} -export class InternalServerError extends APIError { -} +export class InternalServerError extends APIError {} diff --git a/src/error.ts b/src/error.ts index d0832d34..fc55f46c 100644 --- a/src/error.ts +++ b/src/error.ts @@ -1,2 +1,2 @@ /** @deprecated Import from ./core/error instead */ -export * from "./core/error" \ No newline at end of file +export * from './core/error'; diff --git a/src/index.ts b/src/index.ts index 5f81d419..71734d88 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,4 +5,18 @@ export { ImageKit as default } from './client'; export { type Uploadable, toFile } from './core/uploads'; export { APIPromise } from './core/api-promise'; export { ImageKit, type ClientOptions } from './client'; -export { ImageKitError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError } from './core/error'; +export { + ImageKitError, + APIError, + APIConnectionError, + APIConnectionTimeoutError, + APIUserAbortError, + NotFoundError, + ConflictError, + RateLimitError, + BadRequestError, + AuthenticationError, + InternalServerError, + PermissionDeniedError, + UnprocessableEntityError, +} from './core/error'; diff --git a/src/internal/builtin-types.ts b/src/internal/builtin-types.ts index 6059d5db..c23d3bde 100644 --- a/src/internal/builtin-types.ts +++ b/src/internal/builtin-types.ts @@ -1,23 +1,20 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export type Fetch = ( - input: string | URL | Request, - init?: RequestInit, -) => Promise +export type Fetch = (input: string | URL | Request, init?: RequestInit) => Promise; /** * An alias to the builtin `RequestInit` type so we can * easily alias it in import statements if there are name clashes. - * - * https://developer.mozilla.org/docs/Web/API/RequestInit + * + * https://developer.mozilla.org/docs/Web/API/RequestInit */ type _RequestInit = RequestInit; /** * An alias to the builtin `Response` type so we can * easily alias it in import statements if there are name clashes. - * - * https://developer.mozilla.org/docs/Web/API/Response + * + * https://developer.mozilla.org/docs/Web/API/Response */ type _Response = Response; @@ -54,7 +51,15 @@ type _Array = Array; */ type _Record = Record; -export type { _Array as Array, _BodyInit as BodyInit, _HeadersInit as HeadersInit, _Record as Record, _RequestInfo as RequestInfo, _RequestInit as RequestInit, _Response as Response }; +export type { + _Array as Array, + _BodyInit as BodyInit, + _HeadersInit as HeadersInit, + _Record as Record, + _RequestInfo as RequestInfo, + _RequestInit as RequestInit, + _Response as Response, +}; /** * A copy of the builtin `EndingType` type as it isn't fully supported in certain diff --git a/src/internal/detect-platform.ts b/src/internal/detect-platform.ts index 394ede88..e82d95c9 100644 --- a/src/internal/detect-platform.ts +++ b/src/internal/detect-platform.ts @@ -25,7 +25,11 @@ function getDetectedPlatform(): DetectedPlatform { if (typeof EdgeRuntime !== 'undefined') { return 'edge'; } - if (Object.prototype.toString.call(typeof (globalThis as any).process !== 'undefined' ? (globalThis as any).process : 0) === '[object process]') { + if ( + Object.prototype.toString.call( + typeof (globalThis as any).process !== 'undefined' ? (globalThis as any).process : 0, + ) === '[object process]' + ) { return 'node'; } return 'unknown'; diff --git a/src/internal/errors.ts b/src/internal/errors.ts index c14a742b..82c7b14d 100644 --- a/src/internal/errors.ts +++ b/src/internal/errors.ts @@ -2,12 +2,12 @@ export function isAbortError(err: unknown) { return ( - typeof err === 'object' && err !== null && ( - // Spec-compliant fetch implementations - ('name' in err && (err as any).name === 'AbortError') || + typeof err === 'object' && + err !== null && + // Spec-compliant fetch implementations + (('name' in err && (err as any).name === 'AbortError') || // Expo fetch - ('message' in err && String((err as any).message).includes('FetchRequestCanceledException')) - ) + ('message' in err && String((err as any).message).includes('FetchRequestCanceledException'))) ); } @@ -24,10 +24,10 @@ export const castToError = (err: any): Error => { if (err.name) error.name = err.name; return error; } - } catch { } + } catch {} try { return new Error(JSON.stringify(err)); - } catch { } + } catch {} } return new Error(err); }; diff --git a/src/internal/headers.ts b/src/internal/headers.ts index fa2ea2b9..c724a9d2 100644 --- a/src/internal/headers.ts +++ b/src/internal/headers.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { isReadonlyArray } from "./utils/values"; +import { isReadonlyArray } from './utils/values'; type HeaderValue = string | undefined | null; export type HeadersLike = @@ -51,7 +51,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator(client: ImageKit, props: APIResponseProps): Promise { const { response, requestLogID, retryOfRequestLogID, startTime } = props; const body = await (async () => { - // fetch refuses to read the body when the status code is 204. if (response.status === 204) { return null as T; @@ -43,6 +42,15 @@ export async function defaultParseResponse(client: ImageKit, props: APIRespon const text = await response.text(); return text as unknown as T; })(); - loggerFor(client).debug(`[${requestLogID}] response parsed`, formatRequestDetails({ retryOfRequestLogID, url: response.url, status: response.status, body, durationMs: Date.now() - startTime })); + loggerFor(client).debug( + `[${requestLogID}] response parsed`, + formatRequestDetails({ + retryOfRequestLogID, + url: response.url, + status: response.status, + body, + durationMs: Date.now() - startTime, + }), + ); return body; } diff --git a/src/internal/request-options.ts b/src/internal/request-options.ts index a8558b20..2aabf9aa 100644 --- a/src/internal/request-options.ts +++ b/src/internal/request-options.ts @@ -76,14 +76,10 @@ export type RequestOptions = { defaultBaseURL?: string | undefined; __binaryResponse?: boolean | undefined; - }; export type EncodedContent = { bodyHeaders: HeadersLike; body: BodyInit }; -export type RequestEncoder = (request: { - headers: NullableHeaders; - body: unknown; -}) => EncodedContent; +export type RequestEncoder = (request: { headers: NullableHeaders; body: unknown }) => EncodedContent; export const FallbackEncoder: RequestEncoder = ({ headers, body }) => { return { diff --git a/src/internal/shim-types.ts b/src/internal/shim-types.ts index accbf576..8ddf7b0a 100644 --- a/src/internal/shim-types.ts +++ b/src/internal/shim-types.ts @@ -19,8 +19,8 @@ type _ConditionalNodeReadableStream = typeof globalThis extends { ReadableStream: any } ? never : _NodeReadableStream; type _ReadableStream = NeverToAny< - ([0] extends [1 & _DOMReadableStream] ? never : _DOMReadableStream) | - ([0] extends [1 & _ConditionalNodeReadableStream] ? never : _ConditionalNodeReadableStream) + | ([0] extends [1 & _DOMReadableStream] ? never : _DOMReadableStream) + | ([0] extends [1 & _ConditionalNodeReadableStream] ? never : _ConditionalNodeReadableStream) >; export type { _ReadableStream as ReadableStream }; diff --git a/src/internal/shims.ts b/src/internal/shims.ts index 1d378b65..e4dc7102 100644 --- a/src/internal/shims.ts +++ b/src/internal/shims.ts @@ -27,7 +27,9 @@ export function makeReadableStream(...args: ReadableStreamArgs): ReadableStream if (typeof ReadableStream === 'undefined') { // Note: All of the platforms / runtimes we officially support already define // `ReadableStream` as a global, so this should only ever be hit on unsupported runtimes. - throw new Error('`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`'); + throw new Error( + '`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`', + ); } return new ReadableStream(...args); diff --git a/src/internal/to-file.ts b/src/internal/to-file.ts index c72a2b41..30eada32 100644 --- a/src/internal/to-file.ts +++ b/src/internal/to-file.ts @@ -1,4 +1,4 @@ -import { BlobPart, getName, makeFile, isAsyncIterable } from "./uploads"; +import { BlobPart, getName, makeFile, isAsyncIterable } from './uploads'; import type { FilePropertyBag } from './builtin-types'; import { checkFileSupport } from './uploads'; @@ -65,8 +65,11 @@ const isResponseLike = (value: any): value is ResponseLike => typeof value.url === 'string' && typeof value.blob === 'function'; -export type ToFileInput = FileLike | ResponseLike | Exclude | AsyncIterable; - +export type ToFileInput = + | FileLike + | ResponseLike + | Exclude + | AsyncIterable; /** * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats @@ -116,9 +119,7 @@ export async function toFile( return makeFile(parts, name, options); } -async function getBytes( - value: BlobLikePart | AsyncIterable, -): Promise> { +async function getBytes(value: BlobLikePart | AsyncIterable): Promise> { let parts: Array = []; if ( typeof value === 'string' || @@ -151,4 +152,3 @@ function propsForError(value: unknown): string { const props = Object.getOwnPropertyNames(value); return `; props: [${props.map((p) => `"${p}"`).join(', ')}]`; } - diff --git a/src/internal/types.ts b/src/internal/types.ts index c45fee32..b668dfc0 100644 --- a/src/internal/types.ts +++ b/src/internal/types.ts @@ -7,34 +7,40 @@ export type KeysEnum = { [P in keyof Required]: true }; export type FinalizedRequestInit = RequestInit & { headers: Headers }; -type NotAny = [0] extends [(1 & T)] ? never : T; +type NotAny = [0] extends [1 & T] ? never : T; /** * Some environments overload the global fetch function, and Parameters only gets the last signature. */ -type OverloadedParameters = T extends { - (...args: infer A): unknown; - (...args: infer B): unknown; - (...args: infer C): unknown; - (...args: infer D): unknown; -} - ? A | B | C | D - : T extends { +type OverloadedParameters = + T extends ( + { (...args: infer A): unknown; (...args: infer B): unknown; (...args: infer C): unknown; + (...args: infer D): unknown; } - ? A | B | C - : T extends { + ) ? + A | B | C | D + : T extends ( + { + (...args: infer A): unknown; + (...args: infer B): unknown; + (...args: infer C): unknown; + } + ) ? + A | B | C + : T extends ( + { (...args: infer A): unknown; (...args: infer B): unknown; } - ? A | B - : T extends (...args: infer A) => unknown - ? A + ) ? + A | B + : T extends (...args: infer A) => unknown ? A : never; - +/* eslint-disable */ /** * These imports attempt to get types from a parent package's dependencies. * Unresolved bare specifiers can trigger [automatic type acquisition][1] in some projects, which @@ -57,19 +63,19 @@ type OverloadedParameters = T extends { * * [1]: https://www.typescriptlang.org/tsconfig/#typeAcquisition */ -/** @ts-ignore For users with \@types/node */ /* prettier-ignore */ +/** @ts-ignore For users with \@types/node */ type UndiciTypesRequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users with undici */ /* prettier-ignore */ +/** @ts-ignore For users with undici */ type UndiciRequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users with \@types/bun */ /* prettier-ignore */ +/** @ts-ignore For users with \@types/bun */ type BunRequestInit = globalThis.FetchRequestInit; -/** @ts-ignore For users with node-fetch@2 */ /* prettier-ignore */ +/** @ts-ignore For users with node-fetch@2 */ type NodeFetch2RequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */ /* prettier-ignore */ +/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */ type NodeFetch3RequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users who use Deno */ /* prettier-ignore */ +/** @ts-ignore For users who use Deno */ type FetchRequestInit = NonNullable[1]>; - +/* eslint-enable */ type RequestInits = | NotAny diff --git a/src/internal/utils/log.ts b/src/internal/utils/log.ts index 697d265a..7da41295 100644 --- a/src/internal/utils/log.ts +++ b/src/internal/utils/log.ts @@ -4,7 +4,7 @@ import { hasOwn } from './values'; import { type ImageKit } from '../../client'; import { RequestOptions } from '../request-options'; -type LogFn = (message: string, ...rest: unknown[]) => void +type LogFn = (message: string, ...rest: unknown[]) => void; export type Logger = { error: LogFn; warn: LogFn; @@ -21,14 +21,22 @@ const levelNumbers = { debug: 500, }; -export const parseLogLevel = (maybeLevel: string | undefined, sourceName: string, client: ImageKit): LogLevel | undefined => { +export const parseLogLevel = ( + maybeLevel: string | undefined, + sourceName: string, + client: ImageKit, +): LogLevel | undefined => { if (!maybeLevel) { return undefined; } if (hasOwn(levelNumbers, maybeLevel)) { return maybeLevel; - }; - loggerFor(client).warn(`${sourceName} was set to ${JSON.stringify(maybeLevel)}, expected one of ${JSON.stringify(Object.keys(levelNumbers))}`); + } + loggerFor(client).warn( + `${sourceName} was set to ${JSON.stringify(maybeLevel)}, expected one of ${JSON.stringify( + Object.keys(levelNumbers), + )}`, + ); return undefined; }; @@ -89,11 +97,24 @@ export const formatRequestDetails = (details: { body?: unknown; }) => { if (details.options) { - details.options = {...details.options}; + details.options = { ...details.options }; delete details.options['headers']; // redundant + leaks internals } if (details.headers) { - details.headers = Object.fromEntries((details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map(([name, value]) => [name, name.toLowerCase() === 'authorization' || name.toLowerCase() === 'cookie' || name.toLowerCase() === 'set-cookie' ? '***' : value])) + details.headers = Object.fromEntries( + (details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map( + ([name, value]) => [ + name, + ( + name.toLowerCase() === 'authorization' || + name.toLowerCase() === 'cookie' || + name.toLowerCase() === 'set-cookie' + ) ? + '***' + : value, + ], + ), + ); } if ('retryOfRequestLogID' in details) { if (details.retryOfRequestLogID) { @@ -101,5 +122,5 @@ export const formatRequestDetails = (details: { } delete details.retryOfRequestLogID; } - return details -} + return details; +}; diff --git a/src/internal/utils/uuid.ts b/src/internal/utils/uuid.ts index 53708ba6..b0e53aaf 100644 --- a/src/internal/utils/uuid.ts +++ b/src/internal/utils/uuid.ts @@ -10,10 +10,8 @@ export let uuid4 = function () { return crypto.randomUUID(); } const u8 = new Uint8Array(1); - const randomByte = crypto - ? () => crypto.getRandomValues(u8)[0]! - : () => (Math.random() * 0xff) & 0xff; - return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) => + const randomByte = crypto ? () => crypto.getRandomValues(u8)[0]! : () => (Math.random() * 0xff) & 0xff; + return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => (+c ^ (randomByte() & (15 >> (+c / 4)))).toString(16), ); -} +}; diff --git a/src/resource.ts b/src/resource.ts index 57a27a94..363e3516 100644 --- a/src/resource.ts +++ b/src/resource.ts @@ -1,2 +1,2 @@ /** @deprecated Import from ./core/resource instead */ -export * from "./core/resource" \ No newline at end of file +export * from './core/resource'; diff --git a/src/resources/accounts/accounts.ts b/src/resources/accounts/accounts.ts index 5f561627..82d1b238 100644 --- a/src/resources/accounts/accounts.ts +++ b/src/resources/accounts/accounts.ts @@ -2,9 +2,23 @@ import { APIResource } from '../../core/resource'; import * as OriginsAPI from './origins'; -import { OriginCreateParams, OriginListResponse, OriginRequest, OriginResponse, OriginUpdateParams, Origins } from './origins'; +import { + OriginCreateParams, + OriginListResponse, + OriginRequest, + OriginResponse, + OriginUpdateParams, + Origins, +} from './origins'; import * as URLEndpointsAPI from './url-endpoints'; -import { URLEndpointCreateParams, URLEndpointListResponse, URLEndpointRequest, URLEndpointResponse, URLEndpointUpdateParams, URLEndpoints } from './url-endpoints'; +import { + URLEndpointCreateParams, + URLEndpointListResponse, + URLEndpointRequest, + URLEndpointResponse, + URLEndpointUpdateParams, + URLEndpoints, +} from './url-endpoints'; import * as UsageAPI from './usage'; import { Usage, UsageGetParams, UsageGetResponse } from './usage'; @@ -19,11 +33,7 @@ Accounts.Origins = Origins; Accounts.URLEndpoints = URLEndpoints; export declare namespace Accounts { - export { - Usage as Usage, - type UsageGetResponse as UsageGetResponse, - type UsageGetParams as UsageGetParams - }; + export { Usage as Usage, type UsageGetResponse as UsageGetResponse, type UsageGetParams as UsageGetParams }; export { Origins as Origins, @@ -31,7 +41,7 @@ export declare namespace Accounts { type OriginResponse as OriginResponse, type OriginListResponse as OriginListResponse, type OriginCreateParams as OriginCreateParams, - type OriginUpdateParams as OriginUpdateParams + type OriginUpdateParams as OriginUpdateParams, }; export { @@ -40,6 +50,6 @@ export declare namespace Accounts { type URLEndpointResponse as URLEndpointResponse, type URLEndpointListResponse as URLEndpointListResponse, type URLEndpointCreateParams as URLEndpointCreateParams, - type URLEndpointUpdateParams as URLEndpointUpdateParams + type URLEndpointUpdateParams as URLEndpointUpdateParams, }; } diff --git a/src/resources/accounts/index.ts b/src/resources/accounts/index.ts index fee9bfbf..34a0246d 100644 --- a/src/resources/accounts/index.ts +++ b/src/resources/accounts/index.ts @@ -1,6 +1,20 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Accounts } from './accounts';; -export { Origins, type OriginRequest, type OriginResponse, type OriginListResponse, type OriginCreateParams, type OriginUpdateParams } from './origins';; -export { URLEndpoints, type URLEndpointRequest, type URLEndpointResponse, type URLEndpointListResponse, type URLEndpointCreateParams, type URLEndpointUpdateParams } from './url-endpoints';; -export { Usage, type UsageGetResponse, type UsageGetParams } from './usage';; +export { Accounts } from './accounts'; +export { + Origins, + type OriginRequest, + type OriginResponse, + type OriginListResponse, + type OriginCreateParams, + type OriginUpdateParams, +} from './origins'; +export { + URLEndpoints, + type URLEndpointRequest, + type URLEndpointResponse, + type URLEndpointListResponse, + type URLEndpointCreateParams, + type URLEndpointUpdateParams, +} from './url-endpoints'; +export { Usage, type UsageGetResponse, type UsageGetParams } from './usage'; diff --git a/src/resources/accounts/origins.ts b/src/resources/accounts/origins.ts index 41b9fdbb..f59a468e 100644 --- a/src/resources/accounts/origins.ts +++ b/src/resources/accounts/origins.ts @@ -8,7 +8,7 @@ import { path } from '../../internal/utils/path'; export class Origins extends APIResource { /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Creates a new origin and returns the origin object. * * @example @@ -29,7 +29,7 @@ export class Origins extends APIResource { } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Updates the origin identified by `id` and returns the updated origin object. * * @example @@ -51,7 +51,7 @@ export class Origins extends APIResource { } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Returns an array of all configured origins for the current account. * * @example @@ -65,7 +65,7 @@ export class Origins extends APIResource { } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Permanently removes the origin identified by `id`. If the origin is in use by * any URL‑endpoints, the API will return an error. * @@ -75,11 +75,14 @@ export class Origins extends APIResource { * ``` */ delete(id: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/accounts/origins/${id}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); + return this._client.delete(path`/v1/accounts/origins/${id}`, { + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Retrieves the origin identified by `id`. * * @example @@ -97,7 +100,15 @@ export class Origins extends APIResource { /** * Schema for origin request resources. */ -export type OriginRequest = OriginRequest.S3 | OriginRequest.S3Compatible | OriginRequest.CloudinaryBackup | OriginRequest.WebFolder | OriginRequest.WebProxy | OriginRequest.Gcs | OriginRequest.AzureBlob | OriginRequest.AkeneoPim +export type OriginRequest = + | OriginRequest.S3 + | OriginRequest.S3Compatible + | OriginRequest.CloudinaryBackup + | OriginRequest.WebFolder + | OriginRequest.WebProxy + | OriginRequest.Gcs + | OriginRequest.AzureBlob + | OriginRequest.AkeneoPim; export namespace OriginRequest { export interface S3 { @@ -377,7 +388,15 @@ export namespace OriginRequest { /** * Origin object as returned by the API (sensitive fields removed). */ -export type OriginResponse = OriginResponse.S3 | OriginResponse.S3Compatible | OriginResponse.CloudinaryBackup | OriginResponse.WebFolder | OriginResponse.WebProxy | OriginResponse.Gcs | OriginResponse.AzureBlob | OriginResponse.AkeneoPim +export type OriginResponse = + | OriginResponse.S3 + | OriginResponse.S3Compatible + | OriginResponse.CloudinaryBackup + | OriginResponse.WebFolder + | OriginResponse.WebProxy + | OriginResponse.Gcs + | OriginResponse.AzureBlob + | OriginResponse.AkeneoPim; export namespace OriginResponse { export interface S3 { @@ -648,9 +667,17 @@ export namespace OriginResponse { } } -export type OriginListResponse = Array +export type OriginListResponse = Array; -export type OriginCreateParams = OriginCreateParams.S3 | OriginCreateParams.S3Compatible | OriginCreateParams.CloudinaryBackup | OriginCreateParams.WebFolder | OriginCreateParams.WebProxy | OriginCreateParams.GoogleCloudStorageGcs | OriginCreateParams.AzureBlobStorage | OriginCreateParams.AkeneoPim +export type OriginCreateParams = + | OriginCreateParams.S3 + | OriginCreateParams.S3Compatible + | OriginCreateParams.CloudinaryBackup + | OriginCreateParams.WebFolder + | OriginCreateParams.WebProxy + | OriginCreateParams.GoogleCloudStorageGcs + | OriginCreateParams.AzureBlobStorage + | OriginCreateParams.AkeneoPim; export declare namespace OriginCreateParams { export interface S3 { @@ -927,7 +954,15 @@ export declare namespace OriginCreateParams { } } -export type OriginUpdateParams = OriginUpdateParams.S3 | OriginUpdateParams.S3Compatible | OriginUpdateParams.CloudinaryBackup | OriginUpdateParams.WebFolder | OriginUpdateParams.WebProxy | OriginUpdateParams.GoogleCloudStorageGcs | OriginUpdateParams.AzureBlobStorage | OriginUpdateParams.AkeneoPim +export type OriginUpdateParams = + | OriginUpdateParams.S3 + | OriginUpdateParams.S3Compatible + | OriginUpdateParams.CloudinaryBackup + | OriginUpdateParams.WebFolder + | OriginUpdateParams.WebProxy + | OriginUpdateParams.GoogleCloudStorageGcs + | OriginUpdateParams.AzureBlobStorage + | OriginUpdateParams.AkeneoPim; export declare namespace OriginUpdateParams { export interface S3 { @@ -1210,6 +1245,6 @@ export declare namespace Origins { type OriginResponse as OriginResponse, type OriginListResponse as OriginListResponse, type OriginCreateParams as OriginCreateParams, - type OriginUpdateParams as OriginUpdateParams + type OriginUpdateParams as OriginUpdateParams, }; } diff --git a/src/resources/accounts/url-endpoints.ts b/src/resources/accounts/url-endpoints.ts index 9afa7e0a..7bd424c4 100644 --- a/src/resources/accounts/url-endpoints.ts +++ b/src/resources/accounts/url-endpoints.ts @@ -8,7 +8,7 @@ import { path } from '../../internal/utils/path'; export class URLEndpoints extends APIResource { /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Creates a new URL‑endpoint and returns the resulting object. * * @example @@ -24,7 +24,7 @@ export class URLEndpoints extends APIResource { } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Updates the URL‑endpoint identified by `id` and returns the updated object. * * @example @@ -35,12 +35,16 @@ export class URLEndpoints extends APIResource { * }); * ``` */ - update(id: string, body: URLEndpointUpdateParams, options?: RequestOptions): APIPromise { + update( + id: string, + body: URLEndpointUpdateParams, + options?: RequestOptions, + ): APIPromise { return this._client.put(path`/v1/accounts/url-endpoints/${id}`, { body, ...options }); } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Returns an array of all URL‑endpoints configured including the default * URL-endpoint generated by ImageKit during account creation. * @@ -55,7 +59,7 @@ export class URLEndpoints extends APIResource { } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Deletes the URL‑endpoint identified by `id`. You cannot delete the default * URL‑endpoint created by ImageKit during account creation. * @@ -65,11 +69,14 @@ export class URLEndpoints extends APIResource { * ``` */ delete(id: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/accounts/url-endpoints/${id}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); + return this._client.delete(path`/v1/accounts/url-endpoints/${id}`, { + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); } /** - * **Note:** This API is currently in beta. + * **Note:** This API is currently in beta. * Retrieves the URL‑endpoint identified by `id`. * * @example @@ -184,7 +191,7 @@ export namespace URLEndpointResponse { } } -export type URLEndpointListResponse = Array +export type URLEndpointListResponse = Array; export interface URLEndpointCreateParams { /** @@ -208,7 +215,10 @@ export interface URLEndpointCreateParams { /** * Configuration for third-party URL rewriting. */ - urlRewriter?: URLEndpointCreateParams.Cloudinary | URLEndpointCreateParams.Imgix | URLEndpointCreateParams.Akamai; + urlRewriter?: + | URLEndpointCreateParams.Cloudinary + | URLEndpointCreateParams.Imgix + | URLEndpointCreateParams.Akamai; } export namespace URLEndpointCreateParams { @@ -252,7 +262,10 @@ export interface URLEndpointUpdateParams { /** * Configuration for third-party URL rewriting. */ - urlRewriter?: URLEndpointUpdateParams.Cloudinary | URLEndpointUpdateParams.Imgix | URLEndpointUpdateParams.Akamai; + urlRewriter?: + | URLEndpointUpdateParams.Cloudinary + | URLEndpointUpdateParams.Imgix + | URLEndpointUpdateParams.Akamai; } export namespace URLEndpointUpdateParams { @@ -280,6 +293,6 @@ export declare namespace URLEndpoints { type URLEndpointResponse as URLEndpointResponse, type URLEndpointListResponse as URLEndpointListResponse, type URLEndpointCreateParams as URLEndpointCreateParams, - type URLEndpointUpdateParams as URLEndpointUpdateParams + type URLEndpointUpdateParams as URLEndpointUpdateParams, }; } diff --git a/src/resources/accounts/usage.ts b/src/resources/accounts/usage.ts index 7c2f7f1d..87e703a4 100644 --- a/src/resources/accounts/usage.ts +++ b/src/resources/accounts/usage.ts @@ -66,8 +66,5 @@ export interface UsageGetParams { } export declare namespace Usage { - export { - type UsageGetResponse as UsageGetResponse, - type UsageGetParams as UsageGetParams - }; + export { type UsageGetResponse as UsageGetResponse, type UsageGetParams as UsageGetParams }; } diff --git a/src/resources/assets.ts b/src/resources/assets.ts index 79b2ca27..19a35adb 100644 --- a/src/resources/assets.ts +++ b/src/resources/assets.ts @@ -12,12 +12,15 @@ export class Assets extends APIResource { * by generating a query string in a Lucene-like syntax and provide this generated * string as the value of the `searchQuery`. */ - list(query: AssetListParams | null | undefined = {}, options?: RequestOptions): APIPromise { + list( + query: AssetListParams | null | undefined = {}, + options?: RequestOptions, + ): APIPromise { return this._client.get('/v1/files', { query, ...options }); } } -export type AssetListResponse = Array +export type AssetListResponse = Array; export interface AssetListParams { /** @@ -70,7 +73,21 @@ export interface AssetListParams { * Sort the results by one of the supported fields in ascending or descending * order. */ - sort?: 'ASC_NAME' | 'DESC_NAME' | 'ASC_CREATED' | 'DESC_CREATED' | 'ASC_UPDATED' | 'DESC_UPDATED' | 'ASC_HEIGHT' | 'DESC_HEIGHT' | 'ASC_WIDTH' | 'DESC_WIDTH' | 'ASC_SIZE' | 'DESC_SIZE' | 'ASC_RELEVANCE' | 'DESC_RELEVANCE'; + sort?: + | 'ASC_NAME' + | 'DESC_NAME' + | 'ASC_CREATED' + | 'DESC_CREATED' + | 'ASC_UPDATED' + | 'DESC_UPDATED' + | 'ASC_HEIGHT' + | 'DESC_HEIGHT' + | 'ASC_WIDTH' + | 'DESC_WIDTH' + | 'ASC_SIZE' + | 'DESC_SIZE' + | 'ASC_RELEVANCE' + | 'DESC_RELEVANCE'; /** * Filter results by asset type. @@ -84,8 +101,5 @@ export interface AssetListParams { } export declare namespace Assets { - export { - type AssetListResponse as AssetListResponse, - type AssetListParams as AssetListParams - }; + export { type AssetListResponse as AssetListResponse, type AssetListParams as AssetListParams }; } diff --git a/src/resources/beta/beta.ts b/src/resources/beta/beta.ts index a0bc3ef3..f8fa04c2 100644 --- a/src/resources/beta/beta.ts +++ b/src/resources/beta/beta.ts @@ -11,7 +11,5 @@ export class Beta extends APIResource { Beta.V2 = V2; export declare namespace Beta { - export { - V2 as V2 - }; + export { V2 as V2 }; } diff --git a/src/resources/beta/index.ts b/src/resources/beta/index.ts index 46a22248..2b3a43ce 100644 --- a/src/resources/beta/index.ts +++ b/src/resources/beta/index.ts @@ -1,4 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Beta } from './beta';; -export { V2 } from './v2/index';; +export { Beta } from './beta'; +export { V2 } from './v2/index'; diff --git a/src/resources/beta/v2/files.ts b/src/resources/beta/v2/files.ts index 43538fa7..a3daea86 100644 --- a/src/resources/beta/v2/files.ts +++ b/src/resources/beta/v2/files.ts @@ -51,7 +51,13 @@ export class Files extends APIResource { upload(body: FileUploadParams, options?: RequestOptions): APIPromise { const serializedBody = serializeUploadOptions(body); - return this._client.post('/api/v2/files/upload', multipartFormRequestOptions({ body: serializedBody, defaultBaseURL: 'https://upload.imagekit.io', ...options }, this._client)); + return this._client.post( + '/api/v2/files/upload', + multipartFormRequestOptions( + { body: serializedBody, defaultBaseURL: 'https://upload.imagekit.io', ...options }, + this._client, + ), + ); } } @@ -466,7 +472,16 @@ export interface FileUploadParams { /** * Array of response field keys to include in the API response body. */ - responseFields?: Array<'tags' | 'customCoordinates' | 'isPrivateFile' | 'embeddedMetadata' | 'isPublished' | 'customMetadata' | 'metadata' | 'selectedFieldsSchema'>; + responseFields?: Array< + | 'tags' + | 'customCoordinates' + | 'isPrivateFile' + | 'embeddedMetadata' + | 'isPublished' + | 'customMetadata' + | 'metadata' + | 'selectedFieldsSchema' + >; /** * Set the tags while uploading the file. Provide an array of tag strings (e.g. @@ -479,11 +494,11 @@ export interface FileUploadParams { /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. * - * - `pre` — applied before the file is uploaded to the Media Library. + * - `pre` — applied before the file is uploaded to the Media Library. * Useful for reducing file size or applying basic optimizations upfront (e.g., * resize, compress). * - * - `post` — applied immediately after upload. + * - `post` — applied immediately after upload. * Ideal for generating transformed versions (like video encodes or thumbnails) * in advance, so they're ready for delivery without delay. * @@ -515,11 +530,11 @@ export namespace FileUploadParams { /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. * - * - `pre` — applied before the file is uploaded to the Media Library. + * - `pre` — applied before the file is uploaded to the Media Library. * Useful for reducing file size or applying basic optimizations upfront (e.g., * resize, compress). * - * - `post` — applied immediately after upload. + * - `post` — applied immediately after upload. * Ideal for generating transformed versions (like video encodes or thumbnails) * in advance, so they're ready for delivery without delay. * @@ -527,11 +542,16 @@ export namespace FileUploadParams { */ export interface Transformation { /** - * List of transformations to apply _after_ the file is uploaded. + * List of transformations to apply _after_ the file is uploaded. * Each item must match one of the following types: `transformation`, * `gif-to-video`, `thumbnail`, `abs`. */ - post?: Array; + post?: Array< + | Transformation.Transformation + | Transformation.GifToVideo + | Transformation.Thumbnail + | Transformation.Abs + >; /** * Transformation string to apply before uploading the file to the Media Library. @@ -548,7 +568,7 @@ export namespace FileUploadParams { type: 'transformation'; /** - * Transformation string (e.g. `w-200,h-200`). + * Transformation string (e.g. `w-200,h-200`). * Same syntax as ImageKit URL-based transformations. */ value: string; @@ -561,7 +581,7 @@ export namespace FileUploadParams { type: 'gif-to-video'; /** - * Optional transformation string to apply to the output video. + * Optional transformation string to apply to the output video. * **Example**: `q-80` */ value?: string; @@ -574,7 +594,7 @@ export namespace FileUploadParams { type: 'thumbnail'; /** - * Optional transformation string. + * Optional transformation string. * **Example**: `w-150,h-150` */ value?: string; @@ -600,8 +620,5 @@ export namespace FileUploadParams { } export declare namespace Files { - export { - type FileUploadResponse as FileUploadResponse, - type FileUploadParams as FileUploadParams - }; + export { type FileUploadResponse as FileUploadResponse, type FileUploadParams as FileUploadParams }; } diff --git a/src/resources/beta/v2/index.ts b/src/resources/beta/v2/index.ts index e53ebe72..bffa32ec 100644 --- a/src/resources/beta/v2/index.ts +++ b/src/resources/beta/v2/index.ts @@ -1,4 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Files, type FileUploadResponse, type FileUploadParams } from './files';; -export { V2 } from './v2';; +export { Files, type FileUploadResponse, type FileUploadParams } from './files'; +export { V2 } from './v2'; diff --git a/src/resources/beta/v2/v2.ts b/src/resources/beta/v2/v2.ts index 211cace8..3a047920 100644 --- a/src/resources/beta/v2/v2.ts +++ b/src/resources/beta/v2/v2.ts @@ -14,6 +14,6 @@ export declare namespace V2 { export { Files as Files, type FileUploadResponse as FileUploadResponse, - type FileUploadParams as FileUploadParams + type FileUploadParams as FileUploadParams, }; } diff --git a/src/resources/cache/cache.ts b/src/resources/cache/cache.ts index a8a36d84..b959081c 100644 --- a/src/resources/cache/cache.ts +++ b/src/resources/cache/cache.ts @@ -2,7 +2,12 @@ import { APIResource } from '../../core/resource'; import * as InvalidationAPI from './invalidation'; -import { Invalidation, InvalidationCreateParams, InvalidationCreateResponse, InvalidationGetResponse } from './invalidation'; +import { + Invalidation, + InvalidationCreateParams, + InvalidationCreateResponse, + InvalidationGetResponse, +} from './invalidation'; export class Cache extends APIResource { invalidation: InvalidationAPI.Invalidation = new InvalidationAPI.Invalidation(this._client); @@ -15,6 +20,6 @@ export declare namespace Cache { Invalidation as Invalidation, type InvalidationCreateResponse as InvalidationCreateResponse, type InvalidationGetResponse as InvalidationGetResponse, - type InvalidationCreateParams as InvalidationCreateParams + type InvalidationCreateParams as InvalidationCreateParams, }; } diff --git a/src/resources/cache/index.ts b/src/resources/cache/index.ts index 8d9a7c47..3c9f4fc7 100644 --- a/src/resources/cache/index.ts +++ b/src/resources/cache/index.ts @@ -1,4 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Cache } from './cache';; -export { Invalidation, type InvalidationCreateResponse, type InvalidationGetResponse, type InvalidationCreateParams } from './invalidation';; +export { Cache } from './cache'; +export { + Invalidation, + type InvalidationCreateResponse, + type InvalidationGetResponse, + type InvalidationCreateParams, +} from './invalidation'; diff --git a/src/resources/cache/invalidation.ts b/src/resources/cache/invalidation.ts index 6c1b7d4e..d06b2701 100644 --- a/src/resources/cache/invalidation.ts +++ b/src/resources/cache/invalidation.ts @@ -65,6 +65,6 @@ export declare namespace Invalidation { export { type InvalidationCreateResponse as InvalidationCreateResponse, type InvalidationGetResponse as InvalidationGetResponse, - type InvalidationCreateParams as InvalidationCreateParams + type InvalidationCreateParams as InvalidationCreateParams, }; } diff --git a/src/resources/custom-metadata-fields.ts b/src/resources/custom-metadata-fields.ts index 32348358..81081924 100644 --- a/src/resources/custom-metadata-fields.ts +++ b/src/resources/custom-metadata-fields.ts @@ -42,7 +42,11 @@ export class CustomMetadataFields extends APIResource { * }); * ``` */ - update(id: string, body: CustomMetadataFieldUpdateParams | null | undefined = {}, options?: RequestOptions): APIPromise { + update( + id: string, + body: CustomMetadataFieldUpdateParams | null | undefined = {}, + options?: RequestOptions, + ): APIPromise { return this._client.patch(path`/v1/customMetadataFields/${id}`, { body, ...options }); } @@ -62,7 +66,10 @@ export class CustomMetadataFields extends APIResource { * await client.customMetadataFields.list(); * ``` */ - list(query: CustomMetadataFieldListParams | null | undefined = {}, options?: RequestOptions): APIPromise { + list( + query: CustomMetadataFieldListParams | null | undefined = {}, + options?: RequestOptions, + ): APIPromise { return this._client.get('/v1/customMetadataFields', { query, ...options }); } @@ -161,10 +168,9 @@ export namespace CustomMetadataField { } } -export type CustomMetadataFieldListResponse = Array +export type CustomMetadataFieldListResponse = Array; -export interface CustomMetadataFieldDeleteResponse { -} +export interface CustomMetadataFieldDeleteResponse {} export interface CustomMetadataFieldCreateParams { /** @@ -335,6 +341,6 @@ export declare namespace CustomMetadataFields { type CustomMetadataFieldDeleteResponse as CustomMetadataFieldDeleteResponse, type CustomMetadataFieldCreateParams as CustomMetadataFieldCreateParams, type CustomMetadataFieldUpdateParams as CustomMetadataFieldUpdateParams, - type CustomMetadataFieldListParams as CustomMetadataFieldListParams + type CustomMetadataFieldListParams as CustomMetadataFieldListParams, }; } diff --git a/src/resources/files/bulk.ts b/src/resources/files/bulk.ts index e66e9c9e..35dec26f 100644 --- a/src/resources/files/bulk.ts +++ b/src/resources/files/bulk.ts @@ -166,6 +166,6 @@ export declare namespace Bulk { type BulkDeleteParams as BulkDeleteParams, type BulkAddTagsParams as BulkAddTagsParams, type BulkRemoveAITagsParams as BulkRemoveAITagsParams, - type BulkRemoveTagsParams as BulkRemoveTagsParams + type BulkRemoveTagsParams as BulkRemoveTagsParams, }; } diff --git a/src/resources/files/files.ts b/src/resources/files/files.ts index f6a1e93e..ccf97c30 100644 --- a/src/resources/files/files.ts +++ b/src/resources/files/files.ts @@ -3,11 +3,28 @@ import { APIResource } from '../../core/resource'; import * as Shared from '../shared'; import * as BulkAPI from './bulk'; -import { Bulk, BulkAddTagsParams, BulkAddTagsResponse, BulkDeleteParams, BulkDeleteResponse, BulkRemoveAITagsParams, BulkRemoveAITagsResponse, BulkRemoveTagsParams, BulkRemoveTagsResponse } from './bulk'; +import { + Bulk, + BulkAddTagsParams, + BulkAddTagsResponse, + BulkDeleteParams, + BulkDeleteResponse, + BulkRemoveAITagsParams, + BulkRemoveAITagsResponse, + BulkRemoveTagsParams, + BulkRemoveTagsResponse, +} from './bulk'; import * as MetadataAPI from './metadata'; import { MetadataGetFromURLParams } from './metadata'; import * as VersionsAPI from './versions'; -import { VersionDeleteParams, VersionDeleteResponse, VersionGetParams, VersionListResponse, VersionRestoreParams, Versions } from './versions'; +import { + VersionDeleteParams, + VersionDeleteResponse, + VersionGetParams, + VersionListResponse, + VersionRestoreParams, + Versions, +} from './versions'; import { APIPromise } from '../../core/api-promise'; import { type Uploadable } from '../../core/uploads'; import { buildHeaders } from '../../internal/headers'; @@ -48,7 +65,10 @@ export class Files extends APIResource { * ``` */ delete(fileID: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/files/${fileID}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); + return this._client.delete(path`/v1/files/${fileID}`, { + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); } /** @@ -161,7 +181,13 @@ export class Files extends APIResource { upload(body: FileUploadParams, options?: RequestOptions): APIPromise { const serializedBody = serializeUploadOptions(body); - return this._client.post('/api/v1/files/upload', multipartFormRequestOptions({ body: serializedBody, defaultBaseURL: 'https://upload.imagekit.io', ...options }, this._client)); + return this._client.post( + '/api/v1/files/upload', + multipartFormRequestOptions( + { body: serializedBody, defaultBaseURL: 'https://upload.imagekit.io', ...options }, + this._client, + ), + ); } } @@ -693,7 +719,9 @@ export namespace Metadata { /** * Schema for update file update request. */ -export type UpdateFileRequest = UpdateFileRequest.UpdateFileDetails | UpdateFileRequest.ChangePublicationStatus +export type UpdateFileRequest = + | UpdateFileRequest.UpdateFileDetails + | UpdateFileRequest.ChangePublicationStatus; export namespace UpdateFileRequest { export interface UpdateFileDetails { @@ -795,11 +823,9 @@ export namespace FileUpdateResponse { } } -export interface FileCopyResponse { -} +export interface FileCopyResponse {} -export interface FileMoveResponse { -} +export interface FileMoveResponse {} export interface FileRenameResponse { /** @@ -1094,7 +1120,7 @@ export namespace FileUploadResponse { } } -export type FileUpdateParams = FileUpdateParams.UpdateFileDetails | FileUpdateParams.ChangePublicationStatus +export type FileUpdateParams = FileUpdateParams.UpdateFileDetails | FileUpdateParams.ChangePublicationStatus; export declare namespace FileUpdateParams { export interface UpdateFileDetails { @@ -1389,7 +1415,16 @@ export interface FileUploadParams { /** * Array of response field keys to include in the API response body. */ - responseFields?: Array<'tags' | 'customCoordinates' | 'isPrivateFile' | 'embeddedMetadata' | 'isPublished' | 'customMetadata' | 'metadata' | 'selectedFieldsSchema'>; + responseFields?: Array< + | 'tags' + | 'customCoordinates' + | 'isPrivateFile' + | 'embeddedMetadata' + | 'isPublished' + | 'customMetadata' + | 'metadata' + | 'selectedFieldsSchema' + >; /** * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a @@ -1412,11 +1447,11 @@ export interface FileUploadParams { /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. * - * - `pre` — applied before the file is uploaded to the Media Library. + * - `pre` — applied before the file is uploaded to the Media Library. * Useful for reducing file size or applying basic optimizations upfront (e.g., * resize, compress). * - * - `post` — applied immediately after upload. + * - `post` — applied immediately after upload. * Ideal for generating transformed versions (like video encodes or thumbnails) * in advance, so they're ready for delivery without delay. * @@ -1448,11 +1483,11 @@ export namespace FileUploadParams { /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. * - * - `pre` — applied before the file is uploaded to the Media Library. + * - `pre` — applied before the file is uploaded to the Media Library. * Useful for reducing file size or applying basic optimizations upfront (e.g., * resize, compress). * - * - `post` — applied immediately after upload. + * - `post` — applied immediately after upload. * Ideal for generating transformed versions (like video encodes or thumbnails) * in advance, so they're ready for delivery without delay. * @@ -1460,11 +1495,16 @@ export namespace FileUploadParams { */ export interface Transformation { /** - * List of transformations to apply _after_ the file is uploaded. + * List of transformations to apply _after_ the file is uploaded. * Each item must match one of the following types: `transformation`, * `gif-to-video`, `thumbnail`, `abs`. */ - post?: Array; + post?: Array< + | Transformation.Transformation + | Transformation.GifToVideo + | Transformation.Thumbnail + | Transformation.Abs + >; /** * Transformation string to apply before uploading the file to the Media Library. @@ -1481,7 +1521,7 @@ export namespace FileUploadParams { type: 'transformation'; /** - * Transformation string (e.g. `w-200,h-200`). + * Transformation string (e.g. `w-200,h-200`). * Same syntax as ImageKit URL-based transformations. */ value: string; @@ -1494,7 +1534,7 @@ export namespace FileUploadParams { type: 'gif-to-video'; /** - * Optional transformation string to apply to the output video. + * Optional transformation string to apply to the output video. * **Example**: `q-80` */ value?: string; @@ -1507,7 +1547,7 @@ export namespace FileUploadParams { type: 'thumbnail'; /** - * Optional transformation string. + * Optional transformation string. * **Example**: `w-150,h-150` */ value?: string; @@ -1550,7 +1590,7 @@ export declare namespace Files { type FileCopyParams as FileCopyParams, type FileMoveParams as FileMoveParams, type FileRenameParams as FileRenameParams, - type FileUploadParams as FileUploadParams + type FileUploadParams as FileUploadParams, }; export { @@ -1562,7 +1602,7 @@ export declare namespace Files { type BulkDeleteParams as BulkDeleteParams, type BulkAddTagsParams as BulkAddTagsParams, type BulkRemoveAITagsParams as BulkRemoveAITagsParams, - type BulkRemoveTagsParams as BulkRemoveTagsParams + type BulkRemoveTagsParams as BulkRemoveTagsParams, }; export { @@ -1571,10 +1611,8 @@ export declare namespace Files { type VersionDeleteResponse as VersionDeleteResponse, type VersionDeleteParams as VersionDeleteParams, type VersionGetParams as VersionGetParams, - type VersionRestoreParams as VersionRestoreParams + type VersionRestoreParams as VersionRestoreParams, }; - export { - type MetadataGetFromURLParams as MetadataGetFromURLParams - }; + export { type MetadataGetFromURLParams as MetadataGetFromURLParams }; } diff --git a/src/resources/files/index.ts b/src/resources/files/index.ts index f0318ae4..de6d1ad7 100644 --- a/src/resources/files/index.ts +++ b/src/resources/files/index.ts @@ -1,6 +1,39 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Bulk, type BulkDeleteResponse, type BulkAddTagsResponse, type BulkRemoveAITagsResponse, type BulkRemoveTagsResponse, type BulkDeleteParams, type BulkAddTagsParams, type BulkRemoveAITagsParams, type BulkRemoveTagsParams } from './bulk';; -export { Files, type File, type Folder, type Metadata, type UpdateFileRequest, type FileUpdateResponse, type FileCopyResponse, type FileMoveResponse, type FileRenameResponse, type FileUploadResponse, type FileUpdateParams, type FileCopyParams, type FileMoveParams, type FileRenameParams, type FileUploadParams } from './files';; -export { Versions, type VersionListResponse, type VersionDeleteResponse, type VersionDeleteParams, type VersionGetParams, type VersionRestoreParams } from './versions';; -export { type MetadataGetFromURLParams } from './metadata';; +export { + Bulk, + type BulkDeleteResponse, + type BulkAddTagsResponse, + type BulkRemoveAITagsResponse, + type BulkRemoveTagsResponse, + type BulkDeleteParams, + type BulkAddTagsParams, + type BulkRemoveAITagsParams, + type BulkRemoveTagsParams, +} from './bulk'; +export { + Files, + type File, + type Folder, + type Metadata, + type UpdateFileRequest, + type FileUpdateResponse, + type FileCopyResponse, + type FileMoveResponse, + type FileRenameResponse, + type FileUploadResponse, + type FileUpdateParams, + type FileCopyParams, + type FileMoveParams, + type FileRenameParams, + type FileUploadParams, +} from './files'; +export { + Versions, + type VersionListResponse, + type VersionDeleteResponse, + type VersionDeleteParams, + type VersionGetParams, + type VersionRestoreParams, +} from './versions'; +export { type MetadataGetFromURLParams } from './metadata'; diff --git a/src/resources/files/metadata.ts b/src/resources/files/metadata.ts index 6d850825..1aa79caf 100644 --- a/src/resources/files/metadata.ts +++ b/src/resources/files/metadata.ts @@ -48,7 +48,5 @@ export interface MetadataGetFromURLParams { } export declare namespace Metadata { - export { - type MetadataGetFromURLParams as MetadataGetFromURLParams - }; + export { type MetadataGetFromURLParams as MetadataGetFromURLParams }; } diff --git a/src/resources/files/versions.ts b/src/resources/files/versions.ts index 125eee61..4cd160bd 100644 --- a/src/resources/files/versions.ts +++ b/src/resources/files/versions.ts @@ -33,8 +33,12 @@ export class Versions extends APIResource { * ); * ``` */ - delete(versionID: string, params: VersionDeleteParams, options?: RequestOptions): APIPromise { - const { fileId } = params + delete( + versionID: string, + params: VersionDeleteParams, + options?: RequestOptions, + ): APIPromise { + const { fileId } = params; return this._client.delete(path`/v1/files/${fileId}/versions/${versionID}`, options); } @@ -49,7 +53,7 @@ export class Versions extends APIResource { * ``` */ get(versionID: string, params: VersionGetParams, options?: RequestOptions): APIPromise { - const { fileId } = params + const { fileId } = params; return this._client.get(path`/v1/files/${fileId}/versions/${versionID}`, options); } @@ -64,16 +68,19 @@ export class Versions extends APIResource { * ); * ``` */ - restore(versionID: string, params: VersionRestoreParams, options?: RequestOptions): APIPromise { - const { fileId } = params + restore( + versionID: string, + params: VersionRestoreParams, + options?: RequestOptions, + ): APIPromise { + const { fileId } = params; return this._client.put(path`/v1/files/${fileId}/versions/${versionID}/restore`, options); } } -export type VersionListResponse = Array +export type VersionListResponse = Array; -export interface VersionDeleteResponse { -} +export interface VersionDeleteResponse {} export interface VersionDeleteParams { /** @@ -105,6 +112,6 @@ export declare namespace Versions { type VersionDeleteResponse as VersionDeleteResponse, type VersionDeleteParams as VersionDeleteParams, type VersionGetParams as VersionGetParams, - type VersionRestoreParams as VersionRestoreParams + type VersionRestoreParams as VersionRestoreParams, }; } diff --git a/src/resources/folders/folders.ts b/src/resources/folders/folders.ts index 56175222..916e3042 100644 --- a/src/resources/folders/folders.ts +++ b/src/resources/folders/folders.ts @@ -95,11 +95,9 @@ export class Folders extends APIResource { } } -export interface FolderCreateResponse { -} +export interface FolderCreateResponse {} -export interface FolderDeleteResponse { -} +export interface FolderDeleteResponse {} /** * Job submitted successfully. A `jobId` will be returned. @@ -244,11 +242,8 @@ export declare namespace Folders { type FolderDeleteParams as FolderDeleteParams, type FolderCopyParams as FolderCopyParams, type FolderMoveParams as FolderMoveParams, - type FolderRenameParams as FolderRenameParams + type FolderRenameParams as FolderRenameParams, }; - export { - Job as Job, - type JobGetResponse as JobGetResponse - }; + export { Job as Job, type JobGetResponse as JobGetResponse }; } diff --git a/src/resources/folders/index.ts b/src/resources/folders/index.ts index 81d62189..7759a7d4 100644 --- a/src/resources/folders/index.ts +++ b/src/resources/folders/index.ts @@ -1,4 +1,16 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Folders, type FolderCreateResponse, type FolderDeleteResponse, type FolderCopyResponse, type FolderMoveResponse, type FolderRenameResponse, type FolderCreateParams, type FolderDeleteParams, type FolderCopyParams, type FolderMoveParams, type FolderRenameParams } from './folders';; -export { Job, type JobGetResponse } from './job';; +export { + Folders, + type FolderCreateResponse, + type FolderDeleteResponse, + type FolderCopyResponse, + type FolderMoveResponse, + type FolderRenameResponse, + type FolderCreateParams, + type FolderDeleteParams, + type FolderCopyParams, + type FolderMoveParams, + type FolderRenameParams, +} from './folders'; +export { Job, type JobGetResponse } from './job'; diff --git a/src/resources/folders/job.ts b/src/resources/folders/job.ts index 8a908073..a9fc92b6 100644 --- a/src/resources/folders/job.ts +++ b/src/resources/folders/job.ts @@ -43,7 +43,5 @@ export interface JobGetResponse { } export declare namespace Job { - export { - type JobGetResponse as JobGetResponse - }; + export { type JobGetResponse as JobGetResponse }; } diff --git a/src/resources/saved-extensions.ts b/src/resources/saved-extensions.ts index f117de0a..ff39d734 100644 --- a/src/resources/saved-extensions.ts +++ b/src/resources/saved-extensions.ts @@ -50,7 +50,11 @@ export class SavedExtensions extends APIResource { * ); * ``` */ - update(id: string, body: SavedExtensionUpdateParams, options?: RequestOptions): APIPromise { + update( + id: string, + body: SavedExtensionUpdateParams, + options?: RequestOptions, + ): APIPromise { return this._client.patch(path`/v1/saved-extensions/${id}`, { body, ...options }); } @@ -77,7 +81,10 @@ export class SavedExtensions extends APIResource { * ``` */ delete(id: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/saved-extensions/${id}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); + return this._client.delete(path`/v1/saved-extensions/${id}`, { + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); } /** @@ -95,7 +102,7 @@ export class SavedExtensions extends APIResource { } } -export type SavedExtensionListResponse = Array +export type SavedExtensionListResponse = Array; export interface SavedExtensionCreateParams { /** @@ -137,6 +144,6 @@ export declare namespace SavedExtensions { export { type SavedExtensionListResponse as SavedExtensionListResponse, type SavedExtensionCreateParams as SavedExtensionCreateParams, - type SavedExtensionUpdateParams as SavedExtensionUpdateParams + type SavedExtensionUpdateParams as SavedExtensionUpdateParams, }; } diff --git a/src/resources/shared.ts b/src/resources/shared.ts index 3b07fe08..fcd500ad 100644 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -1,6 +1,5 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - export interface BaseOverlay { /** * Controls how the layer blends with the base image or underlying content. Maps to @@ -44,7 +43,11 @@ export interface BaseOverlay { * Configuration object for an extension (base extensions only, not saved extension * references). */ -export type ExtensionConfig = ExtensionConfig.RemoveBg | ExtensionConfig.AutoTaggingExtension | ExtensionConfig.AIAutoDescription | ExtensionConfig.AITasks +export type ExtensionConfig = + | ExtensionConfig.RemoveBg + | ExtensionConfig.AutoTaggingExtension + | ExtensionConfig.AIAutoDescription + | ExtensionConfig.AITasks; export namespace ExtensionConfig { export interface RemoveBg { @@ -364,7 +367,13 @@ export namespace ExtensionConfig { * Array of extensions to be applied to the asset. Each extension can be configured * with specific parameters based on the extension type. */ -export type Extensions = Array +export type Extensions = Array< + | Extensions.RemoveBg + | Extensions.AutoTaggingExtension + | Extensions.AIAutoDescription + | Extensions.AITasks + | Extensions.SavedExtension +>; export namespace Extensions { export interface RemoveBg { @@ -779,7 +788,7 @@ export interface ImageOverlay extends BaseOverlay { * See * [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). */ -export type Overlay = TextOverlay | ImageOverlay | VideoOverlay | SubtitleOverlay | SolidColorOverlay +export type Overlay = TextOverlay | ImageOverlay | VideoOverlay | SubtitleOverlay | SolidColorOverlay; export interface OverlayPosition { /** @@ -787,14 +796,32 @@ export interface OverlayPosition { * calculated. The default value is `top_left`. Maps to `lap` in the URL. Can only * be used with one or more of `x`, `y`, `xCenter`, or `yCenter`. */ - anchorPoint?: 'top' | 'left' | 'right' | 'bottom' | 'top_left' | 'top_right' | 'bottom_left' | 'bottom_right' | 'center'; + anchorPoint?: + | 'top' + | 'left' + | 'right' + | 'bottom' + | 'top_left' + | 'top_right' + | 'bottom_left' + | 'bottom_right' + | 'center'; /** * Specifies the position of the overlay relative to the parent image or video. If * one or more of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this * parameter is ignored. Maps to `lfo` in the URL. */ - focus?: 'center' | 'top' | 'left' | 'bottom' | 'right' | 'top_left' | 'top_right' | 'bottom_left' | 'bottom_right'; + focus?: + | 'center' + | 'top' + | 'left' + | 'bottom' + | 'right' + | 'top_left' + | 'top_right' + | 'bottom_left' + | 'bottom_right'; /** * Specifies the x-coordinate of the top-left corner of the base asset where the @@ -1062,7 +1089,7 @@ export interface SrcOptions { * Available streaming resolutions for * [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) */ -export type StreamingResolution = '240' | '360' | '480' | '720' | '1080' | '1440' | '2160' +export type StreamingResolution = '240' | '360' | '480' | '720' | '1080' | '1440' | '2160'; export interface SubtitleOverlay extends BaseOverlay { /** @@ -1317,7 +1344,7 @@ export interface Transformation { /** * Uses AI to edit images based on a text prompt. Provide a text prompt or a * base64-encoded prompt, e.g., `prompt-snow road` or - * `prompte-[urlencoded_base64_encoded_text]`. Not supported inside overlay. + * `prompte-[urlencoded_base64_encoded_text]`. Not supported inside overlay. * See [AI Edit](https://imagekit.io/docs/ai-transformations#edit-image-e-edit). */ aiEdit?: string; @@ -1732,7 +1759,7 @@ export interface Transformation { * path of the URL, set this to `path`. Learn more in the * [Transformations guide](https://imagekit.io/docs/transformations). */ -export type TransformationPosition = 'path' | 'query' +export type TransformationPosition = 'path' | 'query'; export interface VideoOverlay extends BaseOverlay { /** diff --git a/src/resources/webhooks.ts b/src/resources/webhooks.ts index 984ade65..be299493 100644 --- a/src/resources/webhooks.ts +++ b/src/resources/webhooks.ts @@ -10,7 +10,10 @@ export class Webhooks extends APIResource { return JSON.parse(body) as UnsafeUnwrapWebhookEvent; } - unwrap(body: string, { headers, key }: { headers: Record; key?: string }): UnwrapWebhookEvent { + unwrap( + body: string, + { headers, key }: { headers: Record; key?: string }, + ): UnwrapWebhookEvent { if (headers !== undefined) { const keyStr: string | null = key === undefined ? this._client.webhookSecret : key; if (keyStr === null) throw new Error('Webhook key must not be null in order to unwrap'); @@ -1150,14 +1153,38 @@ export namespace VideoTransformationReadyEvent { * This event confirms that ImageKit has received and queued your transformation * request. Use this for debugging and tracking transformation lifecycle. */ -export type UnsafeUnwrapWebhookEvent = VideoTransformationAcceptedEvent | VideoTransformationReadyEvent | VideoTransformationErrorEvent | UploadPreTransformSuccessEvent | UploadPreTransformErrorEvent | UploadPostTransformSuccessEvent | UploadPostTransformErrorEvent | FileCreateEvent | FileUpdateEvent | FileDeleteEvent | FileVersionCreateEvent | FileVersionDeleteEvent +export type UnsafeUnwrapWebhookEvent = + | VideoTransformationAcceptedEvent + | VideoTransformationReadyEvent + | VideoTransformationErrorEvent + | UploadPreTransformSuccessEvent + | UploadPreTransformErrorEvent + | UploadPostTransformSuccessEvent + | UploadPostTransformErrorEvent + | FileCreateEvent + | FileUpdateEvent + | FileDeleteEvent + | FileVersionCreateEvent + | FileVersionDeleteEvent; /** * Triggered when a new video transformation request is accepted for processing. * This event confirms that ImageKit has received and queued your transformation * request. Use this for debugging and tracking transformation lifecycle. */ -export type UnwrapWebhookEvent = VideoTransformationAcceptedEvent | VideoTransformationReadyEvent | VideoTransformationErrorEvent | UploadPreTransformSuccessEvent | UploadPreTransformErrorEvent | UploadPostTransformSuccessEvent | UploadPostTransformErrorEvent | FileCreateEvent | FileUpdateEvent | FileDeleteEvent | FileVersionCreateEvent | FileVersionDeleteEvent +export type UnwrapWebhookEvent = + | VideoTransformationAcceptedEvent + | VideoTransformationReadyEvent + | VideoTransformationErrorEvent + | UploadPreTransformSuccessEvent + | UploadPreTransformErrorEvent + | UploadPostTransformSuccessEvent + | UploadPostTransformErrorEvent + | FileCreateEvent + | FileUpdateEvent + | FileDeleteEvent + | FileVersionCreateEvent + | FileVersionDeleteEvent; export declare namespace Webhooks { export { @@ -1175,6 +1202,6 @@ export declare namespace Webhooks { type VideoTransformationErrorEvent as VideoTransformationErrorEvent, type VideoTransformationReadyEvent as VideoTransformationReadyEvent, type UnsafeUnwrapWebhookEvent as UnsafeUnwrapWebhookEvent, - type UnwrapWebhookEvent as UnwrapWebhookEvent + type UnwrapWebhookEvent as UnwrapWebhookEvent, }; } diff --git a/src/uploads.ts b/src/uploads.ts index d5437085..b2ef6471 100644 --- a/src/uploads.ts +++ b/src/uploads.ts @@ -1,2 +1,2 @@ /** @deprecated Import from ./core/uploads instead */ -export * from "./core/uploads" \ No newline at end of file +export * from './core/uploads'; diff --git a/src/version.ts b/src/version.ts index 508ca0a4..662d85ef 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '7.5.0';// x-release-please-version +export const VERSION = '7.5.0'; // x-release-please-version diff --git a/tests/api-resources/accounts/origins.test.ts b/tests/api-resources/accounts/origins.test.ts index bbca9168..2be57f09 100644 --- a/tests/api-resources/accounts/origins.test.ts +++ b/tests/api-resources/accounts/origins.test.ts @@ -5,19 +5,19 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource origins', () => { // Mock server tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.accounts.origins.create({ - accessKey: 'AKIAIOSFODNN7EXAMPLE', - bucket: 'product-images', - name: 'US S3 Storage', - secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', - type: 'S3', - }); + accessKey: 'AKIAIOSFODNN7EXAMPLE', + bucket: 'product-images', + name: 'US S3 Storage', + secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', + type: 'S3', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -30,26 +30,26 @@ describe('resource origins', () => { // Mock server tests are disabled test.skip('create: required and optional params', async () => { const response = await client.accounts.origins.create({ - accessKey: 'AKIAIOSFODNN7EXAMPLE', - bucket: 'product-images', - name: 'US S3 Storage', - secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', - type: 'S3', - baseUrlForCanonicalHeader: 'https://cdn.example.com', - includeCanonicalHeader: false, - prefix: 'raw-assets', - }); + accessKey: 'AKIAIOSFODNN7EXAMPLE', + bucket: 'product-images', + name: 'US S3 Storage', + secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', + type: 'S3', + baseUrlForCanonicalHeader: 'https://cdn.example.com', + includeCanonicalHeader: false, + prefix: 'raw-assets', + }); }); // Mock server tests are disabled test.skip('update: only required params', async () => { const responsePromise = client.accounts.origins.update('id', { - accessKey: 'AKIAIOSFODNN7EXAMPLE', - bucket: 'product-images', - name: 'US S3 Storage', - secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', - type: 'S3', - }); + accessKey: 'AKIAIOSFODNN7EXAMPLE', + bucket: 'product-images', + name: 'US S3 Storage', + secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', + type: 'S3', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -62,15 +62,15 @@ describe('resource origins', () => { // Mock server tests are disabled test.skip('update: required and optional params', async () => { const response = await client.accounts.origins.update('id', { - accessKey: 'AKIAIOSFODNN7EXAMPLE', - bucket: 'product-images', - name: 'US S3 Storage', - secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', - type: 'S3', - baseUrlForCanonicalHeader: 'https://cdn.example.com', - includeCanonicalHeader: false, - prefix: 'raw-assets', - }); + accessKey: 'AKIAIOSFODNN7EXAMPLE', + bucket: 'product-images', + name: 'US S3 Storage', + secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', + type: 'S3', + baseUrlForCanonicalHeader: 'https://cdn.example.com', + includeCanonicalHeader: false, + prefix: 'raw-assets', + }); }); // Mock server tests are disabled diff --git a/tests/api-resources/accounts/url-endpoints.test.ts b/tests/api-resources/accounts/url-endpoints.test.ts index fe281d50..b53af030 100644 --- a/tests/api-resources/accounts/url-endpoints.test.ts +++ b/tests/api-resources/accounts/url-endpoints.test.ts @@ -5,7 +5,7 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource urlEndpoints', () => { @@ -24,16 +24,18 @@ describe('resource urlEndpoints', () => { // Mock server tests are disabled test.skip('create: required and optional params', async () => { const response = await client.accounts.urlEndpoints.create({ - description: 'My custom URL endpoint', - origins: ['origin-id-1'], - urlPrefix: 'product-images', - urlRewriter: { type: 'CLOUDINARY', preserveAssetDeliveryTypes: true }, - }); + description: 'My custom URL endpoint', + origins: ['origin-id-1'], + urlPrefix: 'product-images', + urlRewriter: { type: 'CLOUDINARY', preserveAssetDeliveryTypes: true }, + }); }); // Mock server tests are disabled test.skip('update: only required params', async () => { - const responsePromise = client.accounts.urlEndpoints.update('id', { description: 'My custom URL endpoint' }); + const responsePromise = client.accounts.urlEndpoints.update('id', { + description: 'My custom URL endpoint', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -46,11 +48,11 @@ describe('resource urlEndpoints', () => { // Mock server tests are disabled test.skip('update: required and optional params', async () => { const response = await client.accounts.urlEndpoints.update('id', { - description: 'My custom URL endpoint', - origins: ['origin-id-1'], - urlPrefix: 'product-images', - urlRewriter: { type: 'CLOUDINARY', preserveAssetDeliveryTypes: true }, - }); + description: 'My custom URL endpoint', + origins: ['origin-id-1'], + urlPrefix: 'product-images', + urlRewriter: { type: 'CLOUDINARY', preserveAssetDeliveryTypes: true }, + }); }); // Mock server tests are disabled diff --git a/tests/api-resources/accounts/usage.test.ts b/tests/api-resources/accounts/usage.test.ts index fd5300c7..161cdc71 100644 --- a/tests/api-resources/accounts/usage.test.ts +++ b/tests/api-resources/accounts/usage.test.ts @@ -5,7 +5,7 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource usage', () => { diff --git a/tests/api-resources/assets.test.ts b/tests/api-resources/assets.test.ts index cd78ff5e..bf41276e 100644 --- a/tests/api-resources/assets.test.ts +++ b/tests/api-resources/assets.test.ts @@ -5,7 +5,7 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource assets', () => { @@ -24,16 +24,19 @@ describe('resource assets', () => { // Mock server tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect(client.assets.list({ - fileType: 'all', - limit: 1, - path: 'path', - searchQuery: 'searchQuery', - skip: 0, - sort: 'ASC_NAME', - type: 'file', - }, { path: '/_stainless_unknown_path' })) - .rejects - .toThrow(ImageKit.NotFoundError); + await expect( + client.assets.list( + { + fileType: 'all', + limit: 1, + path: 'path', + searchQuery: 'searchQuery', + skip: 0, + sort: 'ASC_NAME', + type: 'file', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(ImageKit.NotFoundError); }); }); diff --git a/tests/api-resources/beta/v2/files.test.ts b/tests/api-resources/beta/v2/files.test.ts index dbfe3bf3..69af3768 100644 --- a/tests/api-resources/beta/v2/files.test.ts +++ b/tests/api-resources/beta/v2/files.test.ts @@ -5,13 +5,16 @@ import ImageKit, { toFile } from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource files', () => { // Mock server tests are disabled test.skip('upload: only required params', async () => { - const responsePromise = client.beta.v2.files.upload({ file: await toFile(Buffer.from('Example data'), 'README.md'), fileName: 'fileName' }); + const responsePromise = client.beta.v2.files.upload({ + file: await toFile(Buffer.from('Example data'), 'README.md'), + fileName: 'fileName', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -24,69 +27,87 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('upload: required and optional params', async () => { const response = await client.beta.v2.files.upload({ - file: await toFile(Buffer.from('Example data'), 'README.md'), - fileName: 'fileName', - token: 'token', - checks: '"request.folder" : "marketing/"\n', - customCoordinates: 'customCoordinates', - customMetadata: { brand: 'bar', color: 'bar' }, - description: 'Running shoes', - extensions: [{ - name: 'remove-bg', - options: { - add_shadow: true, - bg_color: 'bg_color', - bg_image_url: 'bg_image_url', - semitransparency: true, - }, - }, { - maxTags: 5, - minConfidence: 95, - name: 'google-auto-tagging', - }, { name: 'ai-auto-description' }, { name: 'ai-tasks', tasks: [{ - instruction: 'What types of clothing items are visible in this image?', - type: 'select_tags', - max_selections: 1, - min_selections: 0, - vocabulary: ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'], - }, { - instruction: 'Is this a luxury or high-end fashion item?', - type: 'yes_no', - on_no: { - add_tags: ['luxury', 'premium'], - remove_tags: ['budget', 'affordable'], - set_metadata: [{ field: 'price_range', value: 'premium' }], - unset_metadata: [{ field: 'price_range' }], - }, - on_unknown: { - add_tags: ['luxury', 'premium'], - remove_tags: ['budget', 'affordable'], - set_metadata: [{ field: 'price_range', value: 'premium' }], - unset_metadata: [{ field: 'price_range' }], - }, - on_yes: { - add_tags: ['luxury', 'premium'], - remove_tags: ['budget', 'affordable'], - set_metadata: [{ field: 'price_range', value: 'premium' }], - unset_metadata: [{ field: 'price_range' }], - }, - }] }, { id: 'ext_abc123', name: 'saved-extension' }], - folder: 'folder', - isPrivateFile: true, - isPublished: true, - overwriteAITags: true, - overwriteCustomMetadata: true, - overwriteFile: true, - overwriteTags: true, - responseFields: ['tags', 'customCoordinates', 'isPrivateFile'], - tags: ['t-shirt', 'round-neck', 'men'], - transformation: { post: [{ type: 'thumbnail', value: 'w-150,h-150' }, { - protocol: 'dash', - type: 'abs', - value: 'sr-240_360_480_720_1080', - }], pre: 'w-300,h-300,q-80' }, - useUniqueFileName: true, - webhookUrl: 'https://example.com', - }); + file: await toFile(Buffer.from('Example data'), 'README.md'), + fileName: 'fileName', + token: 'token', + checks: '"request.folder" : "marketing/"\n', + customCoordinates: 'customCoordinates', + customMetadata: { brand: 'bar', color: 'bar' }, + description: 'Running shoes', + extensions: [ + { + name: 'remove-bg', + options: { + add_shadow: true, + bg_color: 'bg_color', + bg_image_url: 'bg_image_url', + semitransparency: true, + }, + }, + { + maxTags: 5, + minConfidence: 95, + name: 'google-auto-tagging', + }, + { name: 'ai-auto-description' }, + { + name: 'ai-tasks', + tasks: [ + { + instruction: 'What types of clothing items are visible in this image?', + type: 'select_tags', + max_selections: 1, + min_selections: 0, + vocabulary: ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'], + }, + { + instruction: 'Is this a luxury or high-end fashion item?', + type: 'yes_no', + on_no: { + add_tags: ['luxury', 'premium'], + remove_tags: ['budget', 'affordable'], + set_metadata: [{ field: 'price_range', value: 'premium' }], + unset_metadata: [{ field: 'price_range' }], + }, + on_unknown: { + add_tags: ['luxury', 'premium'], + remove_tags: ['budget', 'affordable'], + set_metadata: [{ field: 'price_range', value: 'premium' }], + unset_metadata: [{ field: 'price_range' }], + }, + on_yes: { + add_tags: ['luxury', 'premium'], + remove_tags: ['budget', 'affordable'], + set_metadata: [{ field: 'price_range', value: 'premium' }], + unset_metadata: [{ field: 'price_range' }], + }, + }, + ], + }, + { id: 'ext_abc123', name: 'saved-extension' }, + ], + folder: 'folder', + isPrivateFile: true, + isPublished: true, + overwriteAITags: true, + overwriteCustomMetadata: true, + overwriteFile: true, + overwriteTags: true, + responseFields: ['tags', 'customCoordinates', 'isPrivateFile'], + tags: ['t-shirt', 'round-neck', 'men'], + transformation: { + post: [ + { type: 'thumbnail', value: 'w-150,h-150' }, + { + protocol: 'dash', + type: 'abs', + value: 'sr-240_360_480_720_1080', + }, + ], + pre: 'w-300,h-300,q-80', + }, + useUniqueFileName: true, + webhookUrl: 'https://example.com', + }); }); }); diff --git a/tests/api-resources/cache/invalidation.test.ts b/tests/api-resources/cache/invalidation.test.ts index 9f791c8a..d804f743 100644 --- a/tests/api-resources/cache/invalidation.test.ts +++ b/tests/api-resources/cache/invalidation.test.ts @@ -5,13 +5,15 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource invalidation', () => { // Mock server tests are disabled test.skip('create: only required params', async () => { - const responsePromise = client.cache.invalidation.create({ url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg' }); + const responsePromise = client.cache.invalidation.create({ + url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,7 +25,9 @@ describe('resource invalidation', () => { // Mock server tests are disabled test.skip('create: required and optional params', async () => { - const response = await client.cache.invalidation.create({ url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg' }); + const response = await client.cache.invalidation.create({ + url: 'https://ik.imagekit.io/your_imagekit_id/default-image.jpg', + }); }); // Mock server tests are disabled diff --git a/tests/api-resources/custom-metadata-fields.test.ts b/tests/api-resources/custom-metadata-fields.test.ts index 9abb46d1..52e39794 100644 --- a/tests/api-resources/custom-metadata-fields.test.ts +++ b/tests/api-resources/custom-metadata-fields.test.ts @@ -5,17 +5,17 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource customMetadataFields', () => { // Mock server tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.customMetadataFields.create({ - label: 'price', - name: 'price', - schema: { type: 'Number' }, - }); + label: 'price', + name: 'price', + schema: { type: 'Number' }, + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -28,19 +28,19 @@ describe('resource customMetadataFields', () => { // Mock server tests are disabled test.skip('create: required and optional params', async () => { const response = await client.customMetadataFields.create({ - label: 'price', - name: 'price', - schema: { - type: 'Number', - defaultValue: [true, 10, 'Hello'], - isValueRequired: true, - maxLength: 0, - maxValue: 3000, - minLength: 0, - minValue: 1000, - selectOptions: ['small', 'medium', 'large', 30, 40, true], - }, - }); + label: 'price', + name: 'price', + schema: { + type: 'Number', + defaultValue: [true, 10, 'Hello'], + isValueRequired: true, + maxLength: 0, + maxValue: 3000, + minLength: 0, + minValue: 1000, + selectOptions: ['small', 'medium', 'large', 30, 40, true], + }, + }); }); // Mock server tests are disabled @@ -58,20 +58,24 @@ describe('resource customMetadataFields', () => { // Mock server tests are disabled test.skip('update: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect(client.customMetadataFields.update('id', { - label: 'price', - schema: { - defaultValue: [true, 10, 'Hello'], - isValueRequired: true, - maxLength: 0, - maxValue: 3000, - minLength: 0, - minValue: 1000, - selectOptions: ['small', 'medium', 'large', 30, 40, true], - }, - }, { path: '/_stainless_unknown_path' })) - .rejects - .toThrow(ImageKit.NotFoundError); + await expect( + client.customMetadataFields.update( + 'id', + { + label: 'price', + schema: { + defaultValue: [true, 10, 'Hello'], + isValueRequired: true, + maxLength: 0, + maxValue: 3000, + minLength: 0, + minValue: 1000, + selectOptions: ['small', 'medium', 'large', 30, 40, true], + }, + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(ImageKit.NotFoundError); }); // Mock server tests are disabled @@ -89,9 +93,12 @@ describe('resource customMetadataFields', () => { // Mock server tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect(client.customMetadataFields.list({ folderPath: 'folderPath', includeDeleted: true }, { path: '/_stainless_unknown_path' })) - .rejects - .toThrow(ImageKit.NotFoundError); + await expect( + client.customMetadataFields.list( + { folderPath: 'folderPath', includeDeleted: true }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(ImageKit.NotFoundError); }); // Mock server tests are disabled diff --git a/tests/api-resources/files/bulk.test.ts b/tests/api-resources/files/bulk.test.ts index 4b7a3129..1c417b90 100644 --- a/tests/api-resources/files/bulk.test.ts +++ b/tests/api-resources/files/bulk.test.ts @@ -5,13 +5,15 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource bulk', () => { // Mock server tests are disabled test.skip('delete: only required params', async () => { - const responsePromise = client.files.bulk.delete({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] }); + const responsePromise = client.files.bulk.delete({ + fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,12 +25,17 @@ describe('resource bulk', () => { // Mock server tests are disabled test.skip('delete: required and optional params', async () => { - const response = await client.files.bulk.delete({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] }); + const response = await client.files.bulk.delete({ + fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + }); }); // Mock server tests are disabled test.skip('addTags: only required params', async () => { - const responsePromise = client.files.bulk.addTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] }); + const responsePromise = client.files.bulk.addTags({ + fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + tags: ['t-shirt', 'round-neck', 'sale2019'], + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -40,12 +47,18 @@ describe('resource bulk', () => { // Mock server tests are disabled test.skip('addTags: required and optional params', async () => { - const response = await client.files.bulk.addTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] }); + const response = await client.files.bulk.addTags({ + fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + tags: ['t-shirt', 'round-neck', 'sale2019'], + }); }); // Mock server tests are disabled test.skip('removeAITags: only required params', async () => { - const responsePromise = client.files.bulk.removeAITags({ AITags: ['t-shirt', 'round-neck', 'sale2019'], fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] }); + const responsePromise = client.files.bulk.removeAITags({ + AITags: ['t-shirt', 'round-neck', 'sale2019'], + fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -57,12 +70,18 @@ describe('resource bulk', () => { // Mock server tests are disabled test.skip('removeAITags: required and optional params', async () => { - const response = await client.files.bulk.removeAITags({ AITags: ['t-shirt', 'round-neck', 'sale2019'], fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'] }); + const response = await client.files.bulk.removeAITags({ + AITags: ['t-shirt', 'round-neck', 'sale2019'], + fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + }); }); // Mock server tests are disabled test.skip('removeTags: only required params', async () => { - const responsePromise = client.files.bulk.removeTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] }); + const responsePromise = client.files.bulk.removeTags({ + fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + tags: ['t-shirt', 'round-neck', 'sale2019'], + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -74,6 +93,9 @@ describe('resource bulk', () => { // Mock server tests are disabled test.skip('removeTags: required and optional params', async () => { - const response = await client.files.bulk.removeTags({ fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], tags: ['t-shirt', 'round-neck', 'sale2019'] }); + const response = await client.files.bulk.removeTags({ + fileIds: ['598821f949c0a938d57563bd', '598821f949c0a938d57563be'], + tags: ['t-shirt', 'round-neck', 'sale2019'], + }); }); }); diff --git a/tests/api-resources/files/files.test.ts b/tests/api-resources/files/files.test.ts index 4a7a05de..aeb90697 100644 --- a/tests/api-resources/files/files.test.ts +++ b/tests/api-resources/files/files.test.ts @@ -5,7 +5,7 @@ import ImageKit, { toFile } from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource files', () => { @@ -35,7 +35,10 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('copy: only required params', async () => { - const responsePromise = client.files.copy({ destinationPath: '/folder/to/copy/into/', sourceFilePath: '/path/to/file.jpg' }); + const responsePromise = client.files.copy({ + destinationPath: '/folder/to/copy/into/', + sourceFilePath: '/path/to/file.jpg', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -48,10 +51,10 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('copy: required and optional params', async () => { const response = await client.files.copy({ - destinationPath: '/folder/to/copy/into/', - sourceFilePath: '/path/to/file.jpg', - includeFileVersions: false, - }); + destinationPath: '/folder/to/copy/into/', + sourceFilePath: '/path/to/file.jpg', + includeFileVersions: false, + }); }); // Mock server tests are disabled @@ -68,7 +71,10 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('move: only required params', async () => { - const responsePromise = client.files.move({ destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg' }); + const responsePromise = client.files.move({ + destinationPath: '/folder/to/move/into/', + sourceFilePath: '/path/to/file.jpg', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -80,12 +86,18 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('move: required and optional params', async () => { - const response = await client.files.move({ destinationPath: '/folder/to/move/into/', sourceFilePath: '/path/to/file.jpg' }); + const response = await client.files.move({ + destinationPath: '/folder/to/move/into/', + sourceFilePath: '/path/to/file.jpg', + }); }); // Mock server tests are disabled test.skip('rename: only required params', async () => { - const responsePromise = client.files.rename({ filePath: '/path/to/file.jpg', newFileName: 'newFileName.jpg' }); + const responsePromise = client.files.rename({ + filePath: '/path/to/file.jpg', + newFileName: 'newFileName.jpg', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -98,15 +110,18 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('rename: required and optional params', async () => { const response = await client.files.rename({ - filePath: '/path/to/file.jpg', - newFileName: 'newFileName.jpg', - purgeCache: true, - }); + filePath: '/path/to/file.jpg', + newFileName: 'newFileName.jpg', + purgeCache: true, + }); }); // Mock server tests are disabled test.skip('upload: only required params', async () => { - const responsePromise = client.files.upload({ file: await toFile(Buffer.from('Example data'), 'README.md'), fileName: 'fileName' }); + const responsePromise = client.files.upload({ + file: await toFile(Buffer.from('Example data'), 'README.md'), + fileName: 'fileName', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -119,72 +134,90 @@ describe('resource files', () => { // Mock server tests are disabled test.skip('upload: required and optional params', async () => { const response = await client.files.upload({ - file: await toFile(Buffer.from('Example data'), 'README.md'), - fileName: 'fileName', - token: 'token', - checks: '"request.folder" : "marketing/"\n', - customCoordinates: 'customCoordinates', - customMetadata: { brand: 'bar', color: 'bar' }, - description: 'Running shoes', - expire: 0, - extensions: [{ - name: 'remove-bg', - options: { - add_shadow: true, - bg_color: 'bg_color', - bg_image_url: 'bg_image_url', - semitransparency: true, - }, - }, { - maxTags: 5, - minConfidence: 95, - name: 'google-auto-tagging', - }, { name: 'ai-auto-description' }, { name: 'ai-tasks', tasks: [{ - instruction: 'What types of clothing items are visible in this image?', - type: 'select_tags', - max_selections: 1, - min_selections: 0, - vocabulary: ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'], - }, { - instruction: 'Is this a luxury or high-end fashion item?', - type: 'yes_no', - on_no: { - add_tags: ['luxury', 'premium'], - remove_tags: ['budget', 'affordable'], - set_metadata: [{ field: 'price_range', value: 'premium' }], - unset_metadata: [{ field: 'price_range' }], - }, - on_unknown: { - add_tags: ['luxury', 'premium'], - remove_tags: ['budget', 'affordable'], - set_metadata: [{ field: 'price_range', value: 'premium' }], - unset_metadata: [{ field: 'price_range' }], - }, - on_yes: { - add_tags: ['luxury', 'premium'], - remove_tags: ['budget', 'affordable'], - set_metadata: [{ field: 'price_range', value: 'premium' }], - unset_metadata: [{ field: 'price_range' }], - }, - }] }, { id: 'ext_abc123', name: 'saved-extension' }], - folder: 'folder', - isPrivateFile: true, - isPublished: true, - overwriteAITags: true, - overwriteCustomMetadata: true, - overwriteFile: true, - overwriteTags: true, - publicKey: 'publicKey', - responseFields: ['tags', 'customCoordinates', 'isPrivateFile'], - signature: 'signature', - tags: ['t-shirt', 'round-neck', 'men'], - transformation: { post: [{ type: 'thumbnail', value: 'w-150,h-150' }, { - protocol: 'dash', - type: 'abs', - value: 'sr-240_360_480_720_1080', - }], pre: 'w-300,h-300,q-80' }, - useUniqueFileName: true, - webhookUrl: 'https://example.com', - }); + file: await toFile(Buffer.from('Example data'), 'README.md'), + fileName: 'fileName', + token: 'token', + checks: '"request.folder" : "marketing/"\n', + customCoordinates: 'customCoordinates', + customMetadata: { brand: 'bar', color: 'bar' }, + description: 'Running shoes', + expire: 0, + extensions: [ + { + name: 'remove-bg', + options: { + add_shadow: true, + bg_color: 'bg_color', + bg_image_url: 'bg_image_url', + semitransparency: true, + }, + }, + { + maxTags: 5, + minConfidence: 95, + name: 'google-auto-tagging', + }, + { name: 'ai-auto-description' }, + { + name: 'ai-tasks', + tasks: [ + { + instruction: 'What types of clothing items are visible in this image?', + type: 'select_tags', + max_selections: 1, + min_selections: 0, + vocabulary: ['shirt', 'tshirt', 'dress', 'trousers', 'jacket'], + }, + { + instruction: 'Is this a luxury or high-end fashion item?', + type: 'yes_no', + on_no: { + add_tags: ['luxury', 'premium'], + remove_tags: ['budget', 'affordable'], + set_metadata: [{ field: 'price_range', value: 'premium' }], + unset_metadata: [{ field: 'price_range' }], + }, + on_unknown: { + add_tags: ['luxury', 'premium'], + remove_tags: ['budget', 'affordable'], + set_metadata: [{ field: 'price_range', value: 'premium' }], + unset_metadata: [{ field: 'price_range' }], + }, + on_yes: { + add_tags: ['luxury', 'premium'], + remove_tags: ['budget', 'affordable'], + set_metadata: [{ field: 'price_range', value: 'premium' }], + unset_metadata: [{ field: 'price_range' }], + }, + }, + ], + }, + { id: 'ext_abc123', name: 'saved-extension' }, + ], + folder: 'folder', + isPrivateFile: true, + isPublished: true, + overwriteAITags: true, + overwriteCustomMetadata: true, + overwriteFile: true, + overwriteTags: true, + publicKey: 'publicKey', + responseFields: ['tags', 'customCoordinates', 'isPrivateFile'], + signature: 'signature', + tags: ['t-shirt', 'round-neck', 'men'], + transformation: { + post: [ + { type: 'thumbnail', value: 'w-150,h-150' }, + { + protocol: 'dash', + type: 'abs', + value: 'sr-240_360_480_720_1080', + }, + ], + pre: 'w-300,h-300,q-80', + }, + useUniqueFileName: true, + webhookUrl: 'https://example.com', + }); }); }); diff --git a/tests/api-resources/files/metadata.test.ts b/tests/api-resources/files/metadata.test.ts index a4645b9b..fd318072 100644 --- a/tests/api-resources/files/metadata.test.ts +++ b/tests/api-resources/files/metadata.test.ts @@ -5,7 +5,7 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource metadata', () => { diff --git a/tests/api-resources/files/versions.test.ts b/tests/api-resources/files/versions.test.ts index 13d68039..873ec8cc 100644 --- a/tests/api-resources/files/versions.test.ts +++ b/tests/api-resources/files/versions.test.ts @@ -5,7 +5,7 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource versions', () => { diff --git a/tests/api-resources/folders/folders.test.ts b/tests/api-resources/folders/folders.test.ts index cc72c8b8..c4672ba4 100644 --- a/tests/api-resources/folders/folders.test.ts +++ b/tests/api-resources/folders/folders.test.ts @@ -5,13 +5,16 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource folders', () => { // Mock server tests are disabled test.skip('create: only required params', async () => { - const responsePromise = client.folders.create({ folderName: 'summer', parentFolderPath: '/product/images/' }); + const responsePromise = client.folders.create({ + folderName: 'summer', + parentFolderPath: '/product/images/', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,7 +26,10 @@ describe('resource folders', () => { // Mock server tests are disabled test.skip('create: required and optional params', async () => { - const response = await client.folders.create({ folderName: 'summer', parentFolderPath: '/product/images/' }); + const response = await client.folders.create({ + folderName: 'summer', + parentFolderPath: '/product/images/', + }); }); // Mock server tests are disabled @@ -45,7 +51,10 @@ describe('resource folders', () => { // Mock server tests are disabled test.skip('copy: only required params', async () => { - const responsePromise = client.folders.copy({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' }); + const responsePromise = client.folders.copy({ + destinationPath: '/path/of/destination/folder', + sourceFolderPath: '/path/of/source/folder', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -58,15 +67,18 @@ describe('resource folders', () => { // Mock server tests are disabled test.skip('copy: required and optional params', async () => { const response = await client.folders.copy({ - destinationPath: '/path/of/destination/folder', - sourceFolderPath: '/path/of/source/folder', - includeVersions: true, - }); + destinationPath: '/path/of/destination/folder', + sourceFolderPath: '/path/of/source/folder', + includeVersions: true, + }); }); // Mock server tests are disabled test.skip('move: only required params', async () => { - const responsePromise = client.folders.move({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' }); + const responsePromise = client.folders.move({ + destinationPath: '/path/of/destination/folder', + sourceFolderPath: '/path/of/source/folder', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -78,12 +90,18 @@ describe('resource folders', () => { // Mock server tests are disabled test.skip('move: required and optional params', async () => { - const response = await client.folders.move({ destinationPath: '/path/of/destination/folder', sourceFolderPath: '/path/of/source/folder' }); + const response = await client.folders.move({ + destinationPath: '/path/of/destination/folder', + sourceFolderPath: '/path/of/source/folder', + }); }); // Mock server tests are disabled test.skip('rename: only required params', async () => { - const responsePromise = client.folders.rename({ folderPath: '/path/of/folder', newFolderName: 'new-folder-name' }); + const responsePromise = client.folders.rename({ + folderPath: '/path/of/folder', + newFolderName: 'new-folder-name', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -96,9 +114,9 @@ describe('resource folders', () => { // Mock server tests are disabled test.skip('rename: required and optional params', async () => { const response = await client.folders.rename({ - folderPath: '/path/of/folder', - newFolderName: 'new-folder-name', - purgeCache: true, - }); + folderPath: '/path/of/folder', + newFolderName: 'new-folder-name', + purgeCache: true, + }); }); }); diff --git a/tests/api-resources/folders/job.test.ts b/tests/api-resources/folders/job.test.ts index b52ab727..7ab1e5ac 100644 --- a/tests/api-resources/folders/job.test.ts +++ b/tests/api-resources/folders/job.test.ts @@ -5,7 +5,7 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource job', () => { diff --git a/tests/api-resources/saved-extensions.test.ts b/tests/api-resources/saved-extensions.test.ts index 44796d45..5b4a731e 100644 --- a/tests/api-resources/saved-extensions.test.ts +++ b/tests/api-resources/saved-extensions.test.ts @@ -5,17 +5,17 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource savedExtensions', () => { // Mock server tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.savedExtensions.create({ - config: { name: 'remove-bg' }, - description: 'Analyzes vehicle images for type, condition, and quality assessment', - name: 'Car Quality Analysis', - }); + config: { name: 'remove-bg' }, + description: 'Analyzes vehicle images for type, condition, and quality assessment', + name: 'Car Quality Analysis', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -28,18 +28,18 @@ describe('resource savedExtensions', () => { // Mock server tests are disabled test.skip('create: required and optional params', async () => { const response = await client.savedExtensions.create({ - config: { - name: 'remove-bg', - options: { - add_shadow: true, - bg_color: 'bg_color', - bg_image_url: 'bg_image_url', - semitransparency: true, - }, - }, - description: 'Analyzes vehicle images for type, condition, and quality assessment', - name: 'Car Quality Analysis', - }); + config: { + name: 'remove-bg', + options: { + add_shadow: true, + bg_color: 'bg_color', + bg_image_url: 'bg_image_url', + semitransparency: true, + }, + }, + description: 'Analyzes vehicle images for type, condition, and quality assessment', + name: 'Car Quality Analysis', + }); }); // Mock server tests are disabled diff --git a/tests/api-resources/webhooks.test.ts b/tests/api-resources/webhooks.test.ts index 55002698..e5547f28 100644 --- a/tests/api-resources/webhooks.test.ts +++ b/tests/api-resources/webhooks.test.ts @@ -7,13 +7,14 @@ import ImageKit from '@imagekit/nodejs'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password', - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); describe('resource webhooks', () => { test.skip('unwrap', () => { const key = 'whsec_c2VjcmV0Cg=='; - const payload = '{"id":"id","type":"video.transformation.accepted","created_at":"2019-12-27T18:11:19.117Z","data":{"asset":{"url":"https://example.com"},"transformation":{"type":"video-transformation","options":{"audio_codec":"aac","auto_rotate":true,"format":"mp4","quality":0,"stream_protocol":"HLS","variants":["string"],"video_codec":"h264"}}},"request":{"url":"https://example.com","x_request_id":"x_request_id","user_agent":"user_agent"}}'; + const payload = + '{"id":"id","type":"video.transformation.accepted","created_at":"2019-12-27T18:11:19.117Z","data":{"asset":{"url":"https://example.com"},"transformation":{"type":"video-transformation","options":{"audio_codec":"aac","auto_rotate":true,"format":"mp4","quality":0,"stream_protocol":"HLS","variants":["string"],"video_codec":"h264"}}},"request":{"url":"https://example.com","x_request_id":"x_request_id","user_agent":"user_agent"}}'; const msgID = '1'; const timestamp = new Date(); const wh = new Webhook('whsec_c2VjcmV0Cg=='); @@ -21,38 +22,44 @@ describe('resource webhooks', () => { const headers: Record = { 'webhook-signature': signature, 'webhook-id': msgID, - 'webhook-timestamp': String(Math.floor(timestamp.getTime()/1000)), + 'webhook-timestamp': String(Math.floor(timestamp.getTime() / 1000)), }; - client.webhooks.unwrap(payload, { headers, key }) - client.withOptions({webhookSecret: key}).webhooks.unwrap(payload, { headers }) - client.withOptions({webhookSecret: 'whsec_aaaaaaaaaa=='}).webhooks.unwrap(payload, { headers, key }) + client.webhooks.unwrap(payload, { headers, key }); + client.withOptions({ webhookSecret: key }).webhooks.unwrap(payload, { headers }); + client.withOptions({ webhookSecret: 'whsec_aaaaaaaaaa==' }).webhooks.unwrap(payload, { headers, key }); expect(() => { const wrongKey = 'whsec_aaaaaaaaaa=='; - client.webhooks.unwrap(payload, { headers, key: wrongKey }) + client.webhooks.unwrap(payload, { headers, key: wrongKey }); }).toThrow('No matching signature found'); expect(() => { const wrongKey = 'whsec_aaaaaaaaaa=='; - client.withOptions({webhookSecret: wrongKey}).webhooks.unwrap(payload, { headers }) + client.withOptions({ webhookSecret: wrongKey }).webhooks.unwrap(payload, { headers }); }).toThrow('No matching signature found'); expect(() => { const badSig = wh.sign(msgID, timestamp, 'some other payload'); - client.webhooks.unwrap(payload, { headers: {...headers, 'webhook-signature': badSig }, key}) + client.webhooks.unwrap(payload, { headers: { ...headers, 'webhook-signature': badSig }, key }); }).toThrow('No matching signature found'); expect(() => { const badSig = wh.sign(msgID, timestamp, 'some other payload'); - client.withOptions({webhookSecret: key}).webhooks.unwrap(payload, { headers: {...headers, 'webhook-signature': badSig }}) + client + .withOptions({ webhookSecret: key }) + .webhooks.unwrap(payload, { headers: { ...headers, 'webhook-signature': badSig } }); }).toThrow('No matching signature found'); expect(() => { - client.webhooks.unwrap(payload, { headers: {...headers, 'webhook-timestamp': '5' }, key}) + client.webhooks.unwrap(payload, { headers: { ...headers, 'webhook-timestamp': '5' }, key }); }).toThrow('Message timestamp too old'); expect(() => { - client.withOptions({webhookSecret: key}).webhooks.unwrap(payload, { headers: {...headers, 'webhook-timestamp': '5' }}) + client + .withOptions({ webhookSecret: key }) + .webhooks.unwrap(payload, { headers: { ...headers, 'webhook-timestamp': '5' } }); }).toThrow('Message timestamp too old'); expect(() => { - client.webhooks.unwrap(payload, { headers: {...headers, 'webhook-id': 'wrong' }, key}) + client.webhooks.unwrap(payload, { headers: { ...headers, 'webhook-id': 'wrong' }, key }); }).toThrow('No matching signature found'); expect(() => { - client.withOptions({webhookSecret: key}).webhooks.unwrap(payload, { headers: {...headers, 'webhook-id': 'wrong' }}) + client + .withOptions({ webhookSecret: key }) + .webhooks.unwrap(payload, { headers: { ...headers, 'webhook-id': 'wrong' } }); }).toThrow('No matching signature found'); }); }); diff --git a/tests/index.test.ts b/tests/index.test.ts index 28d1dddf..32f31df0 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -21,11 +21,11 @@ describe('instantiate client', () => { describe('defaultHeaders', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - defaultHeaders: { 'X-My-Default-Header': '2' }, - privateKey: 'My Private Key', - password: 'My Password', -}) + baseURL: 'http://localhost:5000/', + defaultHeaders: { 'X-My-Default-Header': '2' }, + privateKey: 'My Private Key', + password: 'My Password', + }); test('they are used in the request', async () => { const { req } = await client.buildRequest({ path: '/foo', method: 'post' }); @@ -50,207 +50,209 @@ describe('instantiate client', () => { expect(req.headers.has('x-my-default-header')).toBe(false); }); }); -describe('logging', () => { - const env = process.env; + describe('logging', () => { + const env = process.env; - beforeEach(() => { - process.env = { ...env }; - process.env['IMAGE_KIT_LOG'] = undefined; - }); + beforeEach(() => { + process.env = { ...env }; + process.env['IMAGE_KIT_LOG'] = undefined; + }); - afterEach(() => { - process.env = env; - }); + afterEach(() => { + process.env = env; + }); - const forceAPIResponseForClient = async (client: ImageKit) => { - await new APIPromise( - client, - Promise.resolve({ - response: new Response(), - controller: new AbortController(), - requestLogID: 'log_000000', - retryOfRequestLogID: undefined, - startTime: Date.now(), - options: { - method: 'get', - path: '/', - }, - }), - ); - }; - - test('debug logs when log level is debug', async () => { - const debugMock = jest.fn(); - const logger = { - debug: debugMock, - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), + const forceAPIResponseForClient = async (client: ImageKit) => { + await new APIPromise( + client, + Promise.resolve({ + response: new Response(), + controller: new AbortController(), + requestLogID: 'log_000000', + retryOfRequestLogID: undefined, + startTime: Date.now(), + options: { + method: 'get', + path: '/', + }, + }), + ); }; - const client = new ImageKit({ - logger: logger, - logLevel: 'debug', - privateKey: 'My Private Key', - password: 'My Password', -}); + test('debug logs when log level is debug', async () => { + const debugMock = jest.fn(); + const logger = { + debug: debugMock, + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), + }; - await forceAPIResponseForClient(client); - expect(debugMock).toHaveBeenCalled(); - }); + const client = new ImageKit({ + logger: logger, + logLevel: 'debug', + privateKey: 'My Private Key', + password: 'My Password', + }); - test('default logLevel is warn', async () => { - const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password' }); - expect(client.logLevel).toBe('warn'); - }); + await forceAPIResponseForClient(client); + expect(debugMock).toHaveBeenCalled(); + }); - test('debug logs are skipped when log level is info', async () => { - const debugMock = jest.fn(); - const logger = { - debug: debugMock, - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - }; + test('default logLevel is warn', async () => { + const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password' }); + expect(client.logLevel).toBe('warn'); + }); - const client = new ImageKit({ - logger: logger, - logLevel: 'info', - privateKey: 'My Private Key', - password: 'My Password', -}); + test('debug logs are skipped when log level is info', async () => { + const debugMock = jest.fn(); + const logger = { + debug: debugMock, + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), + }; - await forceAPIResponseForClient(client); - expect(debugMock).not.toHaveBeenCalled(); - }); + const client = new ImageKit({ + logger: logger, + logLevel: 'info', + privateKey: 'My Private Key', + password: 'My Password', + }); - test('debug logs happen with debug env var', async () => { - const debugMock = jest.fn(); - const logger = { - debug: debugMock, - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - }; + await forceAPIResponseForClient(client); + expect(debugMock).not.toHaveBeenCalled(); + }); - process.env['IMAGE_KIT_LOG'] = 'debug'; - const client = new ImageKit({ - logger: logger, - privateKey: 'My Private Key', - password: 'My Password', -}); - expect(client.logLevel).toBe('debug'); + test('debug logs happen with debug env var', async () => { + const debugMock = jest.fn(); + const logger = { + debug: debugMock, + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), + }; - await forceAPIResponseForClient(client); - expect(debugMock).toHaveBeenCalled(); - }); + process.env['IMAGE_KIT_LOG'] = 'debug'; + const client = new ImageKit({ + logger: logger, + privateKey: 'My Private Key', + password: 'My Password', + }); + expect(client.logLevel).toBe('debug'); - test('warn when env var level is invalid', async () => { - const warnMock = jest.fn(); - const logger = { - debug: jest.fn(), - info: jest.fn(), - warn: warnMock, - error: jest.fn(), - }; + await forceAPIResponseForClient(client); + expect(debugMock).toHaveBeenCalled(); + }); - process.env['IMAGE_KIT_LOG'] = 'not a log level'; - const client = new ImageKit({ - logger: logger, - privateKey: 'My Private Key', - password: 'My Password', -}); - expect(client.logLevel).toBe('warn'); - expect(warnMock).toHaveBeenCalledWith('process.env[\'IMAGE_KIT_LOG\'] was set to "not a log level", expected one of ["off","error","warn","info","debug"]'); - }); + test('warn when env var level is invalid', async () => { + const warnMock = jest.fn(); + const logger = { + debug: jest.fn(), + info: jest.fn(), + warn: warnMock, + error: jest.fn(), + }; - test('client log level overrides env var', async () => { - const debugMock = jest.fn(); - const logger = { - debug: debugMock, - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - }; + process.env['IMAGE_KIT_LOG'] = 'not a log level'; + const client = new ImageKit({ + logger: logger, + privateKey: 'My Private Key', + password: 'My Password', + }); + expect(client.logLevel).toBe('warn'); + expect(warnMock).toHaveBeenCalledWith( + 'process.env[\'IMAGE_KIT_LOG\'] was set to "not a log level", expected one of ["off","error","warn","info","debug"]', + ); + }); - process.env['IMAGE_KIT_LOG'] = 'debug'; - const client = new ImageKit({ - logger: logger, - logLevel: 'off', - privateKey: 'My Private Key', - password: 'My Password', -}); + test('client log level overrides env var', async () => { + const debugMock = jest.fn(); + const logger = { + debug: debugMock, + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), + }; - await forceAPIResponseForClient(client); - expect(debugMock).not.toHaveBeenCalled(); - }); + process.env['IMAGE_KIT_LOG'] = 'debug'; + const client = new ImageKit({ + logger: logger, + logLevel: 'off', + privateKey: 'My Private Key', + password: 'My Password', + }); - test('no warning logged for invalid env var level + valid client level', async () => { - const warnMock = jest.fn(); - const logger = { - debug: jest.fn(), - info: jest.fn(), - warn: warnMock, - error: jest.fn(), - }; + await forceAPIResponseForClient(client); + expect(debugMock).not.toHaveBeenCalled(); + }); - process.env['IMAGE_KIT_LOG'] = 'not a log level'; - const client = new ImageKit({ - logger: logger, - logLevel: 'debug', - privateKey: 'My Private Key', - password: 'My Password', -}); - expect(client.logLevel).toBe('debug'); - expect(warnMock).not.toHaveBeenCalled(); + test('no warning logged for invalid env var level + valid client level', async () => { + const warnMock = jest.fn(); + const logger = { + debug: jest.fn(), + info: jest.fn(), + warn: warnMock, + error: jest.fn(), + }; + + process.env['IMAGE_KIT_LOG'] = 'not a log level'; + const client = new ImageKit({ + logger: logger, + logLevel: 'debug', + privateKey: 'My Private Key', + password: 'My Password', + }); + expect(client.logLevel).toBe('debug'); + expect(warnMock).not.toHaveBeenCalled(); + }); }); -}); describe('defaultQuery', () => { test('with null query params given', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - defaultQuery: { apiVersion: 'foo' }, - privateKey: 'My Private Key', - password: 'My Password', -}); + baseURL: 'http://localhost:5000/', + defaultQuery: { apiVersion: 'foo' }, + privateKey: 'My Private Key', + password: 'My Password', + }); expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/foo?apiVersion=foo'); }); test('multiple default query params', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - defaultQuery: { apiVersion: 'foo', hello: 'world' }, - privateKey: 'My Private Key', - password: 'My Password', -}); + baseURL: 'http://localhost:5000/', + defaultQuery: { apiVersion: 'foo', hello: 'world' }, + privateKey: 'My Private Key', + password: 'My Password', + }); expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/foo?apiVersion=foo&hello=world'); }); test('overriding with `undefined`', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - defaultQuery: { hello: 'world' }, - privateKey: 'My Private Key', - password: 'My Password', -}) + baseURL: 'http://localhost:5000/', + defaultQuery: { hello: 'world' }, + privateKey: 'My Private Key', + password: 'My Password', + }); expect(client.buildURL('/foo', { hello: undefined })).toEqual('http://localhost:5000/foo'); }); }); test('custom fetch', async () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - privateKey: 'My Private Key', - password: 'My Password', - fetch: (url) => { - return Promise.resolve( - new Response(JSON.stringify({ url, custom: true }), { - headers: { 'Content-Type': 'application/json' }, - }), - ); -}, -}); + baseURL: 'http://localhost:5000/', + privateKey: 'My Private Key', + password: 'My Password', + fetch: (url) => { + return Promise.resolve( + new Response(JSON.stringify({ url, custom: true }), { + headers: { 'Content-Type': 'application/json' }, + }), + ); + }, + }); const response = await client.get('/foo'); expect(response).toEqual({ url: 'http://localhost:5000/foo', custom: true }); @@ -259,39 +261,37 @@ describe('logging', () => { test('explicit global fetch', async () => { // make sure the global fetch type is assignable to our Fetch type const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - privateKey: 'My Private Key', - password: 'My Password', - fetch: defaultFetch, -}); + baseURL: 'http://localhost:5000/', + privateKey: 'My Private Key', + password: 'My Password', + fetch: defaultFetch, + }); }); test('custom signal', async () => { const client = new ImageKit({ - baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', - privateKey: 'My Private Key', - password: 'My Password', - fetch: (...args) => { - return new Promise((resolve, reject) => - setTimeout( - () => - defaultFetch(...args) - .then(resolve) - .catch(reject), - 300, - ), - ); -}, -}); + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + privateKey: 'My Private Key', + password: 'My Password', + fetch: (...args) => { + return new Promise((resolve, reject) => + setTimeout( + () => + defaultFetch(...args) + .then(resolve) + .catch(reject), + 300, + ), + ); + }, + }); const controller = new AbortController(); setTimeout(() => controller.abort(), 200); const spy = jest.spyOn(client, 'request'); - await expect(client.get('/foo', { signal: controller.signal })).rejects.toThrowError( - APIUserAbortError, - ); + await expect(client.get('/foo', { signal: controller.signal })).rejects.toThrowError(APIUserAbortError); expect(spy).toHaveBeenCalledTimes(1); }); @@ -303,11 +303,11 @@ describe('logging', () => { }; const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, -}); + baseURL: 'http://localhost:5000/', + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, + }); await client.patch('/foo'); expect(capturedRequest?.method).toEqual('PATCH'); @@ -316,19 +316,19 @@ describe('logging', () => { describe('baseUrl', () => { test('trailing slash', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/custom/path/', - privateKey: 'My Private Key', - password: 'My Password', -}); + baseURL: 'http://localhost:5000/custom/path/', + privateKey: 'My Private Key', + password: 'My Password', + }); expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/custom/path/foo'); }); test('no trailing slash', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/custom/path', - privateKey: 'My Private Key', - password: 'My Password', -}); + baseURL: 'http://localhost:5000/custom/path', + privateKey: 'My Private Key', + password: 'My Password', + }); expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/custom/path/foo'); }); @@ -338,10 +338,10 @@ describe('logging', () => { test('explicit option', () => { const client = new ImageKit({ - baseURL: 'https://example.com', - privateKey: 'My Private Key', - password: 'My Password', -}); + baseURL: 'https://example.com', + privateKey: 'My Private Key', + password: 'My Password', + }); expect(client.baseURL).toEqual('https://example.com'); }); @@ -354,42 +354,48 @@ describe('logging', () => { test('empty env variable', () => { process.env['IMAGE_KIT_BASE_URL'] = ''; // empty const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password' }); - expect(client.baseURL).toEqual('https://api.imagekit.io') + expect(client.baseURL).toEqual('https://api.imagekit.io'); }); test('blank env variable', () => { process.env['IMAGE_KIT_BASE_URL'] = ' '; // blank const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password' }); - expect(client.baseURL).toEqual('https://api.imagekit.io') + expect(client.baseURL).toEqual('https://api.imagekit.io'); }); test('in request options', () => { const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password' }); - expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual('http://localhost:5000/option/foo'); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( + 'http://localhost:5000/option/foo', + ); }); test('in request options overridden by client options', () => { const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - baseURL: 'http://localhost:5000/client', - }); - expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual('http://localhost:5000/client/foo'); + privateKey: 'My Private Key', + password: 'My Password', + baseURL: 'http://localhost:5000/client', + }); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( + 'http://localhost:5000/client/foo', + ); }); test('in request options overridden by env variable', () => { process.env['IMAGE_KIT_BASE_URL'] = 'http://localhost:5000/env'; const client = new ImageKit({ privateKey: 'My Private Key', password: 'My Password' }); - expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual('http://localhost:5000/env/foo'); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( + 'http://localhost:5000/env/foo', + ); }); }); test('maxRetries option is correctly set', () => { const client = new ImageKit({ - maxRetries: 4, - privateKey: 'My Private Key', - password: 'My Password', -}); + maxRetries: 4, + privateKey: 'My Private Key', + password: 'My Password', + }); expect(client.maxRetries).toEqual(4); // default @@ -400,11 +406,11 @@ describe('logging', () => { describe('withOptions', () => { test('creates a new client with overridden options', async () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - maxRetries: 3, - privateKey: 'My Private Key', - password: 'My Password', - }); + baseURL: 'http://localhost:5000/', + maxRetries: 3, + privateKey: 'My Private Key', + password: 'My Password', + }); const newClient = client.withOptions({ maxRetries: 5, @@ -426,12 +432,12 @@ describe('logging', () => { test('inherits options from the parent client', async () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - defaultHeaders: { 'X-Test-Header': 'test-value' }, - defaultQuery: { 'test-param': 'test-value' }, - privateKey: 'My Private Key', - password: 'My Password', - }); + baseURL: 'http://localhost:5000/', + defaultHeaders: { 'X-Test-Header': 'test-value' }, + defaultQuery: { 'test-param': 'test-value' }, + privateKey: 'My Private Key', + password: 'My Password', + }); const newClient = client.withOptions({ baseURL: 'http://localhost:5001/', @@ -446,11 +452,11 @@ describe('logging', () => { test('respects runtime property changes when creating new client', () => { const client = new ImageKit({ - baseURL: 'http://localhost:5000/', - timeout: 1000, - privateKey: 'My Private Key', - password: 'My Password', - }); + baseURL: 'http://localhost:5000/', + timeout: 1000, + privateKey: 'My Private Key', + password: 'My Password', + }); // Modify the client properties directly after creation client.baseURL = 'http://localhost:6000/'; @@ -500,13 +506,18 @@ describe('request building', () => { describe('custom headers', () => { test('handles undefined', async () => { - const { req } = await client.buildRequest({ path: '/foo', method: 'post', body: { value: 'hello' }, headers: { 'X-Foo': 'baz', 'x-foo': 'bar', 'x-Foo': undefined, 'x-baz': 'bam', 'X-Baz': null } }); + const { req } = await client.buildRequest({ + path: '/foo', + method: 'post', + body: { value: 'hello' }, + headers: { 'X-Foo': 'baz', 'x-foo': 'bar', 'x-Foo': undefined, 'x-baz': 'bam', 'X-Baz': null }, + }); expect(req.headers.get('x-foo')).toEqual('bar'); expect(req.headers.get('x-Foo')).toEqual('bar'); expect(req.headers.get('X-Foo')).toEqual('bar'); expect(req.headers.get('x-baz')).toEqual(null); }); - }) + }); }); describe('default encoder', () => { @@ -583,38 +594,41 @@ describe('default encoder', () => { describe('retries', () => { test('retry on timeout', async () => { let count = 0; - const testFetch = async (url: string | URL | Request, { signal }: RequestInit = {}): Promise => { - if (count++ === 0) { - return new Promise((resolve, reject) => - signal?.addEventListener('abort', () => reject(new Error('timed out'))), - ); - } - return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); - }; - - const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - timeout: 10, - fetch: testFetch, - }); + const testFetch = async ( + url: string | URL | Request, + { signal }: RequestInit = {}, + ): Promise => { + if (count++ === 0) { + return new Promise( + (resolve, reject) => signal?.addEventListener('abort', () => reject(new Error('timed out'))), + ); + } + return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); + }; - expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); - expect(count).toEqual(2); - expect( - await client - .request({ path: '/foo', method: 'get' }) - .asResponse() - .then((r) => r.text()), - ).toEqual(JSON.stringify({ a: 1 })); - expect(count).toEqual(3); + const client = new ImageKit({ + privateKey: 'My Private Key', + password: 'My Password', + timeout: 10, + fetch: testFetch, }); + expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); + expect(count).toEqual(2); + expect( + await client + .request({ path: '/foo', method: 'get' }) + .asResponse() + .then((r) => r.text()), + ).toEqual(JSON.stringify({ a: 1 })); + expect(count).toEqual(3); + }); + test('retry count header', async () => { let count = 0; let capturedRequest: RequestInit | undefined; const testFetch = async (url: string | URL | Request, init: RequestInit = {}): Promise => { - count++ + count++; if (count <= 2) { return new Response(undefined, { status: 429, @@ -628,11 +642,11 @@ describe('retries', () => { }; const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, - maxRetries: 4, - }); + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, + maxRetries: 4, + }); expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); @@ -644,7 +658,7 @@ describe('retries', () => { let count = 0; let capturedRequest: RequestInit | undefined; const testFetch = async (url: string | URL | Request, init: RequestInit = {}): Promise => { - count++ + count++; if (count <= 2) { return new Response(undefined, { status: 429, @@ -657,11 +671,11 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, - maxRetries: 4, - }); + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, + maxRetries: 4, + }); expect( await client.request({ @@ -678,7 +692,7 @@ describe('retries', () => { let count = 0; let capturedRequest: RequestInit | undefined; const testFetch = async (url: string | URL | Request, init: RequestInit = {}): Promise => { - count++ + count++; if (count <= 2) { return new Response(undefined, { status: 429, @@ -691,12 +705,12 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, - maxRetries: 4, - defaultHeaders: { 'X-Stainless-Retry-Count': null }, - }); + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, + maxRetries: 4, + defaultHeaders: { 'X-Stainless-Retry-Count': null }, + }); expect( await client.request({ @@ -712,7 +726,7 @@ describe('retries', () => { let count = 0; let capturedRequest: RequestInit | undefined; const testFetch = async (url: string | URL | Request, init: RequestInit = {}): Promise => { - count++ + count++; if (count <= 2) { return new Response(undefined, { status: 429, @@ -725,11 +739,11 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, - maxRetries: 4, - }); + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, + maxRetries: 4, + }); expect( await client.request({ @@ -744,7 +758,10 @@ describe('retries', () => { test('retry on 429 with retry-after', async () => { let count = 0; - const testFetch = async (url: string | URL | Request, { signal }: RequestInit = {}): Promise => { + const testFetch = async ( + url: string | URL | Request, + { signal }: RequestInit = {}, + ): Promise => { if (count++ === 0) { return new Response(undefined, { status: 429, @@ -757,10 +774,10 @@ describe('retries', () => { }; const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, - }); + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, + }); expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); expect(count).toEqual(2); @@ -775,7 +792,10 @@ describe('retries', () => { test('retry on 429 with retry-after-ms', async () => { let count = 0; - const testFetch = async (url: string | URL | Request, { signal }: RequestInit = {}): Promise => { + const testFetch = async ( + url: string | URL | Request, + { signal }: RequestInit = {}, + ): Promise => { if (count++ === 0) { return new Response(undefined, { status: 429, @@ -788,10 +808,10 @@ describe('retries', () => { }; const client = new ImageKit({ - privateKey: 'My Private Key', - password: 'My Password', - fetch: testFetch, - }); + privateKey: 'My Private Key', + password: 'My Password', + fetch: testFetch, + }); expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); expect(count).toEqual(2); diff --git a/tests/stringifyQuery.test.ts b/tests/stringifyQuery.test.ts index 4bef7207..4fa1d747 100644 --- a/tests/stringifyQuery.test.ts +++ b/tests/stringifyQuery.test.ts @@ -2,24 +2,26 @@ import { stringifyQuery } from '@imagekit/nodejs/internal/utils/query'; -describe(stringifyQuery, () => { for (const [input, expected] of [ - [{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'], - [{ a: null, b: false, c: undefined }, 'a=&b=false'], - [{ 'a/b': 1.28341 }, `${encodeURIComponent('a/b')}=1.28341`], - [ - { 'a/b': 'c/d', 'e=f': 'g&h' }, - `${encodeURIComponent('a/b')}=${encodeURIComponent('c/d')}&${encodeURIComponent( - 'e=f', - )}=${encodeURIComponent('g&h')}`, - ], -] as const) { - it(`${JSON.stringify(input)} -> ${expected}`, () => { - expect(stringifyQuery(input)).toEqual(expected); - }); -} +describe(stringifyQuery, () => { + for (const [input, expected] of [ + [{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'], + [{ a: null, b: false, c: undefined }, 'a=&b=false'], + [{ 'a/b': 1.28341 }, `${encodeURIComponent('a/b')}=1.28341`], + [ + { 'a/b': 'c/d', 'e=f': 'g&h' }, + `${encodeURIComponent('a/b')}=${encodeURIComponent('c/d')}&${encodeURIComponent( + 'e=f', + )}=${encodeURIComponent('g&h')}`, + ], + ] as const) { + it(`${JSON.stringify(input)} -> ${expected}`, () => { + expect(stringifyQuery(input)).toEqual(expected); + }); + } -for (const value of [[], {}, new Date()]) { - it(`${JSON.stringify(value)} -> `, () => { - expect(() => stringifyQuery({ value })).toThrow(`Cannot stringify type ${typeof value}`); - }); -} }) + for (const value of [[], {}, new Date()]) { + it(`${JSON.stringify(value)} -> `, () => { + expect(() => stringifyQuery({ value })).toThrow(`Cannot stringify type ${typeof value}`); + }); + } +}); diff --git a/yarn.lock b/yarn.lock index 9a878fe6..a41ae84e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -709,6 +709,11 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@pkgr/core@^0.2.4": + version "0.2.4" + resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.2.4.tgz#d897170a2b0ba51f78a099edccd968f7b103387c" + integrity sha512-ROFF39F6ZrnzSUEmQQZUar0Jt4xVoP9WnDRdWwF4NNcXs3xBTLgBUDoOwW141y1jP+S8nahIbdxbFC7IShw9Iw== + "@sinclair/typebox@^0.27.8": version "0.27.8" resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" @@ -1515,6 +1520,14 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== +eslint-plugin-prettier@^5.4.1: + version "5.4.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.4.1.tgz#99b55d7dd70047886b2222fdd853665f180b36af" + integrity sha512-9dF+KuU/Ilkq27A8idRP7N2DH8iUR6qXcjF3FR2wETY21PZdBrIjwCau8oboyGj9b7etWmTGEeM8e7oOed6ZWg== + dependencies: + prettier-linter-helpers "^1.0.0" + synckit "^0.11.7" + eslint-plugin-unused-imports@^4.1.4: version "4.1.4" resolved "https://registry.yarnpkg.com/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-4.1.4.tgz#62ddc7446ccbf9aa7b6f1f0b00a980423cda2738" @@ -1666,6 +1679,11 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== +fast-diff@^1.1.2: + version "1.3.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0" + integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw== + fast-glob@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" @@ -2833,6 +2851,13 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + prettier@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.1.tgz#6ba9f23165d690b6cbdaa88cb0807278f7019848" @@ -3137,6 +3162,13 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== +synckit@^0.11.7: + version "0.11.8" + resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.11.8.tgz#b2aaae998a4ef47ded60773ad06e7cb821f55457" + integrity sha512-+XZ+r1XGIJGeQk3VvXhT6xx/VpbHsRzsTkGgF6E5RX9TTXD0118l87puaEBZ566FhqblC6U0d4XnubznJDm30A== + dependencies: + "@pkgr/core" "^0.2.4" + test-exclude@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e" From 79b7da8857f2f0e32de93d15b613721d69c59a5d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 Apr 2026 22:28:45 +0000 Subject: [PATCH 19/36] feat: support setting headers via env --- src/client.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/client.ts b/src/client.ts index 77700f16..b3e24eb4 100644 --- a/src/client.ts +++ b/src/client.ts @@ -260,6 +260,18 @@ export class ImageKit { this.fetch = options.fetch ?? Shims.getDefaultFetch(); this.#encoder = Opts.FallbackEncoder; + const customHeadersEnv = readEnv('IMAGE_KIT_CUSTOM_HEADERS'); + if (customHeadersEnv) { + const parsed: Record = {}; + for (const line of customHeadersEnv.split('\n')) { + const colon = line.indexOf(':'); + if (colon >= 0) { + parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim(); + } + } + options.defaultHeaders = { ...parsed, ...options.defaultHeaders }; + } + this._options = options; this.privateKey = privateKey; From 48e7a85f9464d937a11967ed6255c1249ecd683b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 Apr 2026 17:23:19 +0000 Subject: [PATCH 20/36] chore(internal): codegen related update --- packages/mcp-server/src/local-docs-search.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 828a0523..f5ac7389 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -2537,12 +2537,12 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().origins().create', example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginCreateParams;\nimport io.imagekit.models.accounts.origins.OriginRequest;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.origins.OriginRequest;\nimport io.imagekit.models.accounts.origins.OriginResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n OriginRequest.S3 params = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build();\n OriginResponse originResponse = client.accounts().origins().create(params);\n }\n}', }, kotlin: { method: 'accounts().origins().create', example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginCreateParams\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginRequest.S3 = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build()\n val originResponse: OriginResponse = client.accounts().origins().create(params)\n}', + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.origins.OriginRequest\nimport com.imagekit.api.models.accounts.origins.OriginResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: OriginRequest.S3 = OriginRequest.S3.builder()\n .accessKey("AKIATEST123")\n .bucket("test-bucket")\n .name("My S3 Origin")\n .secretKey("secrettest123")\n .build()\n val originResponse: OriginResponse = client.accounts().origins().create(params)\n}', }, go: { method: 'client.Accounts.Origins.New', @@ -2867,12 +2867,12 @@ const EMBEDDED_METHODS: MethodEntry[] = [ java: { method: 'accounts().urlEndpoints().create', example: - 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointCreateParams;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}', + 'package io.imagekit.example;\n\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest;\nimport io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n ImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\n UrlEndpointRequest params = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build();\n UrlEndpointResponse urlEndpointResponse = client.accounts().urlEndpoints().create(params);\n }\n}', }, kotlin: { method: 'accounts().urlEndpoints().create', example: - 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointRequest = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().create(params)\n}', + 'package com.imagekit.api.example\n\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest\nimport com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse\n\nfun main() {\n val client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\n val params: UrlEndpointRequest = UrlEndpointRequest.builder()\n .description("My custom URL endpoint")\n .build()\n val urlEndpointResponse: UrlEndpointResponse = client.accounts().urlEndpoints().create(params)\n}', }, go: { method: 'client.Accounts.URLEndpoints.New', From c75392491c141b2fc635481b75007bfb47101741 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 Apr 2026 19:49:13 +0000 Subject: [PATCH 21/36] chore(format): run eslint and prettier separately --- .github/workflows/release-doctor.yml | 1 - .prettierignore | 1 + eslint.config.mjs | 3 - package.json | 1 - .../worker-configuration.d.ts | 4 +- .../cloudflare-worker/wrangler.jsonc | 58 +++++++++---------- scripts/fast-format | 9 +-- scripts/format | 3 +- scripts/lint | 3 + src/internal/types.ts | 14 ++--- yarn.lock | 32 ---------- 11 files changed, 45 insertions(+), 84 deletions(-) diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index fa2649a4..c9c6325c 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -19,4 +19,3 @@ jobs: bash ./bin/check-release-environment env: NPM_TOKEN: ${{ secrets.IMAGE_KIT_NPM_TOKEN || secrets.NPM_TOKEN }} - diff --git a/.prettierignore b/.prettierignore index 7cc13dd1..6e7fb359 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,6 +2,7 @@ CHANGELOG.md /ecosystem-tests/*/** /node_modules /deno +/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts # don't format tsc output, will break source maps dist diff --git a/eslint.config.mjs b/eslint.config.mjs index c1a01a62..42741bdb 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,7 +1,6 @@ // @ts-check import tseslint from 'typescript-eslint'; import unusedImports from 'eslint-plugin-unused-imports'; -import prettier from 'eslint-plugin-prettier'; export default tseslint.config( { @@ -14,11 +13,9 @@ export default tseslint.config( plugins: { '@typescript-eslint': tseslint.plugin, 'unused-imports': unusedImports, - prettier, }, rules: { 'no-unused-vars': 'off', - 'prettier/prettier': 'error', 'unused-imports/no-unused-imports': 'error', 'no-restricted-imports': [ 'error', diff --git a/package.json b/package.json index 10029643..b1c22e58 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "@typescript-eslint/eslint-plugin": "8.31.1", "@typescript-eslint/parser": "8.31.1", "eslint": "^9.39.1", - "eslint-plugin-prettier": "^5.4.1", "eslint-plugin-unused-imports": "^4.1.4", "iconv-lite": "^0.6.3", "jest": "^29.4.0", diff --git a/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts b/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts index 432fe3e0..32da9a90 100644 --- a/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts +++ b/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts @@ -1,4 +1,4 @@ -/* eslint-disable */ + // Generated by Wrangler by running `wrangler types` (hash: fc286f4a60f8eb63b1e0d82ea1f34233) // Runtime types generated with workerd@1.20260124.0 2025-03-10 nodejs_compat declare namespace Cloudflare { @@ -29,7 +29,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -/* eslint-disable */ + // noinspection JSUnusedGlobalSymbols declare var onmessage: never; /** diff --git a/packages/mcp-server/cloudflare-worker/wrangler.jsonc b/packages/mcp-server/cloudflare-worker/wrangler.jsonc index 8d53ba81..a49004af 100644 --- a/packages/mcp-server/cloudflare-worker/wrangler.jsonc +++ b/packages/mcp-server/cloudflare-worker/wrangler.jsonc @@ -3,33 +3,33 @@ * https://developers.cloudflare.com/workers/wrangler/configuration/ */ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "imagekit-nodejs-api-mcp-server", - "main": "src/index.ts", - "compatibility_date": "2025-03-10", - "compatibility_flags": ["nodejs_compat"], - "migrations": [ - { - "new_sqlite_classes": ["MyMCP"], - "tag": "v1" - } - ], - "durable_objects": { - "bindings": [ - { - "class_name": "MyMCP", - "name": "MCP_OBJECT" - } - ] - }, - "kv_namespaces": [ - { - "binding": "OAUTH_KV", - "id": "ae6fe7d7993146a9b8d54d87f73b0bdf" - } - ], - "observability": { - "enabled": true - }, - "assets": { "directory": "./static/", "binding": "ASSETS" } + "$schema": "node_modules/wrangler/config-schema.json", + "name": "imagekit-nodejs-api-mcp-server", + "main": "src/index.ts", + "compatibility_date": "2025-03-10", + "compatibility_flags": ["nodejs_compat"], + "migrations": [ + { + "new_sqlite_classes": ["MyMCP"], + "tag": "v1" + } + ], + "durable_objects": { + "bindings": [ + { + "class_name": "MyMCP", + "name": "MCP_OBJECT" + } + ] + }, + "kv_namespaces": [ + { + "binding": "OAUTH_KV", + "id": "ae6fe7d7993146a9b8d54d87f73b0bdf" + } + ], + "observability": { + "enabled": true + }, + "assets": { "directory": "./static/", "binding": "ASSETS" } } diff --git a/scripts/fast-format b/scripts/fast-format index 53721ac0..f1873aef 100755 --- a/scripts/fast-format +++ b/scripts/fast-format @@ -31,10 +31,7 @@ if ! [ -z "$ESLINT_FILES" ]; then fi echo "==> Running prettier --write" -# format things eslint didn't -PRETTIER_FILES="$(grep '\.\(js\|json\)$' "$FILE_LIST" || true)" -if ! [ -z "$PRETTIER_FILES" ]; then - echo "$PRETTIER_FILES" | xargs ./node_modules/.bin/prettier \ - --write --cache --cache-strategy metadata --no-error-on-unmatched-pattern \ - '!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs' +if ! [ -z "$FILE_LIST" ]; then + cat "$FILE_LIST" | xargs ./node_modules/.bin/prettier \ + --write --cache --cache-strategy metadata --no-error-on-unmatched-pattern --ignore-unknown fi diff --git a/scripts/format b/scripts/format index 7a756401..b1b2c17a 100755 --- a/scripts/format +++ b/scripts/format @@ -8,5 +8,4 @@ echo "==> Running eslint --fix" ./node_modules/.bin/eslint --fix . echo "==> Running prettier --write" -# format things eslint didn't -./node_modules/.bin/prettier --write --cache --cache-strategy metadata . '!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs' +./node_modules/.bin/prettier --write --cache --cache-strategy metadata . diff --git a/scripts/lint b/scripts/lint index 3ffb78a6..1f532548 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,6 +4,9 @@ set -e cd "$(dirname "$0")/.." +echo "==> Running prettier --check" +./node_modules/.bin/prettier --check . + echo "==> Running eslint" ./node_modules/.bin/eslint . diff --git a/src/internal/types.ts b/src/internal/types.ts index b668dfc0..a050513a 100644 --- a/src/internal/types.ts +++ b/src/internal/types.ts @@ -40,7 +40,6 @@ type OverloadedParameters = : T extends (...args: infer A) => unknown ? A : never; -/* eslint-disable */ /** * These imports attempt to get types from a parent package's dependencies. * Unresolved bare specifiers can trigger [automatic type acquisition][1] in some projects, which @@ -63,19 +62,18 @@ type OverloadedParameters = * * [1]: https://www.typescriptlang.org/tsconfig/#typeAcquisition */ -/** @ts-ignore For users with \@types/node */ +/** @ts-ignore For users with \@types/node */ /* prettier-ignore */ type UndiciTypesRequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users with undici */ +/** @ts-ignore For users with undici */ /* prettier-ignore */ type UndiciRequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users with \@types/bun */ +/** @ts-ignore For users with \@types/bun */ /* prettier-ignore */ type BunRequestInit = globalThis.FetchRequestInit; -/** @ts-ignore For users with node-fetch@2 */ +/** @ts-ignore For users with node-fetch@2 */ /* prettier-ignore */ type NodeFetch2RequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */ +/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */ /* prettier-ignore */ type NodeFetch3RequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users who use Deno */ +/** @ts-ignore For users who use Deno */ /* prettier-ignore */ type FetchRequestInit = NonNullable[1]>; -/* eslint-enable */ type RequestInits = | NotAny diff --git a/yarn.lock b/yarn.lock index a41ae84e..9a878fe6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -709,11 +709,6 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@pkgr/core@^0.2.4": - version "0.2.4" - resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.2.4.tgz#d897170a2b0ba51f78a099edccd968f7b103387c" - integrity sha512-ROFF39F6ZrnzSUEmQQZUar0Jt4xVoP9WnDRdWwF4NNcXs3xBTLgBUDoOwW141y1jP+S8nahIbdxbFC7IShw9Iw== - "@sinclair/typebox@^0.27.8": version "0.27.8" resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" @@ -1520,14 +1515,6 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -eslint-plugin-prettier@^5.4.1: - version "5.4.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.4.1.tgz#99b55d7dd70047886b2222fdd853665f180b36af" - integrity sha512-9dF+KuU/Ilkq27A8idRP7N2DH8iUR6qXcjF3FR2wETY21PZdBrIjwCau8oboyGj9b7etWmTGEeM8e7oOed6ZWg== - dependencies: - prettier-linter-helpers "^1.0.0" - synckit "^0.11.7" - eslint-plugin-unused-imports@^4.1.4: version "4.1.4" resolved "https://registry.yarnpkg.com/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-4.1.4.tgz#62ddc7446ccbf9aa7b6f1f0b00a980423cda2738" @@ -1679,11 +1666,6 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-diff@^1.1.2: - version "1.3.0" - resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0" - integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw== - fast-glob@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" @@ -2851,13 +2833,6 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -prettier-linter-helpers@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" - integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== - dependencies: - fast-diff "^1.1.2" - prettier@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.1.tgz#6ba9f23165d690b6cbdaa88cb0807278f7019848" @@ -3162,13 +3137,6 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== -synckit@^0.11.7: - version "0.11.8" - resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.11.8.tgz#b2aaae998a4ef47ded60773ad06e7cb821f55457" - integrity sha512-+XZ+r1XGIJGeQk3VvXhT6xx/VpbHsRzsTkGgF6E5RX9TTXD0118l87puaEBZ566FhqblC6U0d4XnubznJDm30A== - dependencies: - "@pkgr/core" "^0.2.4" - test-exclude@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e" From 8bdfaaec37bdf7c465880d999cee790d852efc1f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 Apr 2026 18:03:55 +0000 Subject: [PATCH 22/36] chore: avoid formatting file that gets changed during releases --- .prettierignore | 1 + packages/mcp-server/manifest.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.prettierignore b/.prettierignore index 6e7fb359..38575931 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,6 +2,7 @@ CHANGELOG.md /ecosystem-tests/*/** /node_modules /deno +/packages/mcp-server/manifest.json /packages/mcp-server/cloudflare-worker/worker-configuration.d.ts # don't format tsc output, will break source maps diff --git a/packages/mcp-server/manifest.json b/packages/mcp-server/manifest.json index c9dbefa4..7627b523 100644 --- a/packages/mcp-server/manifest.json +++ b/packages/mcp-server/manifest.json @@ -43,7 +43,7 @@ }, "IMAGEKIT_WEBHOOK_SECRET": { "title": "webhook_secret", - "description": "Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n", + "description": "Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you\'re using webhooks.\n", "required": false, "type": "string" } From afd7d69196c9a493c92923c44f3e4718238b7e9b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 Apr 2026 18:15:44 +0000 Subject: [PATCH 23/36] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a1b609ac..92b16878 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 config_hash: 94f48fd13b7d41b8b6a203a3a8cee9ed From d03a56215e05206f1b59fac13c0757da202157c1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 16:22:25 +0000 Subject: [PATCH 24/36] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 92b16878..6b776b6f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-362d0336e8f52ab1beb7d9602a3665dbb0277700e8dc01ef4f96fc7651699349.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 config_hash: 94f48fd13b7d41b8b6a203a3a8cee9ed From d7fcbd65da4658fd1d55f97d20997cfca03ee64c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 21:26:06 +0000 Subject: [PATCH 25/36] chore(internal): fix MCP cloudflare worker builds --- .../mcp-server/cloudflare-worker/package.json | 18 +++++++++++++++--- .../mcp-server/cloudflare-worker/src/index.ts | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/packages/mcp-server/cloudflare-worker/package.json b/packages/mcp-server/cloudflare-worker/package.json index 84c0823b..6a9a5397 100644 --- a/packages/mcp-server/cloudflare-worker/package.json +++ b/packages/mcp-server/cloudflare-worker/package.json @@ -18,10 +18,22 @@ }, "dependencies": { "@cloudflare/workers-oauth-provider": "^0.0.5", - "@modelcontextprotocol/sdk": "^1.27.1", - "agents": "^0.8.5", + "@modelcontextprotocol/sdk": "1.28.0", + "agents": "~0.8.7", "hono": "^4.12.4", "@imagekit/api-mcp": "latest", - "zod": "^3.24.4" + "@imagekit/nodejs": "latest" + }, + "// overrides": "agents pins @modelcontextprotocol/sdk exactly; the three override blocks below force npm/yarn/pnpm to dedupe to that same version. Keep all four @modelcontextprotocol/sdk values in sync. See src/index.ts for the full rationale.", + "overrides": { + "@modelcontextprotocol/sdk": "1.28.0" + }, + "resolutions": { + "@modelcontextprotocol/sdk": "1.28.0" + }, + "pnpm": { + "overrides": { + "@modelcontextprotocol/sdk": "1.28.0" + } } } diff --git a/packages/mcp-server/cloudflare-worker/src/index.ts b/packages/mcp-server/cloudflare-worker/src/index.ts index 18cc7802..a0433c9c 100644 --- a/packages/mcp-server/cloudflare-worker/src/index.ts +++ b/packages/mcp-server/cloudflare-worker/src/index.ts @@ -1,7 +1,15 @@ import { makeOAuthConsent } from './app'; +// `agents` and `@modelcontextprotocol/sdk` versions must stay in sync with the +// pins/overrides in package.json. `agents` declares an exact pin on +// `@modelcontextprotocol/sdk`; if our resolved version drifts, npm installs a +// second copy under `agents/node_modules/`, and `initMcpServer`'s runtime +// `instanceof McpServer` check fails because the two `McpServer` classes are +// distinct constructors. import { McpAgent } from 'agents/mcp'; import OAuthProvider from '@cloudflare/workers-oauth-provider'; -import { McpOptions, initMcpServer, server, ClientOptions } from '@imagekit/api-mcp/server'; +import { ClientOptions } from '@imagekit/nodejs'; +import { McpOptions } from '@imagekit/api-mcp/options'; +import { initMcpServer, newMcpServer } from '@imagekit/api-mcp/server'; import type { ExportedHandler } from '@cloudflare/workers-types'; type MCPProps = { @@ -51,11 +59,15 @@ const serverConfig: ServerConfig = { }; export class MyMCP extends McpAgent { - server = server; + server = newMcpServer({}); async init() { + if (this.props == null) { + throw new Error('MCP props are not initialized'); + } + initMcpServer({ - server: this.server, + server: await this.server, clientOptions: this.props.clientProps, mcpOptions: this.props.clientConfig, }); From 1c4774d5845ecc0839de1b259cc6e291ce5e543a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 4 May 2026 15:19:57 +0000 Subject: [PATCH 26/36] docs: clarify forwards compat behavior --- packages/mcp-server/src/local-docs-search.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index f5ac7389..b6aeb0c6 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -3318,12 +3318,12 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'java', content: - '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.client.ImageKitClientAsync;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.MultipartField;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.core.http.Headers;\nimport io.imagekit.core.http.HttpResponseFor;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.JsonMissing;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.client.ImageKitClientAsync;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.MultipartField;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.core.http.Headers;\nimport io.imagekit.core.http.HttpResponseFor;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.JsonMissing;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nValidating the response is _not_ forwards compatible with new types from the API for existing fields.\n\nIf you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', }, { language: 'kotlin', content: - '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\nThe Image Kit Kotlin SDK is similar to the Image Kit Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nIf you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\nThe Image Kit Kotlin SDK is similar to the Image Kit Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nValidating the response is _not_ forwards compatible with new types from the API for existing fields.\n\nIf you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', }, { language: 'php', From c7668e7e446fcd2d5de84e76d4f14505d0314895 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 18:45:06 +0000 Subject: [PATCH 27/36] docs: update with proxy auth info --- packages/mcp-server/src/local-docs-search.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index b6aeb0c6..2b9d94e8 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -3318,12 +3318,12 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'java', content: - '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.client.ImageKitClientAsync;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.MultipartField;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.core.http.Headers;\nimport io.imagekit.core.http.HttpResponseFor;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.JsonMissing;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nValidating the response is _not_ forwards compatible with new types from the API for existing fields.\n\nIf you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.client.ImageKitClientAsync;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.MultipartField;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.core.http.Headers;\nimport io.imagekit.core.http.HttpResponseFor;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\nIf the proxy responds with `407 Proxy Authentication Required`, supply credentials by also configuring `proxyAuthenticator`:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.core.http.ProxyAuthenticator;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(...)\n // Or a custom implementation of `ProxyAuthenticator`.\n .proxyAuthenticator(ProxyAuthenticator.basic("username", "password"))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.JsonMissing;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nValidating the response is _not_ forwards compatible with new types from the API for existing fields.\n\nIf you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', }, { language: 'kotlin', content: - '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\nThe Image Kit Kotlin SDK is similar to the Image Kit Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nValidating the response is _not_ forwards compatible with new types from the API for existing fields.\n\nIf you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\nThe Image Kit Kotlin SDK is similar to the Image Kit Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\nIf the proxy responds with `407 Proxy Authentication Required`, supply credentials by also configuring `proxyAuthenticator`:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.core.http.ProxyAuthenticator\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(...)\n // Or a custom implementation of `ProxyAuthenticator`.\n .proxyAuthenticator(ProxyAuthenticator.basic("username", "password"))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nValidating the response is _not_ forwards compatible with new types from the API for existing fields.\n\nIf you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', }, { language: 'php', From d93bb2d88e29d44460cc453fcf21fb9dc28c8fdc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 21:22:44 +0000 Subject: [PATCH 28/36] chore(internal): fix MCP cloudflare worker initialization --- .../mcp-server/cloudflare-worker/src/index.ts | 75 ++++++++++++++++--- 1 file changed, 66 insertions(+), 9 deletions(-) diff --git a/packages/mcp-server/cloudflare-worker/src/index.ts b/packages/mcp-server/cloudflare-worker/src/index.ts index a0433c9c..bc239058 100644 --- a/packages/mcp-server/cloudflare-worker/src/index.ts +++ b/packages/mcp-server/cloudflare-worker/src/index.ts @@ -6,10 +6,12 @@ import { makeOAuthConsent } from './app'; // `instanceof McpServer` check fails because the two `McpServer` classes are // distinct constructors. import { McpAgent } from 'agents/mcp'; +import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import OAuthProvider from '@cloudflare/workers-oauth-provider'; import { ClientOptions } from '@imagekit/nodejs'; import { McpOptions } from '@imagekit/api-mcp/options'; import { initMcpServer, newMcpServer } from '@imagekit/api-mcp/server'; +import { configureLogger } from '@imagekit/api-mcp/logger'; import type { ExportedHandler } from '@cloudflare/workers-types'; type MCPProps = { @@ -58,19 +60,74 @@ const serverConfig: ServerConfig = { ], }; +// `newMcpServer` fetches MCP server instructions from the Stainless API. In a +// Durable Object, that fetch happens inside `blockConcurrencyWhile`; if it +// hangs the DO is reset, and if it rejects the same thing happens. Race +// against a short timeout and catch any rejection so any failure mode lands +// on a fallback server constructed without instructions (the `initialize` +// response simply omits the `instructions` field, which is spec-allowed). +const INSTRUCTIONS_FETCH_TIMEOUT_MS = 5000; + +function fallbackMcpServer(): McpServer { + return new McpServer( + { name: 'imagekit_nodejs_api', version: '7.5.0' }, + { capabilities: { tools: {}, logging: {} } }, + ); +} + +async function buildMcpServer(stainlessApiKey?: string): Promise { + let timeoutId: ReturnType | undefined; + try { + const fetched = newMcpServer({ stainlessApiKey }); + const timeout = new Promise((resolve) => { + timeoutId = setTimeout(() => resolve(null), INSTRUCTIONS_FETCH_TIMEOUT_MS); + }); + + const result = await Promise.race([fetched, timeout]); + + if (result != null) { + return result; + } + } catch (error) { + console.error('Failed to build MCP server from upstream instructions; using fallback', error); + } finally { + if (timeoutId != null) { + clearTimeout(timeoutId); + } + } + + return fallbackMcpServer(); +} + export class MyMCP extends McpAgent { - server = newMcpServer({}); + #resolveServer!: (server: McpServer) => void; + #rejectServer!: (error: unknown) => void; + server: Promise = new Promise((resolve, reject) => { + this.#resolveServer = resolve; + this.#rejectServer = reject; + }); async init() { - if (this.props == null) { - throw new Error('MCP props are not initialized'); - } + try { + if (this.props == null) { + throw new Error('MCP props are not initialized'); + } - initMcpServer({ - server: await this.server, - clientOptions: this.props.clientProps, - mcpOptions: this.props.clientConfig, - }); + configureLogger({ level: 'info', pretty: false }); + + const server = await buildMcpServer(this.props.clientConfig?.stainlessApiKey); + + await initMcpServer({ + server, + clientOptions: this.props.clientProps, + mcpOptions: this.props.clientConfig, + }); + + this.#resolveServer(server); + } catch (error) { + this.#rejectServer(error); + throw error; + } } } From cb0cf049ff0138a42bce6c264f6a97f593093e52 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 20:41:26 +0000 Subject: [PATCH 29/36] docs: update http mcp docs --- packages/mcp-server/src/local-docs-search.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index 2b9d94e8..d0f4ce12 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -668,7 +668,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ }, http: { example: - 'curl https://api.imagekit.io/v1/files/copy \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/folder/to/copy/into/",\n "sourceFilePath": "/path/to/file.jpg"\n }\'', + 'curl https://api.imagekit.io/v1/files/copy \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "destinationPath": "/folder/to/copy/into/",\n "sourceFilePath": "/path/to/file.jpg",\n "includeFileVersions": false\n }\'', }, }, }, @@ -2571,7 +2571,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ }, http: { example: - 'curl https://api.imagekit.io/v1/accounts/origins \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "accessKey": "AKIAIOSFODNN7EXAMPLE",\n "bucket": "product-images",\n "name": "US S3 Storage",\n "secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n "type": "S3",\n "baseUrlForCanonicalHeader": "https://cdn.example.com",\n "prefix": "raw-assets"\n }\'', + 'curl https://api.imagekit.io/v1/accounts/origins \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "accessKey": "AKIAIOSFODNN7EXAMPLE",\n "bucket": "product-images",\n "name": "US S3 Storage",\n "secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n "type": "S3",\n "baseUrlForCanonicalHeader": "https://cdn.example.com",\n "includeCanonicalHeader": false,\n "prefix": "raw-assets"\n }\'', }, }, }, @@ -2701,7 +2701,7 @@ const EMBEDDED_METHODS: MethodEntry[] = [ }, http: { example: - 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "accessKey": "AKIAIOSFODNN7EXAMPLE",\n "bucket": "product-images",\n "name": "US S3 Storage",\n "secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n "type": "S3",\n "baseUrlForCanonicalHeader": "https://cdn.example.com",\n "prefix": "raw-assets"\n }\'', + 'curl https://api.imagekit.io/v1/accounts/origins/$ID \\\n -X PUT \\\n -H \'Content-Type: application/json\' \\\n -u "$IMAGEKIT_PRIVATE_KEY:OPTIONAL_IMAGEKIT_IGNORES_THIS" \\\n -d \'{\n "accessKey": "AKIAIOSFODNN7EXAMPLE",\n "bucket": "product-images",\n "name": "US S3 Storage",\n "secretKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",\n "type": "S3",\n "baseUrlForCanonicalHeader": "https://cdn.example.com",\n "includeCanonicalHeader": false,\n "prefix": "raw-assets"\n }\'', }, }, }, From e006926de887ad3daa88692a91fe1b588946760a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 20:58:54 +0000 Subject: [PATCH 30/36] docs: update logging docs --- packages/mcp-server/src/local-docs-search.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mcp-server/src/local-docs-search.ts b/packages/mcp-server/src/local-docs-search.ts index d0f4ce12..0290e879 100644 --- a/packages/mcp-server/src/local-docs-search.ts +++ b/packages/mcp-server/src/local-docs-search.ts @@ -3318,12 +3318,12 @@ const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'java', content: - '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.client.ImageKitClientAsync;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.MultipartField;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.core.http.Headers;\nimport io.imagekit.core.http.HttpResponseFor;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\nIf the proxy responds with `407 Proxy Authentication Required`, supply credentials by also configuring `proxyAuthenticator`:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.core.http.ProxyAuthenticator;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(...)\n // Or a custom implementation of `ProxyAuthenticator`.\n .proxyAuthenticator(ProxyAuthenticator.basic("username", "password"))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.JsonMissing;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nValidating the response is _not_ forwards compatible with new types from the API for existing fields.\n\nIf you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1)\n\n\nThe Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java.\n\n\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("io.imagekit:image-kit-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n io.imagekit\n image-kit-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport io.imagekit.client.ImageKitClient;\n\nImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClient client = ImageKitOkHttpClient.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.async().files().upload(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport io.imagekit.client.ImageKitClientAsync;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClientAsync;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv();\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nCompletableFuture response = client.files().upload(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.nio.file.Paths;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(new URL("https://example.com//path/to/file").openStream())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nOr a `byte[]` array:\n\n```java\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".getBytes())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.MultipartField;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.InputStream;\nimport java.net.URL;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(new URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build();\nFileUploadResponse response = client.files().upload(params);\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport io.imagekit.core.http.Headers;\nimport io.imagekit.core.http.HttpResponseFor;\nimport io.imagekit.models.files.FileUploadParams;\nimport io.imagekit.models.files.FileUploadResponse;\nimport java.io.ByteArrayInputStream;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes()))\n .fileName("file-name.jpg")\n .build();\nHttpResponseFor response = client.files().withRawResponse().upload(params);\n\nint statusCode = response.statusCode();\nHeaders headers = response.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse parsedResponse = response.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\nOr configure the client manually using the `logLevel` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.core.LogLevel;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .logLevel(LogLevel.INFO)\n .build();\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\nIf the proxy responds with `407 Proxy Authentication Required`, supply credentials by also configuring `proxyAuthenticator`:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport io.imagekit.core.http.ProxyAuthenticator;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(...)\n // Or a custom implementation of `ProxyAuthenticator`.\n .proxyAuthenticator(ProxyAuthenticator.basic("username", "password"))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\nimport java.time.Duration;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-java`\n - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Copy `image-kit-java-client-okhttp`\'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core`\n2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt):\n\n```java\nimport io.imagekit.core.JsonMissing;\nimport io.imagekit.models.files.FileUploadParams;\n\nFileUploadParams params = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport io.imagekit.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.files().upload(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport io.imagekit.core.JsonField;\nimport java.io.InputStream;\nimport java.util.Optional;\n\nJsonField file = client.files().upload(params)._file();\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = file.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nValidating the response is _not_ forwards compatible with new types from the API for existing fields.\n\nIf you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nimport io.imagekit.models.files.FileUploadResponse;\n\nFileUploadResponse response = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport io.imagekit.client.ImageKitClient;\nimport io.imagekit.client.okhttp.ImageKitOkHttpClient;\n\nImageKitClient client = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions.\n', }, { language: 'kotlin', content: - '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\nThe Image Kit Kotlin SDK is similar to the Image Kit Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nThe SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\nIf the proxy responds with `407 Proxy Authentication Required`, supply credentials by also configuring `proxyAuthenticator`:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.core.http.ProxyAuthenticator\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(...)\n // Or a custom implementation of `ProxyAuthenticator`.\n .proxyAuthenticator(ProxyAuthenticator.basic("username", "password"))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nValidating the response is _not_ forwards compatible with new types from the API for existing fields.\n\nIf you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', + '# Image Kit Kotlin API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-kotlin)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-kotlin/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-kotlin/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1)\n\n\nThe Image Kit Kotlin SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Kotlin.\n\nThe Image Kit Kotlin SDK is similar to the Image Kit Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.\n\n\n\n## MCP Server\n\nUse the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\nThe REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). KDocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-kotlin/0.0.1).\n\n## Installation\n\n### Gradle\n\n~~~kotlin\nimplementation("com.imagekit.api:image-kit-kotlin:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.imagekit.api\n image-kit-kotlin\n 0.0.1\n\n~~~\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n```\n\nOr manually:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .privateKey("My Private Key")\n .password("My Password")\n .build()\n```\n\nOr using a combination of the two approaches:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\n .fromEnv()\n .privateKey("My Private Key")\n .build()\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- |\n| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - |\n| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` |\n| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\n\nval clientWithOptions: ImageKitClient = client.withOptions {\n it.baseUrl("https://example.com")\n it.maxRetries(42)\n}\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.\n\nFor example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClient = ImageKitOkHttpClient.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.async().files().upload(params)\n```\n\nOr create an asynchronous client from the beginning:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClientAsync\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\n// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties\n// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables\nval client: ImageKitClientAsync = ImageKitOkHttpClientAsync.fromEnv()\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods are [suspending](https://kotlinlang.org/docs/coroutines-guide.html).\n\n\n\n## File uploads\n\nThe SDK defines methods that accept files.\n\nTo upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.nio.file.Paths\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(Paths.get("/path/to/file"))\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(URL("https://example.com//path/to/file").openStream())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nOr a `ByteArray`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file("content".toByteArray())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\nNote that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.MultipartField\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.InputStream\nimport java.net.URL\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(MultipartField.builder()\n .value(URL("https://example.com//path/to/file").openStream())\n .filename("/path/to/file")\n .build())\n .build()\nval response: FileUploadResponse = client.files().upload(params)\n```\n\n\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Kotlin classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```kotlin\nimport com.imagekit.api.core.http.Headers\nimport com.imagekit.api.core.http.HttpResponseFor\nimport com.imagekit.api.models.files.FileUploadParams\nimport com.imagekit.api.models.files.FileUploadResponse\nimport java.io.ByteArrayInputStream\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file("https://www.example.com/public-url.jpg".byteInputStream())\n .fileName("file-name.jpg")\n .build()\nval response: HttpResponseFor = client.files().withRawResponse().upload(params)\n\nval statusCode: Int = response.statusCode()\nval headers: Headers = response.headers()\n```\n\nYou can still deserialize the response into an instance of a Kotlin class if needed:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval parsedResponse: FileUploadResponse = response.parse()\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`ImageKitServiceException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`ImageKitIoException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors.\n\n- [`ImageKitRetryableException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`ImageKitException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n\n\n## Logging\n\nEnable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`:\n\n```sh\nexport IMAGE_KIT_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport IMAGE_KIT_LOG=debug\n```\n\nOr configure the client manually using the `logLevel` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.core.LogLevel\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .logLevel(LogLevel.INFO)\n .build()\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-kotlin-core` is published with a [configuration file](image-kit-kotlin-core/src/main/resources/META-INF/proguard/image-kit-kotlin-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build()\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build()\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.net.InetSocketAddress\nimport java.net.Proxy\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(Proxy(\n Proxy.Type.HTTP, InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build()\n```\n\nIf the proxy responds with `407 Proxy Authentication Required`, supply credentials by also configuring `proxyAuthenticator`:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport com.imagekit.api.core.http.ProxyAuthenticator\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .proxy(...)\n // Or a custom implementation of `ProxyAuthenticator`.\n .proxyAuthenticator(ProxyAuthenticator.basic("username", "password"))\n .build()\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\nimport java.time.Duration\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build()\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build()\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `image-kit-kotlin-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client\n- `image-kit-kotlin-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp\n- `image-kit-kotlin`\n - Depends on and exposes the APIs of both `image-kit-kotlin-core` and `image-kit-kotlin-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Copy `image-kit-kotlin-client-okhttp`\'s [`OkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`image-kit-kotlin` dependency](#installation) with `image-kit-kotlin-core`\n2. Write a class that implements the [`HttpClient`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface\n3. Construct [`ImageKitClientImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-kotlin-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build()\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .transformation(FileUploadParams.UploadTransformation.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build()\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .file(JsonValue.from(42))\n .fileName("file-name.jpg")\n .build()\n```\n\nThe most straightforward way to create a [`JsonValue`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonValue\n\n// Create primitive JSON values\nval nullValue: JsonValue = JsonValue.from(null)\nval booleanValue: JsonValue = JsonValue.from(true)\nval numberValue: JsonValue = JsonValue.from(42)\nval stringValue: JsonValue = JsonValue.from("Hello World!")\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nval arrayValue: JsonValue = JsonValue.from(listOf(\n "Hello", "World"\n))\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nval objectValue: JsonValue = JsonValue.from(mapOf(\n "a" to 1, "b" to 2\n))\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nval complexValue: JsonValue = JsonValue.from(mapOf(\n "a" to listOf(\n 1, 2\n ), "b" to listOf(\n 3, 4\n )\n))\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/core/Values.kt):\n\n```kotlin\nimport com.imagekit.api.core.JsonMissing\nimport com.imagekit.api.models.files.FileUploadParams\n\nval params: FileUploadParams = FileUploadParams.builder()\n .fileName("fileName")\n .file(JsonMissing.of())\n .build()\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```kotlin\nimport com.imagekit.api.core.JsonBoolean\nimport com.imagekit.api.core.JsonNull\nimport com.imagekit.api.core.JsonNumber\nimport com.imagekit.api.core.JsonValue\n\nval additionalProperties: Map = client.files().upload(params)._additionalProperties()\nval secretPropertyValue: JsonValue = additionalProperties.get("secretProperty")\n\nval result = when (secretPropertyValue) {\n is JsonNull -> "It\'s null!"\n is JsonBoolean -> "It\'s a boolean!"\n is JsonNumber -> "It\'s a number!"\n // Other types include `JsonMissing`, `JsonString`, `JsonArray`, and `JsonObject`\n else -> "It\'s something else!"\n}\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```kotlin\nimport com.imagekit.api.core.JsonField\nimport java.io.InputStream\n\nval file: JsonField = client.files().upload(params)._file()\n\nif (file.isMissing()) {\n // The property is absent from the JSON response\n} else if (file.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n val jsonString: String? = file.asString();\n\n // Try to deserialize into a custom type\n val myObject: MyClass = file.asUnknown()!!.convert(MyClass::class.java)\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-kotlin-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property.\n\nValidating the response is _not_ forwards compatible with new types from the API for existing fields.\n\nIf you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(params).validate()\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```kotlin\nimport com.imagekit.api.models.files.FileUploadResponse\n\nval response: FileUploadResponse = client.files().upload(\n params, RequestOptions.builder().responseValidation(true).build()\n)\n```\n\nOr configure the default for all method calls at the client level:\n\n```kotlin\nimport com.imagekit.api.client.ImageKitClient\nimport com.imagekit.api.client.okhttp.ImageKitOkHttpClient\n\nval client: ImageKitClient = ImageKitOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build()\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nKotlin `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-kotlin/issues) with questions, bugs, or suggestions.\n', }, { language: 'php', From 67dc9fd0584b80870b9428f7153ef937c78135bc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 7 May 2026 14:48:50 +0000 Subject: [PATCH 31/36] chore: redact api-key headers in debug logs --- src/internal/utils/log.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/internal/utils/log.ts b/src/internal/utils/log.ts index 7da41295..baff9a98 100644 --- a/src/internal/utils/log.ts +++ b/src/internal/utils/log.ts @@ -107,6 +107,8 @@ export const formatRequestDetails = (details: { name, ( name.toLowerCase() === 'authorization' || + name.toLowerCase() === 'api-key' || + name.toLowerCase() === 'x-api-key' || name.toLowerCase() === 'cookie' || name.toLowerCase() === 'set-cookie' ) ? From 11cd13ee5b3c050bf5043d535dfe35bbd17a6cec Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 12 May 2026 19:07:12 +0000 Subject: [PATCH 32/36] ci: pin GitHub Actions to commit SHAs Pin all GitHub Actions referenced in generated workflows (both first-party `actions/*` and third-party) to immutable commit SHAs. Updating pinned actions is now a deliberate codegen-side bump rather than implicit on every workflow run. --- .github/workflows/ci.yml | 14 +++++++------- .github/workflows/publish-npm.yml | 4 ++-- .github/workflows/release-doctor.yml | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4392cba..4aacb168 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,10 +21,10 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/imagekit-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Node - uses: actions/setup-node@v4 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: '22' @@ -43,10 +43,10 @@ jobs: contents: read id-token: write steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Node - uses: actions/setup-node@v4 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: '22' @@ -61,7 +61,7 @@ jobs: github.repository == 'stainless-sdks/imagekit-typescript' && !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc - uses: actions/github-script@v8 + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 with: script: core.setOutput('github_token', await core.getIDToken()); @@ -91,10 +91,10 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/imagekit-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Node - uses: actions/setup-node@v4 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: '22' diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index fbddfc6a..efa403d9 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -20,10 +20,10 @@ jobs: contents: write steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Node - uses: actions/setup-node@v3 + uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610 # v3.9.1 with: node-version: '20' diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index c9c6325c..96ac53f2 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -12,7 +12,7 @@ jobs: if: github.repository == 'imagekit-developer/imagekit-nodejs' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Check release environment run: | From f673e9b18023ad4897bffebdddbd8d9e7a93f49e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 06:27:37 +0000 Subject: [PATCH 33/36] feat(api): add no-enlarge crop modes and colorize transformation - Add `maintain_ratio_no_enlarge` to `crop` enum - Add `pad_resize_no_enlarge` and `pad_extract_no_shrink` to `cropMode` enum - Add `colorize` transformation parameter for applying color tints --- .stats.yml | 4 ++-- src/resources/shared.ts | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6b776b6f..278a536d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-362d0336e8f52ab1beb7d9602a3665dbb0277700e8dc01ef4f96fc7651699349.yml -openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-ad6dd3b4acf289708568a12574b997503059a47c4a4ca5ffefe64f40f3d3dbf3.yml +openapi_spec_hash: 7c103e2dff0edcbeea82057e62f58d4d config_hash: 94f48fd13b7d41b8b6a203a3a8cee9ed diff --git a/src/resources/shared.ts b/src/resources/shared.ts index fcd500ad..bc5416c3 100644 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -1437,6 +1437,17 @@ export interface Transformation { */ border?: string; + /** + * Applies a color tint to the image. Accepts color and intensity as optional + * parameters. + * + * - `co-color` - Color to apply (e.g., `red`, `blue`, `FF0022`). Default is gray + * color. + * - `in-intensity` - Intensity of the color (0-100). Default is 35. See + * [Colorize](https://imagekit.io/docs/effects-and-enhancements#colorize---e-colorize). + */ + colorize?: string; + /** * Indicates whether the output image should retain the original color profile. See * [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). @@ -1465,13 +1476,13 @@ export interface Transformation { * Crop modes for image resizing. See * [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). */ - crop?: 'force' | 'at_max' | 'at_max_enlarge' | 'at_least' | 'maintain_ratio'; + crop?: 'force' | 'at_max' | 'at_max_enlarge' | 'at_least' | 'maintain_ratio' | 'maintain_ratio_no_enlarge'; /** * Additional crop modes for image resizing. See * [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). */ - cropMode?: 'pad_resize' | 'extract' | 'pad_extract'; + cropMode?: 'pad_resize' | 'extract' | 'pad_extract' | 'pad_resize_no_enlarge' | 'pad_extract_no_shrink'; /** * Specifies a fallback image if the resource is not found, e.g., a URL or file From f6a558ea1f426d5a1c6f9121d33afbe330595c4f Mon Sep 17 00:00:00 2001 From: Manu Chaudhary Date: Wed, 13 May 2026 12:53:55 +0530 Subject: [PATCH 34/36] fix: correct typo in webhook_secret description Co-authored-by: Copilot --- packages/mcp-server/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mcp-server/manifest.json b/packages/mcp-server/manifest.json index 7627b523..c9dbefa4 100644 --- a/packages/mcp-server/manifest.json +++ b/packages/mcp-server/manifest.json @@ -43,7 +43,7 @@ }, "IMAGEKIT_WEBHOOK_SECRET": { "title": "webhook_secret", - "description": "Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you\'re using webhooks.\n", + "description": "Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`).\nYou can find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks).\nOnly required if you're using webhooks.\n", "required": false, "type": "string" } From 7390f2ee4fdf3caae56709a6308e08c2d7a58a73 Mon Sep 17 00:00:00 2001 From: Manu Chaudhary Date: Wed, 13 May 2026 12:59:09 +0530 Subject: [PATCH 35/36] feat(transformation): add colorize transformation support in URL generation Co-authored-by: Copilot --- src/lib/transformation-utils.ts | 1 + tests/custom-tests/url-generation/basic.test.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/transformation-utils.ts b/src/lib/transformation-utils.ts index 19bbe1a1..5dd27f49 100644 --- a/src/lib/transformation-utils.ts +++ b/src/lib/transformation-utils.ts @@ -61,6 +61,7 @@ export const supportedTransforms: { [key: string]: string } = { unsharpMask: 'e-usm', gradient: 'e-gradient', colorReplace: 'cr', + colorize: 'e-colorize', distort: 'e-distort', // Other flags & finishing diff --git a/tests/custom-tests/url-generation/basic.test.ts b/tests/custom-tests/url-generation/basic.test.ts index 2cc8d3f5..51971467 100644 --- a/tests/custom-tests/url-generation/basic.test.ts +++ b/tests/custom-tests/url-generation/basic.test.ts @@ -1343,6 +1343,7 @@ describe('URL generation', function () { unsharpMask: '2-2-0.8-0.024', gradient: 'from-red_to-white', // New transformation parameters + colorize: 'co-FF0000_in-15', colorReplace: 'FF0000_50_00FF00', distort: 'p-50_50_150_50_150_150_50_150', original: true, @@ -1353,7 +1354,7 @@ describe('URL generation', function () { }); expect(url).toBe( - `https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,x-10,y-20,xc-30,yc-40,fl-h,o-0.8,z-2,vc-h264,ac-aac,so-5,eo-15,du-10,sr-1440_1080,e-grayscale,e-upscale,e-retouch,e-genvar,e-dropshadow,e-changebg-prompt-car,e-edit-prompt-make it vintage,e-bgremove,e-contrast,e-shadow-bl-15_st-40_x-10_y-N5,e-sharpen-10,e-usm-2-2-0.8-0.024,e-gradient-from-red_to-white,cr-FF0000_50_00FF00,e-distort-p-50_50_150_50_150_150_50_150,orig-true,pg-2_4,h-200,w-300,l-image,i-logo.png,l-end`, + `https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,x-10,y-20,xc-30,yc-40,fl-h,o-0.8,z-2,vc-h264,ac-aac,so-5,eo-15,du-10,sr-1440_1080,e-grayscale,e-upscale,e-retouch,e-genvar,e-dropshadow,e-changebg-prompt-car,e-edit-prompt-make it vintage,e-bgremove,e-contrast,e-shadow-bl-15_st-40_x-10_y-N5,e-sharpen-10,e-usm-2-2-0.8-0.024,e-gradient-from-red_to-white,e-colorize-co-FF0000_in-15,cr-FF0000_50_00FF00,e-distort-p-50_50_150_50_150_150_50_150,orig-true,pg-2_4,h-200,w-300,l-image,i-logo.png,l-end`, ); }); From 9bf0bf02eb5b062c24b5a208a413ec70300f0316 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 07:29:47 +0000 Subject: [PATCH 36/36] release: 7.6.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 48 +++++++++++++++++++++++++++++++ package.json | 2 +- packages/mcp-server/manifest.json | 2 +- packages/mcp-server/package.json | 2 +- packages/mcp-server/src/server.ts | 2 +- src/version.ts | 2 +- 7 files changed, 54 insertions(+), 6 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index cd52c1e8..4c4a46ef 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "7.5.0" + ".": "7.6.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index b4b4aa46..7c654af4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,53 @@ # Changelog +## 7.6.0 (2026-05-13) + +Full Changelog: [v7.5.0...v7.6.0](https://github.com/imagekit-developer/imagekit-nodejs/compare/v7.5.0...v7.6.0) + +### Features + +* **api:** add no-enlarge crop modes and colorize transformation ([f673e9b](https://github.com/imagekit-developer/imagekit-nodejs/commit/f673e9b18023ad4897bffebdddbd8d9e7a93f49e)) +* **api:** manual updates ([7c35871](https://github.com/imagekit-developer/imagekit-nodejs/commit/7c35871232cfa418c30c6145fe0da2ec8937bca2)) +* **api:** manual updates ([e6c68dd](https://github.com/imagekit-developer/imagekit-nodejs/commit/e6c68dd1183dc12376ac54ef11da3a0f20487893)) +* **api:** manual updates ([03a3952](https://github.com/imagekit-developer/imagekit-nodejs/commit/03a3952e171bec93bc9efcd6897f33b5af3e2243)) +* **api:** manual updates ([f4b748a](https://github.com/imagekit-developer/imagekit-nodejs/commit/f4b748aab3a25fed6f0a29c30ca9c6f49f992c94)) +* **api:** manual updates ([8ad5efd](https://github.com/imagekit-developer/imagekit-nodejs/commit/8ad5efdd55d6d24310c7d8155de4ae85071d9540)) +* support setting headers via env ([79b7da8](https://github.com/imagekit-developer/imagekit-nodejs/commit/79b7da8857f2f0e32de93d15b613721d69c59a5d)) +* **transformation:** add colorize transformation support in URL generation ([7390f2e](https://github.com/imagekit-developer/imagekit-nodejs/commit/7390f2ee4fdf3caae56709a6308e08c2d7a58a73)) + + +### Bug Fixes + +* correct typo in webhook_secret description ([f6a558e](https://github.com/imagekit-developer/imagekit-nodejs/commit/f6a558ea1f426d5a1c6f9121d33afbe330595c4f)) + + +### Chores + +* avoid formatting file that gets changed during releases ([8bdfaae](https://github.com/imagekit-developer/imagekit-nodejs/commit/8bdfaaec37bdf7c465880d999cee790d852efc1f)) +* configure new SDK language ([a3427fe](https://github.com/imagekit-developer/imagekit-nodejs/commit/a3427fef3d71bbe5e1717e362d4654d4942d8df9)) +* fix example snippet imports ([c424b94](https://github.com/imagekit-developer/imagekit-nodejs/commit/c424b949a56ff4b4486cd694c073615e5293bcc3)) +* **format:** run eslint and prettier separately ([c753924](https://github.com/imagekit-developer/imagekit-nodejs/commit/c75392491c141b2fc635481b75007bfb47101741)) +* **formatter:** run prettier and eslint separately ([d7c26d7](https://github.com/imagekit-developer/imagekit-nodejs/commit/d7c26d76741fb611fc131806719aad0ee3696c4e)) +* **internal:** codegen related update ([48e7a85](https://github.com/imagekit-developer/imagekit-nodejs/commit/48e7a85f9464d937a11967ed6255c1249ecd683b)) +* **internal:** codegen related update ([21fe6ee](https://github.com/imagekit-developer/imagekit-nodejs/commit/21fe6eeadfc0376dffb409f78dadc3c3b32194da)) +* **internal:** fix MCP cloudflare worker builds ([d7fcbd6](https://github.com/imagekit-developer/imagekit-nodejs/commit/d7fcbd65da4658fd1d55f97d20997cfca03ee64c)) +* **internal:** fix MCP cloudflare worker initialization ([d93bb2d](https://github.com/imagekit-developer/imagekit-nodejs/commit/d93bb2d88e29d44460cc453fcf21fb9dc28c8fdc)) +* **internal:** more robust bootstrap script ([853429c](https://github.com/imagekit-developer/imagekit-nodejs/commit/853429c552a32b3e46246bf9849dbebcc6e41e50)) +* **internal:** update docs ordering ([885c2ad](https://github.com/imagekit-developer/imagekit-nodejs/commit/885c2ad3123fb0be7f58a12576402a31eda9743d)) +* redact api-key headers in debug logs ([67dc9fd](https://github.com/imagekit-developer/imagekit-nodejs/commit/67dc9fd0584b80870b9428f7153ef937c78135bc)) +* remove webhook signature verification example from README ([352ec15](https://github.com/imagekit-developer/imagekit-nodejs/commit/352ec15b82f69fa56005e12eb53af84e6397d12e)) +* restructure docs search code ([8b9992f](https://github.com/imagekit-developer/imagekit-nodejs/commit/8b9992f6465052eb1b215bf3ed230dbfef5ad4f6)) +* update CLI documentation ([1967acf](https://github.com/imagekit-developer/imagekit-nodejs/commit/1967acf48ab8aae241680a623fc311da6c2cfd6a)) +* update SDK settings ([fab0b1e](https://github.com/imagekit-developer/imagekit-nodejs/commit/fab0b1e4659e232c59df2a1e1ebec09d0f8639da)) + + +### Documentation + +* clarify forwards compat behavior ([1c4774d](https://github.com/imagekit-developer/imagekit-nodejs/commit/1c4774d5845ecc0839de1b259cc6e291ce5e543a)) +* update http mcp docs ([cb0cf04](https://github.com/imagekit-developer/imagekit-nodejs/commit/cb0cf049ff0138a42bce6c264f6a97f593093e52)) +* update logging docs ([e006926](https://github.com/imagekit-developer/imagekit-nodejs/commit/e006926de887ad3daa88692a91fe1b588946760a)) +* update with proxy auth info ([c7668e7](https://github.com/imagekit-developer/imagekit-nodejs/commit/c7668e7e446fcd2d5de84e76d4f14505d0314895)) + ## 7.5.0 (2026-04-13) Full Changelog: [v7.4.0...v7.5.0](https://github.com/imagekit-developer/imagekit-nodejs/compare/v7.4.0...v7.5.0) diff --git a/package.json b/package.json index b1c22e58..86cfb655 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@imagekit/nodejs", - "version": "7.5.0", + "version": "7.6.0", "description": "Offical NodeJS SDK for ImageKit.io integration", "author": "Image Kit ", "types": "dist/index.d.ts", diff --git a/packages/mcp-server/manifest.json b/packages/mcp-server/manifest.json index c9dbefa4..c2823561 100644 --- a/packages/mcp-server/manifest.json +++ b/packages/mcp-server/manifest.json @@ -1,7 +1,7 @@ { "dxt_version": "0.2", "name": "@imagekit/api-mcp", - "version": "7.5.0", + "version": "7.6.0", "description": "The official MCP Server for the Image Kit API", "author": { "name": "Image Kit", diff --git a/packages/mcp-server/package.json b/packages/mcp-server/package.json index d3b791d3..1cbdce5e 100644 --- a/packages/mcp-server/package.json +++ b/packages/mcp-server/package.json @@ -1,6 +1,6 @@ { "name": "@imagekit/api-mcp", - "version": "7.5.0", + "version": "7.6.0", "description": "The official MCP Server for the Image Kit API", "author": "Image Kit ", "types": "dist/index.d.ts", diff --git a/packages/mcp-server/src/server.ts b/packages/mcp-server/src/server.ts index 4668d948..71f4f1b7 100644 --- a/packages/mcp-server/src/server.ts +++ b/packages/mcp-server/src/server.ts @@ -28,7 +28,7 @@ export const newMcpServer = async ({ new McpServer( { name: 'imagekit_nodejs_api', - version: '7.5.0', + version: '7.6.0', }, { instructions: await getInstructions({ stainlessApiKey, customInstructionsPath }), diff --git a/src/version.ts b/src/version.ts index 662d85ef..6020f5e0 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '7.5.0'; // x-release-please-version +export const VERSION = '7.6.0'; // x-release-please-version