# Overview

Canonical URL: https://developers.iagenify.com/sdk/ref/models/
Language: en

Two ways to call a model, and they are not variants of each other. A session remembers and hands back finished outputs; a turn remembers nothing and hands back the model's next move.

Status: session · turn · one resource · credits on both

Most of the time you want a session: you ask, you get text or a structured object or a file, and the conversation carries on by itself. The turn is the lower layer — it is what an agent loop calls, over and over, and what you call when the loop is yours to write.

## The two shapes, side by side {#two}

|  | Session | Turn |
| --- | --- | --- |
| Created by | api.models.create() | nothing — it is one call |
| State | Kept server-side when memory is on | None. You send the whole history every time |
| Hands back | Finished outputs: text, JSON, images, audio, video | The model's next move: text, or tool calls |
| Tools | Server-side search and fetch, by setting | Your own declarations, called back to you |
| Deadline | None — a long generation runs to the end | Five minutes |
| You use it for | Assistants, extraction, generation | Writing your own agent loop |

> **If you are not sure, start with a session**
>
> The turn asks you to carry the conversation, re-send it each time, and decide what a tool call means. That is the right trade when you are building a loop, and an unnecessary one when you are not.

## The methods {#methods}

| Method | Does |
| --- | --- |
| create({ model, settings, schema, memory, storage }) | Opens a session. Returns an AssistantSession. |
| get(id) | Reopens a saved session. Returns an AssistantSession. |
| list({ limit }) | The account's sessions, newest first. Returns plain objects. |
| turn({ model, messages, tools, … }) | One stateless model turn, with native tool calling. |

> **get() and list() do not return the same kind of thing**
>
> get() hands back an AssistantSession, with generate() on it. list() hands back plain data, with no methods — pass an id from it to get() when you want to carry on.

## A session, end to end {#session}

```javascript
const assistant = await api.models.create({
  model: "gemini-3.5-flash",
  settings: { instructions: "Answer in French, in at most three sentences." },
});

const result = await assistant.generate({
  inputs: [{ type: "text", content: "Résume ce contrat." },
           // A document is always a url — unlike image, audio or video, "file" has no content form.
           { type: "file", url: "https://example.com/contrat.pdf" }],
});

result.outputs;        // [{ type: "text", content: "…" }]
result.usage.credits;  // what it actually cost

await assistant.generate({ inputs: [{ type: "text", content: "Et les risques ?" }] });
// the contract is still in the conversation — you do not re-send it
```

## A turn, end to end {#turn}

```javascript
let messages = [{ role: "user", content: "What is the weather in Tunis?" }];

const turn = await api.models.turn({
  model: "gemini-3.5-flash",
  messages,
  tools: [{ name: "weather", description: "Current weather for a city.",
            parameters: { city: { type: "string", required: true } } }],
});

turn.stopReason;          // "tool_use"
turn.message.toolCalls;   // [{ id, name: "weather", args: { city: "Tunis" }, signature }]

// You run the tool, you append the result, you call again.
```

The loop around that is yours. If you would rather not write one, the agent engine is that loop already built — see [Agent engine](/sdk/agent).

## What each one costs {#cost}

Both are billed on what reaches the provider, in the units the [catalogue](/sdk/ref/iagenify/catalogue) gives for that model. Two things are worth knowing before you design around either.

- **A session with memory pays for its history.** Every call re-sends the conversation, so a long one costs more per answer than a short one — until the older part is summarised for you, which happens on its own.
- **A turn pays for its declarations.** Tool definitions travel on every single turn. Ten tools you never call still cost tokens each time.

- [create()](/sdk/ref/models/create): Opening a session, and the four things that decide how it behaves.
- [turn()](/sdk/ref/models/turn): One stateless turn, with native tool calling.
- [AssistantSession](/sdk/ref/assistant-session): What create() and get() hand back.

```python
assistant = api.models.create(
    model="gemini-3.5-flash",
    settings={"instructions": "Answer in French, in at most three sentences."},
)

result = assistant.generate(inputs=[
    {"type": "text", "content": "Résume ce contrat."},
    {"type": "file", "url": "https://example.com/contrat.pdf"},
])

result["outputs"]            # [{"type": "text", "content": "…"}]
result["usage"]["credits"]   # what it actually cost

assistant.generate(inputs=[{"type": "text", "content": "Et les risques ?"}])
# the contract is still in the conversation — you do not re-send it
```

```python
messages = [{"role": "user", "content": "What is the weather in Tunis?"}]

turn = api.models.turn(
    model="gemini-3.5-flash",
    messages=messages,
    tools=[{"name": "weather", "description": "Current weather for a city.",
            "parameters": {"city": {"type": "string", "required": True}}}],
)

turn["stopReason"]              # "tool_use"
turn["message"]["toolCalls"]    # [{"id", "name": "weather", "args": {"city": "Tunis"}, "signature"}]

# You run the tool, you append the result, you call again.
```
