### Sample Prompt for Text-to-Embedding Source: https://deapi.ai/models?type=text-to-embedding Provides an example of the input text that can be converted into vector embeddings using the Text-to-Embedding model. ```text The quick brown fox jumps over the lazy dog ``` -------------------------------- ### Go OpenAI SDK with deAPI Base URL Source: https://deapi.ai/use-cases/openai-api Initialize the Go OpenAI client using `option.WithBaseURL` to direct requests to deAPI. This example shows image generation. ```go package main import ( context "context" openai "github.com/openai/openai-go" "github.com/openai/openai-go/option" ) func main() { client := openai.NewClient( option.WithAPIKey("dpn-sk-your-token-here"), option.WithBaseURL("https://oai.deapi.ai/v1"), ) img, _ := client.Images.Generate(context.TODO(), openai.ImageGenerateParams{ Model: openai.F("Flux_2_Klein_4B_BF16"), Prompt: openai.F("a neon-lit city at dusk"), }) _ = img } ``` -------------------------------- ### Text-to-Image Prompt Enhancement Request Example Source: https://deapi.ai/use-cases/prompt-enhancer Send a simple text prompt and an optional negative prompt to the `/prompt/image` endpoint. The API will return an enhanced prompt and a negative prompt optimized for image generation models. ```json { "prompt": "a cat on a chair", "negative_prompt": "blurry" } ``` -------------------------------- ### Multi-Provider Pattern with OpenAI SDK Source: https://deapi.ai/blog/use-your-openai-sdk-with-deapi Demonstrates how to use separate OpenAI client instances for different services, one for chat completions via OpenAI and another for media generation (images, TTS) via deAPI, by configuring distinct `base_url` values. ```python from openai import OpenAI # Chat completions via OpenAI chat_client = OpenAI(api_key="sk-...") # Image gen + TTS via deAPI media_client = OpenAI(api_key="dpn-sk-...", base_url="") response = media_client.images.generate( model="flux-2-klein-4b-bf16", prompt="A minimalist logo for a podcast app", size="1024x1024" ) ``` -------------------------------- ### Initialize OpenAI and deAPI Clients Source: https://deapi.ai/use-cases/openai-api Instantiate two OpenAI clients within the same application. One client is configured for OpenAI's chat completions, while the other uses deAPI's `base_url` and API key for media inference tasks. This pattern allows for per-modality cost optimization. ```python from openai import OpenAI # Chat — OpenAI chat = OpenAI(api_key="sk-...") # Media — deAPI (same SDK, different base_url) media = OpenAI( api_key="dpn-sk-your-token-here", base_url="https://oai.deapi.ai/v1", ) reply = chat.chat.completions.create( model="gpt-5", messages=[{"role":"user", "content":"Describe this scene."}] ) picture = media.images.generate( model="Flux_2_Klein_4B_BF16", prompt=reply.choices[0].message.content, ) voice_over = media.audio.speech.create( model="Kokoro", voice="af_bella", input=reply.choices[0].message.content, ) ``` -------------------------------- ### deAPI TTS Conversion (After) Source: https://deapi.ai/compare/elevenlabs Example of making a Text-to-Speech request to deAPI. Uses the 'Authorization: Bearer' header and specifies the model in the request body. ```curl curl -s -X POST \ https://api.deapi.ai/api/v1/client/txt2speech \ -H "Authorization: Bearer $DEAPI_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "model": "", "prompt": "Hello from deAPI" }' ``` -------------------------------- ### ElevenLabs TTS Conversion (Before) Source: https://deapi.ai/compare/elevenlabs Example of making a Text-to-Speech request to ElevenLabs using their API. Requires an 'xi-api-key' header and specifies the voice ID in the URL. ```curl curl -s -X POST \ https://api.elevenlabs.io/v1/text-to-speech/21m00Tcm4TlvDq8ikWAM \ -H "xi-api-key: $ELEVENLABS_KEY" \ -H "Content-Type: application/json" \ -d '{ "text": "Hello from ElevenLabs", "model_id": "eleven_flash_v2_5" }' ``` -------------------------------- ### Text-to-Image API Endpoint Source: https://deapi.ai/playground/text-to-image?model=ZImageTurbo_INT8 This snippet shows how to generate an image from a text prompt using the ZImageTurbo_INT8 model. It includes the request body structure and a cURL example. ```APIDOC ## POST /api/v1/client/txt2img ### Description Generates an image based on a provided text prompt using the ZImageTurbo_INT8 model. ### Method POST ### Endpoint https://api.deapi.ai/api/v1/client/txt2img ### Parameters #### Request Body - **model** (string) - Required - The name of the image generation model to use (e.g., "ZImageTurbo_INT8"). - **prompt** (string) - Required - The text description of the image to generate. - **width** (integer) - Optional - The desired width of the generated image in pixels. - **height** (integer) - Optional - The desired height of the generated image in pixels. - **seed** (integer) - Optional - A seed value for reproducible image generation. - **steps** (integer) - Optional - The number of diffusion steps to perform. ### Request Example ```json { "model": "ZImageTurbo_INT8", "prompt": "Hyperrealistic portrait photograph of a beautiful young woman, natural skin texture with subtle freckles, piercing green eyes with realistic light reflections, soft volumetric lighting from golden hour sun, wispy strands of auburn hair catching the light, shallow depth of field, shot on Hasselblad medium format camera, 85mm lens, professional fashion photography, magazine cover quality, photorealistic skin pores and fine details, natural makeup, serene confident expression", "width": 1024, "height": 576, "seed": 2658376769, "steps": 8 } ``` ### cURL Example ```bash curl -X POST \ 'https://api.deapi.ai/api/v1/client/txt2img' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {{ YOUR_API_TOKEN }}' \ -H 'Content-Type: application/json' \ -d "{ \"model\": \"ZImageTurbo_INT8\", \"prompt\": \"Hyperrealistic portrait photograph of a beautiful young woman, natural skin texture with subtle freckles, piercing green eyes with realistic light reflections, soft volumetric lighting from golden hour sun, wispy strands of auburn hair catching the light, shallow depth of field, shot on Hasselblad medium format camera, 85mm lens, professional fashion photography, magazine cover quality, photorealistic skin pores and fine details, natural makeup, serene confident expression\", \"width\": 1024, \"height\": 576, \"seed\": 2658376769, \"steps\": 8 }" ``` ### Response #### Success Response (200) - **image_url** (string) - URL to the generated image. - **cost** (number) - The cost incurred for generating the image. - **boost_cost** (number) - The cost incurred for using boost. #### Response Example ```json { "image_url": "https://example.com/generated_image.png", "cost": 0.006329, "boost_cost": 0.000000 } ``` ``` -------------------------------- ### Generate Music with ACE-Step 1.5 Turbo (cURL) Source: https://deapi.ai/models/ace-step-turbo-music Use this cURL command to make a POST request to the deAPI /txt2music endpoint. Replace YOUR_API_KEY with your actual API key. The request body specifies the model, prompt, and desired duration in seconds. ```bash curl -X 'POST' \ 'https://api.deapi.ai/api/v1/client/txt2music' \ -H 'accept: application/json' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "model": "AceStep_1_5_Turbo", "prompt": "upbeat electronic background music", "duration": 30 }' ``` -------------------------------- ### Node.js/TypeScript OpenAI SDK with deAPI Base URL Source: https://deapi.ai/use-cases/openai-api Configure the OpenAI Node.js/TypeScript client with `baseURL` to connect to deAPI. This example demonstrates image generation and audio transcription. ```javascript import OpenAI from "openai"; const client = new OpenAI({ apiKey: "dpn-sk-your-token-here", baseURL: "https://oai.deapi.ai/v1", }); const img = await client.images.generate({ model: "Flux_2_Klein_4B_BF16", prompt: "a neon-lit city at dusk, cinematic", }); const tx = await client.audio.transcriptions.create({ model: "WhisperLargeV3", file: fs.createReadStream("meeting.mp3"), }); ``` -------------------------------- ### Retrieve Transcript from URL (Python) Source: https://deapi.ai/blog/how-to-transcribe-youtube-videos-with-ai After a transcription job is completed, this Python snippet downloads the transcript text from the provided 'result_url'. This is the final step to get the transcribed content. ```python transcript = requests.get(result_url).text print(transcript) ``` -------------------------------- ### Text-to-Video API Call (cURL) Source: https://deapi.ai/models/ltx-2-19b-video Use this cURL command to generate a video from a text prompt using the LTX-2 19B Distilled FP8 model. Ensure you replace 'YOUR_API_KEY' with your actual API key. ```bash curl -X 'POST' \ 'https://api.deapi.ai/api/v1/client/txt2video' \ -H 'accept: application/json' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "model": "Ltx2_19B_Dist_FP8", "prompt": "a cat walking through a garden", "width": 768, "height": 768, "num_frames": 65 }' ``` -------------------------------- ### Text-to-Speech: OpenAI vs. deAPI Request Comparison Source: https://deapi.ai/compare/openai Compares the POST request structure for text-to-speech generation between OpenAI's '/v1/audio/speech' endpoint and deAPI's '/v1/client/txt2speech' endpoint. Highlights differences in model selection and input parameters. ```json # OpenAI POST /v1/audio/speech { "model":"gpt-4o-mini-tts", "voice":"alloy", "input":"Hello from deAPI" } # also: tts-1, tts-1-hd ``` ```json # deAPI (open-weight voice) POST /v1/client/txt2speech { "model":"", "prompt":"Hello from deAPI" } # Same Bearer. Same request_id. # Same webhook contract. ```