diff --git a/src/datacustomcode/templates/function/example/chunking_with_external_callout/README.md b/src/datacustomcode/templates/function/example/chunking_with_external_callout/README.md deleted file mode 100644 index 205c004..0000000 --- a/src/datacustomcode/templates/function/example/chunking_with_external_callout/README.md +++ /dev/null @@ -1,120 +0,0 @@ -# Chunking with a Gemini Named Credential Callout - -Splits each input document into paragraph-sized chunks and calls Google's -**Gemini** `generateContent` API for every chunk. The model returns a summary, -category, sentiment, and topics, which are attached to the chunk as citations so -the search index can filter and rank on them. Gemini is reached through a -**Named Credential**, so this code never handles the endpoint URL or the API key. - -## How the callout works - -```python -CALLOUT_URL = "callout:gemini" # callout:[/] - -request = ( - HTTPRequestBuilder() - .set_url(CALLOUT_URL) - .set_method(HTTPMethod.POST) - .set_headers({"Content-Type": "application/json"}) - .set_response_timeout_seconds(60) # optional: per-callout timeout (seconds) - .build() -) -# Body is sent verbatim (serialize it yourself); the response body is a raw string. -response = runtime.named_credential.request(request, json.dumps(payload)) -if response.is_success: - envelope = json.loads(response.body) - text = envelope["candidates"][0]["content"]["parts"][0]["text"] -``` - -The request asks for `responseMimeType: application/json` with a `responseSchema`, -so Gemini returns the classification as a JSON string in -`candidates[0].content.parts[0].text` — decode it, then decode that text again. - -The `gemini` Named Credential's URL already includes the full -`/v1beta/models/:generateContent` path, so the callout is just -`callout:gemini` with **no path suffix** (anything after the name is appended to -the credential's URL). - -## Configure the Named Credential - -1. Create an **External Credential** (e.g. `google_api_key`) that injects your - Gemini API key as the `X-goog-api-key` header. -2. Create a **Named Credential** named `gemini`: - - **URL**: `https://generativelanguage.googleapis.com/v1beta/models/gemini-flash-latest:generateContent` - - **Enabled for Callouts** + **Generate Authorization Header**: on - - **External Credential**: `google_api_key` - -## Test locally - -```bash -DATACUSTOMCODE_EXTERNAL_CALLOUT_CONFIG=/abs/path/to/external_callout_config.json \ - sf data-code-extension function run \ - --entrypoint payload/entrypoint.py \ - --test-with payload/tests/test.json \ - --target-org -``` - -With `--target-org` the SDK fetches only the **URL** from the org's Named -Credential; **auth is always taken from `external_callout_config.json`** locally -(the org's External Credential is used only in the Data Cloud runtime). So the -`X-goog-api-key` must be in the local config for a local test. Omit -`--target-org` to run fully offline using `target_url`. - -```json -{ - "credentials": { - "callout:gemini": { - "auth_type": "Custom", - "custom_headers": { "X-goog-api-key": "YOUR_GEMINI_API_KEY" }, - "target_url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-flash-latest:generateContent" - } - } -} -``` - -Place `external_callout_config.json` in the **parent of your payload folder** (or -point `DATACUSTOMCODE_EXTERNAL_CALLOUT_CONFIG` at it). It is never packaged into -the deployment zip. Get a key from [Google AI Studio](https://aistudio.google.com/apikey); -**do not commit it.** - -## Auth types - -`auth_type` selects how auth is injected for local testing. It should mirror the -External Credential your Named Credential uses in the org, so local and deployed -runs behave the same. This example uses `Custom` (Gemini's `X-goog-api-key`); -all four supported types: - -```json -{ - "credentials": { - "callout:my_custom_api": { - "auth_type": "Custom", - "custom_headers": { "X-goog-api-key": "YOUR_API_KEY" } - }, - "callout:my_basic_api": { - "auth_type": "Basic", - "username": "svc_user", - "password": "YOUR_PASSWORD" - }, - "callout:my_oauth_api": { - "auth_type": "OAuth", - "access_token": "YOUR_ACCESS_TOKEN" - }, - "callout:my_jwt_api": { - "auth_type": "Jwt", - "token": "YOUR_JWT" - } - } -} -``` - -| `auth_type` | Fields read | Header sent | -| ----------- | ------------------------------- | --------------------------------------- | -| `Basic` | `username`, `password` | `Authorization: Basic ` | -| `Custom` | `custom_headers` (sent verbatim)| the headers you list | -| `OAuth` | `access_token` or `token` | `Authorization: Bearer ` | -| `Jwt` | `access_token` or `token` | `Authorization: Bearer ` | - -`OAuth`/`Jwt` take a token you supply for the local run — the SDK does not fetch -or refresh it. In the Data Cloud runtime the Named Credential handles token -acquisition; this local config only stands in for that during testing. diff --git a/src/datacustomcode/templates/function/example/chunking_with_external_callout/config.json b/src/datacustomcode/templates/function/example/chunking_with_external_callout/config.json deleted file mode 100644 index 2f911e9..0000000 --- a/src/datacustomcode/templates/function/example/chunking_with_external_callout/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "entryPoint": "entrypoint.py" -} diff --git a/src/datacustomcode/templates/function/example/chunking_with_external_callout/entrypoint.py b/src/datacustomcode/templates/function/example/chunking_with_external_callout/entrypoint.py deleted file mode 100644 index ab1b00c..0000000 --- a/src/datacustomcode/templates/function/example/chunking_with_external_callout/entrypoint.py +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (c) 2025, Salesforce, Inc. -# SPDX-License-Identifier: Apache-2 - -""" -Document Chunking with a Gemini Named Credential Callout - -Splits each input document into paragraph-sized chunks and classifies every -chunk via Google's Gemini ``generateContent`` API, reached through a Named -Credential (``callout:gemini``) so the endpoint URL and API key are resolved -outside this code. The classification is attached to each chunk as citations. -""" - -import json -import logging - -from datacustomcode.function import Runtime -from datacustomcode.function.feature_types.chunking import ( - ChunkType, - SearchIndexChunkingV1Output, - SearchIndexChunkingV1Request, - SearchIndexChunkingV1Response, -) -from datacustomcode.named_credential.types.http_method import HTTPMethod -from datacustomcode.named_credential.types.http_request_builder import ( - HTTPRequestBuilder, -) - -logger = logging.getLogger(__name__) -logging.basicConfig(level=logging.INFO) - -CALLOUT_URL = "callout:gemini" - -_ANALYSIS_FIELDS = ("summary", "category", "sentiment") - -_PROMPT = ( - "Analyze the following document chunk and classify it. Respond with its " - "one-sentence summary, a single-word category, overall sentiment " - "(positive, negative, or neutral), and up to five key topics.\n\nChunk:\n" -) - -# Force Gemini to return the classification as JSON in a fixed shape. -_GENERATION_CONFIG = { - "responseMimeType": "application/json", - "responseSchema": { - "type": "object", - "properties": { - "summary": {"type": "string"}, - "category": {"type": "string"}, - "sentiment": {"type": "string"}, - "topics": {"type": "array", "items": {"type": "string"}}, - }, - "required": ["summary", "category", "sentiment", "topics"], - }, -} - - -def _chunk_text(text: str, max_words: int = 80) -> list[str]: - """Split text into paragraph-aligned chunks of at most ``max_words`` words.""" - paragraphs = [p.strip() for p in text.split("\n\n") if p.strip()] - - chunks: list[str] = [] - current: list[str] = [] - current_words = 0 - - for paragraph in paragraphs: - paragraph_words = len(paragraph.split()) - if current and current_words + paragraph_words > max_words: - chunks.append("\n\n".join(current)) - current = [] - current_words = 0 - current.append(paragraph) - current_words += paragraph_words - - if current: - chunks.append("\n\n".join(current)) - - return chunks - - -def _extract_model_json(body: str) -> dict: - """Decode the model's JSON classification from a Gemini response. - - The generated text sits at ``candidates[0].content.parts[0].text`` and is - itself a JSON string, so decode twice. Any malformed layer yields ``{}``. - """ - try: - envelope = json.loads(body) if body else {} - except json.JSONDecodeError: - return {} - - try: - text = envelope["candidates"][0]["content"]["parts"][0]["text"] - except (KeyError, IndexError, TypeError): - return {} - - try: - payload = json.loads(text) - except json.JSONDecodeError: - return {} - return payload if isinstance(payload, dict) else {} - - -def _analyze_chunk(chunk_text: str, runtime: Runtime) -> dict[str, str]: - """Classify one chunk via the Gemini callout and return it as citations.""" - request = ( - HTTPRequestBuilder() - .set_url(CALLOUT_URL) - .set_method(HTTPMethod.POST) - .set_headers({"Content-Type": "application/json", "Accept": "application/json"}) - .set_response_timeout_seconds(60) - .build() - ) - - payload = { - "contents": [{"parts": [{"text": _PROMPT + chunk_text}]}], - "generationConfig": _GENERATION_CONFIG, - } - response = runtime.named_credential.request(request, json.dumps(payload)) - - # Don't raise: a single failed callout shouldn't abort the whole job. - if not response.is_success: - logger.error(f"Gemini callout failed with status {response.status_code}") - return {"analysis_status": "failed", "http_status": str(response.status_code)} - - data = _extract_model_json(response.body) - citations = {"analysis_status": "success"} - for field in _ANALYSIS_FIELDS: - value = data.get(field) - citations[field] = str(value) if value is not None else "unavailable" - - topics = data.get("topics") - if isinstance(topics, list): - citations["topics"] = ", ".join(str(topic) for topic in topics) - - return citations - - -def function( - request: SearchIndexChunkingV1Request, runtime: Runtime -) -> SearchIndexChunkingV1Response: - """Chunk each input document and classify every chunk via the Gemini API.""" - logger.info(f"Received {len(request.input)} documents to chunk") - - chunks = [] - chunk_id = 1 - - for doc in request.input: - for chunk_text in _chunk_text(doc.text): - citations = _analyze_chunk(chunk_text, runtime) - - chunk = SearchIndexChunkingV1Output( - text=chunk_text, - seq_no=chunk_id, - chunk_type=ChunkType.TEXT, - citations=citations, - ) - chunks.append(chunk) - chunk_id += 1 - - logger.info(f"Produced {len(chunks)} classified chunks") - return SearchIndexChunkingV1Response(output=chunks) diff --git a/src/datacustomcode/templates/function/example/chunking_with_external_callout/external_callout_config.json b/src/datacustomcode/templates/function/example/chunking_with_external_callout/external_callout_config.json deleted file mode 100644 index 2f979ea..0000000 --- a/src/datacustomcode/templates/function/example/chunking_with_external_callout/external_callout_config.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "credentials": { - "callout:gemini": { - "auth_type": "Custom", - "custom_headers": { - "X-goog-api-key": "YOUR_API_KEY" - }, - "target_url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-flash-latest:generateContent" - } - } -} diff --git a/src/datacustomcode/templates/function/example/chunking_with_external_callout/tests/test.json b/src/datacustomcode/templates/function/example/chunking_with_external_callout/tests/test.json deleted file mode 100644 index c4d9960..0000000 --- a/src/datacustomcode/templates/function/example/chunking_with_external_callout/tests/test.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "input": [ - { - "text": "Product Review: Northstar Analytics\n\nWe rolled Northstar out to our whole revenue team last quarter and the difference has been night and day. Dashboards that used to take our analysts a full day to assemble now refresh in seconds, and the natural-language query box means our account executives can answer their own questions without filing a ticket.\n\nOnboarding was smoother than any tool we have adopted in years. The guided setup imported our Salesforce data on the first try and the sample templates gave us something useful on day one. Support answered our two questions within the hour. Easily the best purchase decision we made this year." - }, - { - "text": "Support Ticket #48210: Repeated timeouts on scheduled exports\n\nFor the third week running our nightly export to the data warehouse has failed silently. There is no alert, no email, nothing in the activity log, and we only find out when the morning report is empty and the leadership meeting has no numbers.\n\nI have raised this twice already and both times the ticket was closed as resolved without anyone actually contacting me. This is costing us real credibility internally and I am extremely frustrated. If the connector cannot handle our volume we need to know now so we can plan a migration, because right now the product is not doing the one job we bought it for." - }, - { - "text": "Renewal Feedback: mixed feelings heading into year two\n\nThe core product is genuinely good. The reporting engine is fast, the permissions model is granular enough for our compliance team, and our analysts like working in it. On the functionality alone I would renew without hesitation.\n\nWhat gives me pause is the pricing. The per-seat cost jumped noticeably at renewal and several add-ons that used to be included are now separate line items. The value is still there, but the conversation with my finance team was harder than it should have been, and I would like more transparency before the next cycle." - }, - { - "text": "Feature Request: scheduled report subscriptions\n\nWe would like the ability to subscribe internal stakeholders to a report on a recurring schedule so a PDF lands in their inbox every Monday morning. Today we export manually and forward it, which is workable but easy to forget.\n\nA few teams have asked whether subscriptions could support filtered views per recipient, for example each regional manager receiving only their own territory. Not urgent for us, but it would remove a recurring bit of manual work and is something a couple of competing tools already offer." - } - ] -} diff --git a/src/datacustomcode/templates/script/examples/external_callout/README.md b/src/datacustomcode/templates/script/examples/external_callout/README.md deleted file mode 100644 index eadfa4f..0000000 --- a/src/datacustomcode/templates/script/examples/external_callout/README.md +++ /dev/null @@ -1,140 +0,0 @@ -# Transform with a Gemini Named Credential Callout - -The **transform** calls Google's **Gemini** `generateContent` API to summarize text, and -write the result back to a DLO. Gemini is reached through a **Named Credential** -(`callout:gemini`), so this code never handles the endpoint URL or the API key. - -It shows **both** callout paths against the same Named Credential. - -## Shared request template - -```python -from datacustomcode.client import Client, named_credential_request_col - -# URL, method and headers apply to every callout on this template. -request = ( - HTTPRequestBuilder() - .set_url("callout:gemini") # callout:[/] - .set_method(HTTPMethod.POST) - .set_headers({"Content-Type": "application/json"}) - .set_response_timeout_seconds(60) # optional: per-callout timeout (seconds) - .build() -) -``` - -## Driver path — one-shot on the driver - -`Client.named_credential_request` runs the callout **once** on the driver and -returns an `HTTPResponse` (`.status_code`, `.body`, `.headers`, `.is_success`). -Use it for a lookup or a shared value you reuse across the job. - -```python -response = client.named_credential_request(request, body=json.dumps(payload)) -if response.is_success: - envelope = json.loads(response.body) - text = envelope["candidates"][0]["content"]["parts"][0]["text"] -``` - -## Per-row path — fan out across the DataFrame - -`named_credential_request_col` dispatches one callout per row; only the body -Column varies. - -```python -# One callout per row; body is a Column built from the row's data. -df = df.withColumn("_callout", named_credential_request_col(request, body=body_col)) -``` - -It returns a struct Column: - -``` -{status, response: {status_code, body, headers}, error_code, error_message} -``` - -- A non-2xx response is still `status = "SUCCESS"` with the HTTP code in - `response.status_code` — extracting the model text just yields null for that row. -- A transport failure sets `status = "ERROR"`; the row survives, the job does not - abort. Pull the model text out of `response.body` with `get_json_object(...)`. - -Both paths resolve the same Named Credential and read auth from the same local -`external_callout_config.json`. - -The `gemini` Named Credential's URL already includes the full -`/v1beta/models/:generateContent` path, so the callout is just -`callout:gemini` with **no path suffix** (anything after the name is appended to -the credential's URL). - -## Configure the Named Credential - -1. Create an **External Credential** (e.g. `google_api_key`) that injects your - Gemini API key as the `X-goog-api-key` header. -2. Create a **Named Credential** named `gemini`: - - **URL**: `https://generativelanguage.googleapis.com/v1beta/models/gemini-flash-latest:generateContent` - - **Enabled for Callouts** + **Generate Authorization Header**: on - - **External Credential**: `google_api_key` - -## Test locally - -Copy `entrypoint.py` into your `payload/` folder (or point the run at it), then: - -```bash -DATACUSTOMCODE_EXTERNAL_CALLOUT_CONFIG=/abs/path/to/external_callout_config.json \ - sf data-code-extension script run --entrypoint entrypoint.py --target-org -``` - -With `----target-org` the SDK fetches only the **URL** from the org's Named -Credential; **auth is always taken from `external_callout_config.json`** locally -(the org's External Credential is used only in the Data Cloud runtime). So the -`X-goog-api-key` must be in the local config for a local test. Omit -`--target-org` to run fully offline using `target_url`. - -```json -{ - "credentials": { - "callout:gemini": { - "auth_type": "Custom", - "custom_headers": { "X-goog-api-key": "YOUR_GEMINI_API_KEY" }, - "target_url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-flash-latest:generateContent" - } - } -} -``` - -Place `external_callout_config.json` in the **parent of your payload folder** (or -point `DATACUSTOMCODE_EXTERNAL_CALLOUT_CONFIG` at it). It is never packaged into -the deployment zip. Get a key from [Google AI Studio](https://aistudio.google.com/apikey); -**do not commit it.** - -## What it reads / writes - -`config.json` declares the DLO permissions for deployment: - -| | DLO | Notes | -| ------ | ------------------- | --------------------------------------------- | -| read | `Account_std__dll` | source rows; `description__c` is summarized | -| write | `Account_std_copy__dll` | adds `summary__c`, `callout_status__c`, `callout_http_code__c` | - -Adjust `_TEXT_COLUMN`, `_SOURCE_DLO` and `_TARGET_DLO` in `entrypoint.py` (and the -matching entries in `config.json`) to point at your own DLOs. - -## Auth types - -`auth_type` selects how auth is injected for local testing. It should mirror the -External Credential your Named Credential uses in the org, so local and deployed -runs behave the same. This example uses `Custom` (Gemini's `X-goog-api-key`); -all supported types: - -| `auth_type` | Fields read | Header sent | -| ----------- | ------------------------------- | --------------------------------------- | -| `Basic` | `username`, `password` | `Authorization: Basic ` | -| `Custom` | `custom_headers` (sent verbatim)| the headers you list | -| `OAuth` | `access_token` or `token` | `Authorization: Bearer ` | -| `Jwt` | `access_token` or `token` | `Authorization: Bearer ` | -| `AwsSv4` | `aws_access_key_id`, `aws_secret_access_key`, `aws_region`, `aws_service`, optional `aws_session_token` | `Authorization: AWS4-HMAC-SHA256 ...` plus `x-amz-date` / `x-amz-content-sha256` (and `x-amz-security-token` when a session token is set) | - -`OAuth`/`Jwt` take a token you supply for the local run — the SDK does not fetch -or refresh it. In the Data Cloud runtime the Named Credential handles token -acquisition; this local config only stands in for that during testing. - -`AwsSv4` signs the request with AWS Signature Version 4 using the keys you -supply, mirroring an AWS Signature Version 4 External Credential in the org. diff --git a/src/datacustomcode/templates/script/examples/external_callout/entrypoint.py b/src/datacustomcode/templates/script/examples/external_callout/entrypoint.py deleted file mode 100644 index 547bcef..0000000 --- a/src/datacustomcode/templates/script/examples/external_callout/entrypoint.py +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (c) 2025, Salesforce, Inc. -# SPDX-License-Identifier: Apache-2 - -""" -Data Transform with a Gemini Named Credential Callout - -This is a batch transform: read a DLO, enrich it via Google's Gemini ``generateContent`` -API, and write the result back to a DLO. - -It shows **both** callout paths against the same Named Credential -(``callout:gemini``); the request template (URL, method, headers) is shared and -only the body differs: - -- **Driver path** — :meth:`Client.named_credential_request` runs **once** on the - driver and returns an :class:`HTTPResponse`. Use it for a single job-level - callout whose result you reuse across the job. -- **Per-row path** — :func:`datacustomcode.client.named_credential_request_col` - fans the callout out across the DataFrame, one call per row, returning a struct - Column ``{status, response, error_code, error_message}`` where ``response`` is - itself ``{status_code, body, headers}``. A non-2xx response is still - ``SUCCESS`` with its code in ``response.status_code``; a transport failure sets - ``status`` to ``ERROR`` without aborting the whole Spark job. -""" - -import json -import logging - -from pyspark.sql import Column -from pyspark.sql.functions import ( - array, - col, - concat, - get_json_object, - lit, - struct, - to_json, -) - -from datacustomcode.client import Client, named_credential_request_col -from datacustomcode.io.writer.base import WriteMode -from datacustomcode.named_credential.types.http_method import HTTPMethod -from datacustomcode.named_credential.types.http_request_builder import ( - HTTPRequestBuilder, -) - -logger = logging.getLogger(__name__) -logging.basicConfig(level=logging.INFO) - -CALLOUT_URL = "callout:gemini" - -_TEXT_COLUMN = "Description__c" -_SOURCE_DLO = "Account_std__dll" -_TARGET_DLO = "Account_std_copy__dll" - -_PROMPT = ( - "Summarize the following text in one sentence. Respond with the summary " - "only, no preamble.\n\nText:\n" -) - -_REQUEST = ( - HTTPRequestBuilder() - .set_url(CALLOUT_URL) - .set_method(HTTPMethod.POST) - .set_headers({"Content-Type": "application/json", "Accept": "application/json"}) - .set_response_timeout_seconds(60) - .build() -) - - -def _gemini_body_col(text_col: Column) -> Column: - """Build a per-row Gemini ``generateContent`` request body as a JSON string. - - Using ``to_json(struct(...))`` keeps the row text properly escaped inside the - JSON payload rather than string-concatenating it. - """ - prompt = concat(lit(_PROMPT), text_col) - contents = array(struct(array(struct(prompt.alias("text"))).alias("parts"))) - return to_json(struct(contents.alias("contents"))) - - -def _gemini_body(text: str) -> str: - """Build a Gemini ``generateContent`` request body as a JSON string (driver).""" - return json.dumps({"contents": [{"parts": [{"text": _PROMPT + text}]}]}) - - -def _summarize_on_driver(client: Client, text: str) -> str: - """One-shot driver callout: summarize a single string once, not per row. - - The scalar counterpart to the per-row column path — same request template, - but dispatched once on the driver and returning an ``HTTPResponse``. - """ - response = client.named_credential_request(_REQUEST, body=_gemini_body(text)) - - # Don't raise: a failed driver callout shouldn't abort the whole job. - if not response.is_success: - logger.error(f"Driver Gemini callout failed: HTTP {response.status_code}") - return "" - - envelope = json.loads(response.body) if response.body else {} - try: - return str(envelope["candidates"][0]["content"]["parts"][0]["text"]) - except (KeyError, IndexError, TypeError): - return "" - - -def main(): - client = Client() - - df = client.read_dlo(_SOURCE_DLO) - - # Driver path: one callout on the driver over a single representative row. - sample = df.select(_TEXT_COLUMN).first() - if sample and sample[0]: - driver_summary = _summarize_on_driver(client, sample[0]) - logger.info(f"Driver-path sample summary: {driver_summary}") - - # Per-row path: one Gemini callout per row; the result struct is a column. - callout = named_credential_request_col( - _REQUEST, body=_gemini_body_col(col(_TEXT_COLUMN)) - ) - df = df.withColumn("_callout", callout) - - # Pull the model's text out of the response body. A row whose callout failed - # (non-2xx or transport error) yields null here rather than failing the job. - summary = get_json_object( - col("_callout")["response"]["body"], - "$.candidates[0].content.parts[0].text", - ) - - df = df.select( - col("id__c").alias("id__c"), - col("Description__c").alias("description__c"), - col("kq_id__c").alias("kq_id__c"), - summary.alias("summary__c"), - col("_callout")["status"].alias("callout_status__c"), - col("_callout")["response"]["status_code"].alias("callout_http_code__c"), - ) - - client.write_to_dlo(_TARGET_DLO, df, write_mode=WriteMode.APPEND) - - -if __name__ == "__main__": - main() diff --git a/src/datacustomcode/templates/script/examples/external_callout/external_callout_config.json b/src/datacustomcode/templates/script/examples/external_callout/external_callout_config.json deleted file mode 100644 index 2f979ea..0000000 --- a/src/datacustomcode/templates/script/examples/external_callout/external_callout_config.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "credentials": { - "callout:gemini": { - "auth_type": "Custom", - "custom_headers": { - "X-goog-api-key": "YOUR_API_KEY" - }, - "target_url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-flash-latest:generateContent" - } - } -}