Skip to main content

Your first API call

Let's call a language model to confirm everything is set up.

Prerequisites

  • You have an EcoLink account (sign up here)
  • You have an API key (create one here)
  • You have at least $0.01 of credit (new accounts get $1.00 free)

Call a chat model

curl https://api.ecohash.com/v1/chat/completions \
-H "Authorization: Bearer eco_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"model": "meta-llama/Llama-3.1-8B-Instruct",
"messages": [
{"role": "user", "content": "In one sentence: what is EcoLink?"}
]
}'

Response (truncated):

{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1776391234,
"model": "meta-llama/Llama-3.1-8B-Instruct",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "EcoLink is a GPU cloud platform providing on-demand GPU instances and pre-deployed inference models."
},
"finish_reason": "stop"
}],
"usage": { "prompt_tokens": 18, "completion_tokens": 24, "total_tokens": 42 }
}

That's it — you just ran inference on a Llama 3.1 8B model deployed in one of our regions.

With streaming

Add "stream": true to get tokens as they're generated (server-sent events):

curl https://api.ecohash.com/v1/chat/completions \
-H "Authorization: Bearer eco_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-N \
-d '{
"model": "meta-llama/Llama-3.1-8B-Instruct",
"messages": [{"role": "user", "content": "Count to 10 slowly"}],
"stream": true
}'

Each line is a data: prefixed JSON chunk; the last one is data: [DONE]. See Chat completions for the full response schema.

With the OpenAI Python SDK

from openai import OpenAI
client = OpenAI(
api_key="eco_YOUR_KEY_HERE",
base_url="https://api.ecohash.com/v1",
)

resp = client.chat.completions.create(
model="meta-llama/Llama-3.1-8B-Instruct",
messages=[{"role": "user", "content": "In one sentence: what is EcoLink?"}],
)
print(resp.choices[0].message.content)

Try image generation

curl https://api.ecohash.com/v1/images/generations \
-H "Authorization: Bearer eco_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-1-schnell",
"prompt": "a photorealistic golden retriever wearing a top hat",
"size": "1024x1024"
}'

The response contains a base64-encoded PNG in data[0].b64_json or a hosted URL in data[0].url (depending on response_format).

Try speech-to-text

curl https://api.ecohash.com/v1/audio/transcriptions \
-H "Authorization: Bearer eco_YOUR_KEY_HERE" \
-F model=large-v3 \
-F file=@recording.mp3

Response:

{ "text": "Hello, this is a test of the EcoLink speech-to-text API." }

What to do next