Rewrite with Xholic AI
curl -X POST https://api.xholic.ai/v1/composer/rewrite \ -H "Authorization: Bearer $XHOLIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{"text":"Shipping the API today","instruction":"<instruction>","mode":"selection","dryRun":true}'xholic composer rewrite --text 'Shipping the API today' --instruction '<instruction>' --mode 'selection' --dry-run{ "name": "composer_rewrite", "arguments": { "text": "Shipping the API today", "instruction": "<instruction>", "mode": "selection", "dryRun": true }}const response = await fetch("https://api.xholic.ai/v1/composer/rewrite", { method: "POST", headers: { Authorization: `Bearer ${process.env.XHOLIC_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ "text": "Shipping the API today", "instruction": "<instruction>", "mode": "selection", "dryRun": true }),});const result = await response.json();console.log(result.summary);import axios from "axios";
const { data } = await axios.post( "https://api.xholic.ai/v1/composer/rewrite", { "text": "Shipping the API today", "instruction": "<instruction>", "mode": "selection", "dryRun": true }, { headers: { Authorization: `Bearer ${process.env.XHOLIC_API_KEY}` } },);console.log(data.summary);import osimport requests
response = requests.post( "https://api.xholic.ai/v1/composer/rewrite", headers={"Authorization": f"Bearer {os.environ['XHOLIC_API_KEY']}"}, json={ "text": "Shipping the API today", "instruction": "<instruction>", "mode": "selection", "dryRun": True },)print(response.json()["summary"])package main
import ( "fmt" "io" "net/http" "os" "strings")
func main() { body := strings.NewReader(`{"text":"Shipping the API today","instruction":"<instruction>","mode":"selection","dryRun":true}`) req, _ := http.NewRequest("POST", "https://api.xholic.ai/v1/composer/rewrite", body) req.Header.Set("Authorization", "Bearer "+os.Getenv("XHOLIC_API_KEY")) req.Header.Set("Content-Type", "application/json") res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() out, _ := io.ReadAll(res.Body) fmt.Println(string(out))}<?php$ch = curl_init("https://api.xholic.ai/v1/composer/rewrite");curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . getenv('XHOLIC_API_KEY'), 'Content-Type: application/json', ], CURLOPT_POSTFIELDS => '{"text":"Shipping the API today","instruction":"<instruction>","mode":"selection","dryRun":true}',]);$result = json_decode(curl_exec($ch), true);echo $result['summary'];require "net/http"require "json"
uri = URI("https://api.xholic.ai/v1/composer/rewrite")req = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")req["Authorization"] = "Bearer #{ENV.fetch("XHOLIC_API_KEY")}"req.body = '{"text":"Shipping the API today","instruction":"<instruction>","mode":"selection","dryRun":true}'res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }puts JSON.parse(res.body)["summary"]Only when the user explicitly asks for Xholic’s rewriter. Rewrites a post or a selection by an instruction, or reviews the writing (mode review). Uses Xholic AI credits: quote first and pass confirmCredits after the user agrees. Otherwise rewrite it yourself.
Uses Xholic AI credits (up to about 8). The first call returns CREDITS_CONFIRMATION_REQUIRED with a quote; after the user agrees, call again with confirmCredits and the quote’s quoteId.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
The post, or the selected part to rewrite.
The full post around a selection.
X account to act on, as @handle. Leave it out to use the connection’s default account.
Return exactly what would happen without doing it.
A unique key for this write. Repeating a call with the same key returns the first result instead of acting twice.
Xholic AI credits the user agreed to spend. Call first without it to get the quote, show the quote to the user, and pass the amount only after they say yes.
The quoteId from the quote the user agreed to. Send it with confirmCredits.
Example
{ "text": "Shipping the API today", "instruction": "<instruction>", "mode": "selection", "dryRun": true}Responses
Section titled “Responses”Success
object
One or two readable sentences about the result.
The result. Its shape depends on the action.
object
Example
{ "ok": true}default
Section titled “default”Error
object
object
Example
{ "ok": false, "error": { "code": "UNAUTHENTICATED", "scope": "account" }}