curl
curl https://sharemy.ai/v1/chat/completions \
-H "Authorization: Bearer $SHAREMYAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-4b",
"messages": [{"role": "user", "content": "Why is the sky blue?"}],
"max_tokens": 256
}'import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["SHAREMYAI_API_KEY"], base_url="https://sharemy.ai/v1")
completion = client.chat.completions.create(
model="qwen3-4b",
messages=[{"role": "user", "content": "Why is the sky blue?"}],
max_tokens=256,
)
print(completion.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.SHAREMYAI_API_KEY, baseURL: "https://sharemy.ai/v1" });
const completion = await client.chat.completions.create({
model: "qwen3-4b",
messages: [{ role: "user", content: "Why is the sky blue?" }],
max_tokens: 256,
});
console.log(completion.choices[0].message.content);{
"id": "chatcmpl-6f1c2e0d9b6a4f3c8e7d5b4a3c2e1f0a",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "<string>",
"reasoning_content": "<string>"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"cost_credits": 123
}
}{
"error": {
"message": "Choose a temperature from 0 to 2.",
"type": "invalid_request_error",
"param": "temperature",
"code": "invalid_value"
}
}{
"error": {
"message": "Send your API token as Authorization: Bearer smai_…. Create one at https://sharemy.ai, account panel, API tokens.",
"type": "invalid_request_error",
"param": null,
"code": "invalid_api_key"
}
}{
"error": {
"message": "This costs 8.192 credits and your balance is 3.000 credits. Add credits at https://sharemy.ai.",
"type": "insufficient_quota",
"param": null,
"code": "insufficient_quota",
"price_credits": 8.192,
"balance_credits": 3
}
}{
"error": {
"message": "This account is suspended. If you think that is a mistake, contact us.",
"type": "invalid_request_error",
"param": null,
"code": "account_suspended"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}{
"error": {
"message": "At most 4 API calls at once. Wait for one to finish.",
"type": "invalid_request_error",
"param": null,
"code": "rate_limit_exceeded"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}{
"error": {
"message": "The machine running this left the network. (request 69ba81e5-6a67-4cd5-a28b-2e023337b936)",
"type": "api_error",
"param": null,
"code": "network_error"
}
}{
"error": {
"message": "No machine that runs this model is online right now. (request 69ba81e5-6a67-4cd5-a28b-2e023337b936)",
"type": "api_error",
"param": null,
"code": "no_provider"
}
}API reference
Create a chat completion
Answer a conversation with an open chat model such as Qwen3 or Gemma 4, as one JSON reply or as server-sent events.
POST
/
v1
/
chat
/
completions
curl
curl https://sharemy.ai/v1/chat/completions \
-H "Authorization: Bearer $SHAREMYAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-4b",
"messages": [{"role": "user", "content": "Why is the sky blue?"}],
"max_tokens": 256
}'import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["SHAREMYAI_API_KEY"], base_url="https://sharemy.ai/v1")
completion = client.chat.completions.create(
model="qwen3-4b",
messages=[{"role": "user", "content": "Why is the sky blue?"}],
max_tokens=256,
)
print(completion.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.SHAREMYAI_API_KEY, baseURL: "https://sharemy.ai/v1" });
const completion = await client.chat.completions.create({
model: "qwen3-4b",
messages: [{ role: "user", content: "Why is the sky blue?" }],
max_tokens: 256,
});
console.log(completion.choices[0].message.content);{
"id": "chatcmpl-6f1c2e0d9b6a4f3c8e7d5b4a3c2e1f0a",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "<string>",
"reasoning_content": "<string>"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"cost_credits": 123
}
}{
"error": {
"message": "Choose a temperature from 0 to 2.",
"type": "invalid_request_error",
"param": "temperature",
"code": "invalid_value"
}
}{
"error": {
"message": "Send your API token as Authorization: Bearer smai_…. Create one at https://sharemy.ai, account panel, API tokens.",
"type": "invalid_request_error",
"param": null,
"code": "invalid_api_key"
}
}{
"error": {
"message": "This costs 8.192 credits and your balance is 3.000 credits. Add credits at https://sharemy.ai.",
"type": "insufficient_quota",
"param": null,
"code": "insufficient_quota",
"price_credits": 8.192,
"balance_credits": 3
}
}{
"error": {
"message": "This account is suspended. If you think that is a mistake, contact us.",
"type": "invalid_request_error",
"param": null,
"code": "account_suspended"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}{
"error": {
"message": "At most 4 API calls at once. Wait for one to finish.",
"type": "invalid_request_error",
"param": null,
"code": "rate_limit_exceeded"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}{
"error": {
"message": "The machine running this left the network. (request 69ba81e5-6a67-4cd5-a28b-2e023337b936)",
"type": "api_error",
"param": null,
"code": "network_error"
}
}{
"error": {
"message": "No machine that runs this model is online right now. (request 69ba81e5-6a67-4cd5-a28b-2e023337b936)",
"type": "api_error",
"param": null,
"code": "no_provider"
}
}Answers a conversation with one of the chat models. The reply comes back whole, or as server-sent events with
With streaming, the thinking is held until it is finished, then sent whole in one chunk as
A refusal at submission returns an HTTP error and a JSON body, even with
"stream": true.
Price
The price uses the output token budget. Send a positive integer inmax_completion_tokens or max_tokens. If you send both, max_completion_tokens wins. The model default is 1,024 or 2,048. Values above 4,096 are capped at 4,096 for generation and pricing. When capped, the response includes X-ShareMyAI-Max-Tokens: 4096. See Credits and pricing.
Thinking
The Qwen3 and Gemma 4 models can think before they answer. Thinking is off unless you sendreasoning_effort:
- Leave it out, or send
noneorminimal: the model answers without thinking. - Send another nonempty string, such as
low,mediumorhigh: the model thinks first. The level itself makes no difference.
smollm2-360m never thinks and ignores the field. Thinking uses tokens from max_tokens, so allow enough for both.
Without streaming, the thinking comes back in message.reasoning_content, apart from the answer in message.content:
{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1764900000,
"model": "qwen3-4b",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "391",
"reasoning_content": "17 times 23: 17 times 20 is 340, plus 17 times 3 is 51..."
},
"finish_reason": "stop"
}],
"usage": { "prompt_tokens": 5, "completion_tokens": 54, "total_tokens": 59, "cost_credits": 4.096 }
}
delta.reasoning_content, before the answer streams in delta.content.
completion = client.chat.completions.create(
model="qwen3-4b",
messages=[{"role": "user", "content": "What is 17 times 23?"}],
reasoning_effort="medium",
max_tokens=1024,
)
message = completion.choices[0].message
print(getattr(message, "reasoning_content", None))
print(message.content)
const completion = await client.chat.completions.create({
model: "qwen3-4b",
messages: [{ role: "user", content: "What is 17 times 23?" }],
reasoning_effort: "medium",
max_tokens: 1024,
});
const message = completion.choices[0].message;
console.log(message.reasoning_content);
console.log(message.content);
Streaming
An accepted request withstream: true opens a text/event-stream response. The first content or reasoning chunk carries the assistant role. Ignore the : waiting keepalive comments sent every 15 seconds while the stream is open.
On success, the final choice has an empty delta and a finish_reason of stop or length. Set stream_options.include_usage to true to receive one more chunk with choices: [] and the full usage before data: [DONE].
curl -N https://sharemy.ai/v1/chat/completions \
-H "Authorization: Bearer $SHAREMYAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "qwen3-4b", "stream": true, "max_tokens": 512,
"messages": [{"role": "user", "content": "Tell me a short story."}]}'
stream = client.chat.completions.create(
model="qwen3-4b",
messages=[{"role": "user", "content": "Tell me a short story."}],
max_tokens=512,
stream=True,
)
for chunk in stream:
if chunk.choices:
print(chunk.choices[0].delta.content or "", end="", flush=True)
const stream = await client.chat.completions.create({
model: "qwen3-4b",
messages: [{ role: "user", content: "Tell me a short story." }],
max_tokens: 512,
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
stream: true. A failure after acceptance sends one error event and closes the stream. If a machine leaves mid-reply, the stream ends with network_error and the job is refunded. See Errors in a stream.
Request fields
- Messages. Use
system,developer,userorassistant. Adevelopermessage becomes a system message. Send content as a string or an array of text parts. - Defaults. Top-level
nullvalues behave like omitted fields. Bothmodelandmessagesare required. - Stop strings. Send
stopas a string or a list of strings. The returned answer ends before the first matching string, including when streamed. - One reply. Omit
nor set it to1. A value above 1 gets400 unsupported_value. - Output format. Use text. Requesting
json_objectorjson_schemainresponse_formatgets400 unsupported_value. - Tools. Omit
tool_choiceor sendautoornone. A required or named tool choice gets400 unsupported_value. The model does not call tools. - Ignored fields.
tools,seed,logprobs,presence_penalty,frequency_penalty,logit_biasanduser.
Finish reason and usage
For both response formats,finish_reason is length when the model reports reaching the output budget or ends with unfinished thinking. Otherwise it is stop.
usage.prompt_tokens estimates one token per four characters, rounded up. completion_tokens uses the model’s count when available and otherwise uses the same estimate. usage.cost_credits is the price in credits.Authorizations
Body
application/json
Top-level null fields are treated as omitted.
Response
One completion or an accepted SSE stream. A successful stream ends with [DONE], preceded by a usage chunk if requested. A later failure sends one error event and closes. A refusal before acceptance returns an HTTP error with JSON.