Skip to main content
POST
curl
Answers a conversation with one of the chat models. The reply comes back whole, or as server-sent events with "stream": true.

Price

The price uses the output token budget. Send a positive integer in max_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 send reasoning_effort:
  • Leave it out, or send none or minimal: the model answers without thinking.
  • Send another nonempty string, such as low, medium or high: 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:
With streaming, the thinking is held until it is finished, then sent whole in one chunk as delta.reasoning_content, before the answer streams in delta.content.

Streaming

An accepted request with stream: 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].
A refusal at submission returns an HTTP error and a JSON body, even with 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, user or assistant. A developer message becomes a system message. Send content as a string or an array of text parts.
  • Defaults. Top-level null values behave like omitted fields. Both model and messages are required.
  • Stop strings. Send stop as a string or a list of strings. The returned answer ends before the first matching string, including when streamed.
  • One reply. Omit n or set it to 1. A value above 1 gets 400 unsupported_value.
  • Output format. Use text. Requesting json_object or json_schema in response_format gets 400 unsupported_value.
  • Tools. Omit tool_choice or send auto or none. A required or named tool choice gets 400 unsupported_value. The model does not call tools.
  • Ignored fields. tools, seed, logprobs, presence_penalty, frequency_penalty, logit_bias and user.

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

Authorization
string
header
required

An API token from the account panel on sharemy.ai. Tokens start with smai_.

Body

application/json

Top-level null fields are treated as omitted.

model
enum<string>
required

A chat model id. There is no default.

Available options:
smollm2-360m,
qwen3-06b,
qwen3-17b,
qwen3-4b,
gemma-4-e2b,
gemma-4-e4b
messages
object[]
required

1 to 100 messages, with at most 64,000 characters of text across all of them.

Required array length: 1 - 100 elements
max_tokens
integer | null

Maximum output tokens used for generation and pricing. Defaults to 1024 or 2048 by model. Values above 4096 are capped and reported in X-ShareMyAI-Max-Tokens.

Required range: x >= 1
max_completion_tokens
integer | null

Same budget and cap as max_tokens. Takes precedence when both are supplied.

Required range: x >= 1
temperature
number | null
default:0.7
Required range: 0 <= x <= 2
top_p
number | null
default:0.9
Required range: 0 <= x <= 1
stream
boolean | null
default:false

Send the reply as server-sent events while it is written.

reasoning_effort
string | null

Any nonempty string except none or minimal enables thinking on supported models. smollm2-360m ignores it.

Example:

"medium"

n
enum<integer> | null

One completion per request. Values above 1 return 400 unsupported_value.

Available options:
1,
null
stop

End the returned answer before the first matching nonempty string.

response_format

Use text. json_object and json_schema return 400 unsupported_value.

tool_choice
enum<string> | null

Required or named choices return 400 unsupported_value. Tool calls are unsupported.

Available options:
auto,
none,
null
stream_options
object | null

Options for streamed replies.

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.

id
string
required
Example:

"chatcmpl-6f1c2e0d9b6a4f3c8e7d5b4a3c2e1f0a"

object
string
required
Allowed value: "chat.completion"
created
integer
required

Unix time in seconds.

model
string
required
choices
object[]
required
usage
object
required

Token counts. prompt_tokens is an estimate (characters divided by four). completion_tokens is the model's own count when it reports one, otherwise also an estimate.