# Optimize

### NodeJS

```javascript
const rpai = await ai.optimize({
  text: "FakeBrand Boa XL Max Water Pump Pliers in a Festive Christmas Ornament",
  instruction: "SEO for an online store product title",
});

console.log("Optimized title:", rpai.response);
```

### .NET

<pre class="language-csharp"><code class="lang-csharp">//Response format can be created manually but it is easier to use a type
//await ai.Optimize(new() {
//Text= "FakeBrand Boa XL Max Water Pump Pliers in a Festive Christmas Ornament",
//Instruction= "SEO for an online store product title"
//}).ConfigureAwait(false);

var rpai = await ai.Optimize&#x3C;string>(new() {
<strong>  Text= "FakeBrand Boa XL Max Water Pump Pliers in a Festive Christmas Ornament",
</strong>  Instruction= "SEO for an online store product title"
}).ConfigureAwait(false);

Console.WriteLine("Optimized title: {0}", rpai);
</code></pre>

### **/api/v1/ai/Optimize – Optimize Text Based on Instructions**

**Method**:\
`POST`

**Parameters**:

* `text`: *(string)* – The text to optimize.
* `instruction`: *(string)* – The instruction for optimizing the text.
* `responseFormat`: *(string)* – The format of the response (e.g., `text`, `json`).

**Request Example**:

```bash
curl -X POST https://production.cloudbrowser.ai/api/v1/ai/Optimize \
-H "Content-Type: application/json" \
-d '{
  "text": "10 Tips for Gardening",
  "instruction": "Make the title more engaging for SEO",
  "responseFormat": "text"
}'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cloudbrowser.gitbook.io/docs/configurations/ai-functions/optimize.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
