#hey can i use my credits via the API?

1 messages · Page 1 of 1 (latest)

flat basaltBOT
#
AI-generated Answer for gammie12

Yes, you can use your credits via the API. To check your remaining credits and usage, you can visit the Usage Analytics page, which provides detailed information on your credit balance and usage. Additionally, there is an API endpoint available to retrieve this information, allowing you to query your user details, including credit usage.

If you encounter any issues, ensure your API key is included in the request headers, and refer to the API References for further details on testing calls and using the API effectively.

vivid shadow
#

I have 211k crédit i'm asking if i use the api will it deduce from my credit or i should pay for the api separatly?

flat basaltBOT
#
AI-generated Answer for gammie12

Yes, you can use your existing credits via the API. When you make API calls, the characters used will be deducted from your available credit balance. You do not need to pay separately for the API as long as you have credits remaining in your account. If your credits run out, you can enable usage-based billing through a subscription plan to pay for additional credits.

vivid shadow
#

can this code run for the api call ?

import os, requests
import pysrt

--- CONFIG ---

API_KEY = os.getenv("ELEVENLABS_API_KEY") # sécuriser avec .env
VOICE_ID = "votre_voice_id" # à récupérer via GET /v1/voices
MODEL_ID = "eleven_multilingual_v2"
SRT_FILE = "votre_fichier.srt"

CREDIT_COST_PER_CHAR = 1.0 # pour multilingual v2
OUTPUT_DIR = "outputs"
os.makedirs(OUTPUT_DIR, exist_ok=True)

--- FONCTIONS ---

def estimate_credits(text):
return len(text) * CREDIT_COST_PER_CHAR

def synth_text(text, idx):
url = f"https://api.elevenlabs.io/v1/text-to-speech/{VOICE_ID}"
headers = {"xi-api-key": API_KEY, "Content-Type": "application/json"}
payload = {
"text": text,
"model_id": MODEL_ID,
# Optionnel : sans override, laisse les settings par défaut
}
resp = requests.post(url, headers=headers, json=payload)
if resp.status_code == 200:
fn = os.path.join(OUTPUT_DIR, f"output_{idx}.mp3")
with open(fn, "wb") as f:
f.write(resp.content)
print(f"[OK] {fn} ({len(resp.content)//1024} Ko)")
return True
else:
print(f"[Erreur] statut {resp.status_code} – {resp.text}")
return False

--- MAIN 🚀 ---

def main():
if not os.path.exists(SRT_FILE):
print("Fichier introuvable:", SRT_FILE); return

subs = pysrt.open(SRT_FILE)
total_chars = 0
total_credits = 0

for i, sub in enumerate(subs, start=1):
    text = sub.text.replace("\n", " ").strip()
    if text:
        chars = len(text)
        credits = estimate_credits(text)
        print(f"[{i}] «…{text[:30]}…» → {chars} chars ≈ {credits:.1f} crédits")
        total_chars += chars
        total_credits += credits
        synth_text(text, i)

print(f"\nTotal estimé : {total_chars} caractères → {total_credits:.1f} crédits")

if name == "main":
main()

flat basaltBOT
#
AI-generated Answer for gammie12

Yes, you can use your credits via the API. When you make API calls, the usage will deduct from your available credits, provided you are on a plan that includes API access. You do not need to pay separately for the API if your subscription already covers it.

Regarding your code, it looks functional for making API calls to ElevenLabs' text-to-speech service. However, ensure the following:

  1. API Key: Make sure your ELEVENLABS_API_KEY is correctly set in your environment variables.
  2. Voice ID: Replace votre_voice_id with the actual voice ID obtained via the API (GET /v1/voices).
  3. Model ID: Confirm that eleven_multilingual_v2 is the correct model ID for your use case.
  4. Credit Cost: The CREDIT_COST_PER_CHAR variable should reflect the actual cost per character for the model you're using. Check your plan details or API documentation for accuracy.

If you encounter any issues, verify your API key, voice ID, and model ID, and ensure your subscription plan supports the API.

vivid shadow
#

will it cost mor if use the api than if i put the texte on the webesite?

flat basaltBOT
#
AI-generated Answer for gammie12

Using the API and the website interface will deduct credits from your account in the same way, as both are based on character usage. There is no separate payment required for the API if you already have credits available. However, keep in mind that text normalization is applied on the website interface but not through the API, which may affect the output quality or pronunciation. You might need to adjust your input text manually when using the API.

Regarding your code, it appears functional for making API calls, provided your API key and voice ID are correctly set. Ensure you account for the character cost per model, as multilingual models like "eleven_multilingual_v2" may have specific credit costs per character.

If you have further questions about pricing or need detailed cost estimates, you can check the Pricing Page.

vivid shadow
#

why when i use any voice id that is not on my voice, it's been add in my voice library? may i not use a voice in the api, without it bein added inmy voice librairie?

flat basaltBOT
#
AI-generated Answer for gammie12
  1. Using Credits via API: Yes, you can use your credits through the API. The API will deduct credits based on the text-to-speech operations you perform, similar to using the ElevenLabs website. You do not need to pay separately for the API if you already have credits.

  2. Cost Difference Between API and Website: The cost per character is the same whether you use the API or the website. The pricing depends on the model and voice settings you use, not the platform.

  3. Code for API Call: Your code looks functional for making API calls to ElevenLabs. Ensure that:

    • You replace votre_voice_id with the actual voice ID from your account.
    • The API key is correctly set in your environment variables.
    • The CREDIT_COST_PER_CHAR matches the model you're using (e.g., multilingual models may have specific costs).
  4. Voice ID Behavior in API: When you use a voice ID that is not already in your "My Voices" collection, it gets added automatically to your library. This is the default behavior to ensure you have access to the voice for future use. Currently, there is no way to use a voice via the API without it being added to your library.

vivid shadow
#

Ok for this voice can i add it in my collection pls instead o my voice?

flat basaltBOT
#
AI-generated Answer for gammie12

Currently, when you use a voice ID in the API that is not already in your "My Voice" section, it gets automatically added to your voice library under "My Voice." Unfortunately, there isn't an option to directly add it to a different collection, such as "Favorites" or another custom collection, through the API.

If you'd like to organize voices differently, you can manually move or manage them within the Voice Library on the ElevenLabs platform. Let me know if you have further questions!

vivid shadow
#

i do...pls what happen if dont have any voic slot anymore and that i used a voice id tht is not in my voice?

flat basaltBOT
#
AI-generated Answer for gammie12

When you use a voice ID in the API that is not already in your "My Voices" library, the voice is automatically added to your library, which consumes one of your custom voice slots. If you have no available voice slots left, you will not be able to add the voice, and the API request will likely fail.

To free up space, you can delete existing voices from your library. Navigate to the VoiceLab, go to the "Personal" or "Community" tab, and delete voices you no longer need. Default voices do not count toward your storage limit and cannot be deleted.

vivid shadow
#

help me pls, how can i know when i will receive ma next crédits?