> ## Documentation Index
> Fetch the complete documentation index at: https://docs.doconda.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to generate an Excel file from Gemini on Vertex AI

> Declare doconda.tools() as Gemini functions on Vertex AI: the model creates an .xlsx with real formulas and gives you the link.

Install `google-genai` and `doconda` (or the AI SDK with `@ai-sdk/google-vertex`) and declare `doconda.tools()` as
Gemini functions. When you ask for a spreadsheet, Gemini calls `create_document` with `format: "xlsx"` and you get an
Excel file with real formulas and its PDF, with their download links.

## Steps

1. Authenticate with Google Cloud (`gcloud auth application-default login` or a service account) and have a project with
   Vertex AI enabled.
2. Put your Doconda API key (dashboard → **API keys**) in `DOCONDA_API_KEY`.
3. Declare the tools and run the loop: while Gemini asks for functions, run them and hand back the result.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  # pip install google-genai doconda
  from doconda import Doconda
  from google import genai
  from google.genai import types

  client = genai.Client(vertexai=True, project="my-project", location="europe-west1")
  tools = Doconda().tools()
  config = types.GenerateContentConfig(
      tools=[types.Tool(function_declarations=[
          types.FunctionDeclaration(name=t.name, description=t.description, parameters_json_schema=t.input_schema) for t in tools
      ])]
  )
  contents = [types.Content(role="user", parts=[types.Part.from_text(text="Make me an Excel file with the event budget")])]

  while True:
      res = client.models.generate_content(model="gemini-3.5-flash", contents=contents, config=config)
      if not res.function_calls:
          break
      contents.append(res.candidates[0].content)
      parts = [
          types.Part.from_function_response(name=c.name, response={"result": next(t for t in tools if t.name == c.name).run(dict(c.args or {}))})
          for c in res.function_calls
      ]
      contents.append(types.Content(role="user", parts=parts))

  print(res.text)
  ```

  ```ts TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  // npm install ai @ai-sdk/google-vertex @doconda/sdk
  import { createVertex } from "@ai-sdk/google-vertex"
  import { generateText, isStepCount, jsonSchema, tool } from "ai"
  import { Doconda } from "@doconda/sdk"

  const vertex = createVertex({ project: "my-project", location: "europe-west1" })
  const doconda = new Doconda()
  const tools = Object.fromEntries(
    doconda.tools().map((t) => [
      t.name,
      tool({ description: t.description, inputSchema: jsonSchema(t.inputSchema), execute: (input) => t.run(input as Record<string, unknown>) }),
    ]),
  )

  const { text } = await generateText({
    model: vertex("gemini-3.5-flash"),
    tools,
    stopWhen: isStepCount(5),
    prompt: "Make me an Excel file with the event budget",
  })

  console.log(text)
  ```
</CodeGroup>

`parameters_json_schema` (`parametersJsonSchema` in `@google/genai`) takes each tool's JSON Schema as is.

## What you get back

```json theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
{
  "id": "doc_01JAB3…",
  "format": "xlsx",
  "status": "ready",
  "links": { "xlsx": "https://…", "pdf": "https://…" },
  "links_note": "Links expire in 5 minutes: call get_document for fresh ones."
}
```

* An Excel file with real formulas (not pasted numbers), with the assumptions in their own cells, and its PDF.
* `status`: `ready`, `ready_with_warnings`, `needs_review` or `failed` (not charged).
* Links expire after 5 minutes; the agent gets fresh ones with `get_document`.

## FAQ

<AccordionGroup>
  <Accordion title="Does it work with the Gemini API without Vertex AI?">
    Yes, it's the same code without `vertexai=True`. See the [Gemini](/en/agents/gemini) guide.
  </Accordion>

  <Accordion title="Can I give it my own data for the spreadsheet?">
    Yes. Upload your files with `upload_file` and the agent passes them as sources (up to 5 documents: Word,
    PowerPoint, Excel, PDF, TXT or Markdown).
  </Accordion>

  <Accordion title="Where is the data processed?">
    Documents and files are stored in the European Union (Ireland), and the AI that processes them also runs in the EU.
  </Accordion>

  <Accordion title="How much does it cost?">
    You pay per delivered document; failed ones are not charged. See [pricing](/en/guides/account#pricing).
  </Accordion>
</AccordionGroup>

## Keep reading

* [Google Vertex AI](/en/agents/vertex): the full guide, also with `@google/genai`.
* [Quickstart](/en/quickstart).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.